feat(mcp): add MCP server with in-process command execution#98
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
Code Coverage ReportTotal Coverage: 54.4% Generated from commit: 737d426 |
This comment has been minimized.
This comment has been minimized.
09a9336 to
2be124e
Compare
This comment has been minimized.
This comment has been minimized.
2be124e to
6bb2303
Compare
6bb2303 to
d5de450
Compare
This comment has been minimized.
This comment has been minimized.
d5de450 to
3d3f008
Compare
This comment has been minimized.
This comment has been minimized.
3d3f008 to
af36550
Compare
This comment has been minimized.
This comment has been minimized.
25e0a30 to
fbedf4c
Compare
This comment has been minimized.
This comment has been minimized.
fbedf4c to
086fbcd
Compare
This comment has been minimized.
This comment has been minimized.
086fbcd to
479620c
Compare
This comment has been minimized.
This comment has been minimized.
479620c to
da90012
Compare
This comment has been minimized.
This comment has been minimized.
da90012 to
6c0fa22
Compare
This comment has been minimized.
This comment has been minimized.
6c0fa22 to
9ea8f9a
Compare
This comment has been minimized.
This comment has been minimized.
- Add MCP server with in-process command execution via root.Run - Wire RegisterWizardTools using WizardDepsFactory called at Action time, not construction time - Parameterless factory closures (func() State) — wizard constructors capture their own deps - Remove ConfigManager()/AuthService() from wizard state interfaces; step handlers access services via deps - Add max sessions enforcement to SessionStore (DefaultMaxSessions=100) with automatic expired-session eviction on Create - NewSessionStoreWithLimits constructor for custom TTL + max - Restore root.Writer/ErrWriter with defer in MCP command execution - Add tests for max sessions, eviction, and all wizard tool flows
9ea8f9a to
0561ef0
Compare
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Description
This PR adds a Model Context Protocol (MCP) server to pinner-cli, enabling AI agents to discover and invoke CLI commands as MCP tools, access live data via
pinner://resources, and drive interactive wizard workflows through structured prompts.Key additions:
MCP Server & Tool Adapter (
pkg/internal/mcp/adapter.go): Exposes all non-hidden CLI subcommands as MCP tools over stdio. Tool invocations execute the command tree in-process (no subprocess fork), capturing stdout/stderr into buffers and returning results to the agent. Extended flag-type support beyond the upstream adapter to include Float, Duration, and StringSlice flags.MCP Resources (
pkg/internal/mcp/resources.go): Registers fourpinner://resources that agents can read at runtime:pinner://account/status— auth state, quota, and masked config summarypinner://websites/{domain}/dns-requirements— DNS records the user must configurepinner://websites/{id}/validation-status— live website validation resultpinner://wizard/{session_id}/state— current wizard FSM state and next-step schemaMCP Prompts (
pkg/internal/mcp/prompts.go): Two prompt templates that generate step-by-step instructions for agents:website-onboarding— guides the agent through the website creation wizard (auth check, content source, target type, domain, DNS mode, create, DNS setup, validate)setup— guides the agent through initial setup (auth, config, shell completion, tutorial)Wizard Session Engine (
pkg/internal/mcp/session.go,wizard.go): A TTL-bounded, in-memory session store with FSM-driven step progression. Each step validates JSON input, mutates wizard state, and returns aStepResponsecontaining the next step name and its expected input schema. Sessions support retry on handler errors (FSM stays in the same state) and abort transitions from any step. Two wizard types are implemented: websites creation and initial setup.CLI Integration: The
mcpsubcommand is wired into the root command. Output formatters now respect the root command's writer, allowing in-process execution to capture output into buffers when invoked by the MCP adapter.