feat(tools/mcp): MCP stdio runtime and registry integration (issue #19)#53
Merged
Conversation
Add JSON-RPC newline transport, initialize handshake, tools/call, result parsing to §13.2-style maps, and CallStdio with retry/backoff from ToolSpec.retry. Wire Registry type mcp + transport stdio to mcp.CallStdio. Include testdata/mockmcp subprocess and integration tests (issue #19). Made-with: Cursor
exec.Command requires a .exe path on windows-latest CI; without it the built binary path is not recognized as executable. Made-with: Cursor
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
Implements MCP stdio execution for
Toolspecs (type: mcp,mcp.transport: stdio) per design doc §7.3, with JSON-RPC over newline-delimited JSON,initialize+notifications/initialized, andtools/call. Results are normalized to §13.2-styleoutputmaps (JSON intextcontent decoded when possible). Retries honorToolSpec.retry(maxAttempts,backoff:fixed,exponential, or default short delay) for transport-style failures; JSON-RPC application errors are not retried.Layout
internal/tools/mcp/transport_stdio.goRoundTrip, NDJSON read loop (skip notifications)internal/tools/mcp/client.goInitialize,CallTool,parseCallToolResultinternal/tools/mcp/call.goCallStdio,ExecMeta, retry/backoff helpersinternal/tools/mcp/errors.go*rpcErrorfor MCP RPC failures (non-retryable)internal/tools/mcp/testdata/mockmcp/main.goinitialize+tools/callechoingargumentsas JSONtextinternal/tools/registry.gomcpbranch callingmcp.CallStdiowith toolretryTests (no
t.Skip)internal/tools/mcp/mcp_test.go:go buildmock binary →CallStdioround-trip; retry path with missing binary (expects failure after attempts).internal/tools/tools_test.go:Registry.Callwith MCP tool → same mock binary (end-to-end fromusesstring).Out of scope (per issue)
Verification
make fmt(go fmt ./...)make test(go test ./... -race)make vetCloses #19
Made with Cursor