Skip to content

feat(tools/mcp): MCP stdio runtime and registry integration (issue #19)#53

Merged
leo-aa88 merged 2 commits into
mainfrom
issue/19-mcp-stdio
Apr 11, 2026
Merged

feat(tools/mcp): MCP stdio runtime and registry integration (issue #19)#53
leo-aa88 merged 2 commits into
mainfrom
issue/19-mcp-stdio

Conversation

@leo-aa88
Copy link
Copy Markdown
Member

Summary

Implements MCP stdio execution for Tool specs (type: mcp, mcp.transport: stdio) per design doc §7.3, with JSON-RPC over newline-delimited JSON, initialize + notifications/initialized, and tools/call. Results are normalized to §13.2-style output maps (JSON in text content decoded when possible). Retries honor ToolSpec.retry (maxAttempts, backoff: fixed, exponential, or default short delay) for transport-style failures; JSON-RPC application errors are not retried.

Layout

Path Role
internal/tools/mcp/transport_stdio.go Subprocess stdin/stdout, RoundTrip, NDJSON read loop (skip notifications)
internal/tools/mcp/client.go Initialize, CallTool, parseCallToolResult
internal/tools/mcp/call.go CallStdio, ExecMeta, retry/backoff helpers
internal/tools/mcp/errors.go *rpcError for MCP RPC failures (non-retryable)
internal/tools/mcp/testdata/mockmcp/main.go Tiny MCP server: initialize + tools/call echoing arguments as JSON text
internal/tools/registry.go New mcp branch calling mcp.CallStdio with tool retry

Tests (no t.Skip)

  • internal/tools/mcp/mcp_test.go: go build mock binary → CallStdio round-trip; retry path with missing binary (expects failure after attempts).
  • internal/tools/tools_test.go: Registry.Call with MCP tool → same mock binary (end-to-end from uses string).

Out of scope (per issue)

  • MCP HTTP transport.

Verification

  • make fmt (go fmt ./...)
  • make test (go test ./... -race)
  • make vet

Closes #19

Made with Cursor

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
@leo-aa88 leo-aa88 merged commit 88f38a5 into main Apr 11, 2026
4 checks passed
@leo-aa88 leo-aa88 deleted the issue/19-mcp-stdio branch April 11, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MVP] MCP stdio tool runtime (internal/tools/mcp)

1 participant