Skip to content

feat!: generate MCP servers on the official Go MCP SDK #89

Closed

Description

@erikist

Closes #44. The core migration from github.com/mark3labs/mcp-go to the official SDK, github.com/modelcontextprotocol/go-sdk v1.8.0 (requires Go 1.25). It lands on main; the old official-go-mcp branch and draft #74 are superseded, but #74's typed-handler idea is fine to reuse.

Do

  • go.mod: go 1.25, require github.com/modelcontextprotocol/go-sdk v1.8.0. Remove mark3labs from go.mod and go.sum.
  • Generator (cmd/protoc-gen-go-mcp/mcp.go), for each non-streaming RPC:
    • Tool: &mcp.Tool{Name, Description, InputSchema: <schema from #88 for the request message, emitted as a json.RawMessage literal>}.
    • Registration: mcp.AddTool[json.RawMessage, any](server, tool, handler) so that the SDK validates arguments against the schema (raw Server.AddTool does not validate).
    • Handler: protojson.Unmarshal(args, req) → call the gRPC client.
      • On success: return &mcp.CallToolResult{Content: []mcp.Content{&mcp.TextContent{Text: protojson.Marshal(resp)}}}.
      • On a gRPC error: return it as a Go error, which the SDK turns into an isError result. Include the gRPC status code in the message.
    • Exported API: keep the generated names and shape (New<Service>MCPServer, the per-tool accessors, RegisterDefaultTools) wherever the official types allow, and list any change in the PR body.
  • Examples: regenerate them, and update the golden file (test: golden-file test for the plugin's generated code #85).
  • cmd/mcp-vibe: mcp.NewServer(&mcp.Implementation{...}, nil) + server.Run(ctx, &mcp.StdioTransport{}).
  • End-to-end test (test: end-to-end test of a generated MCP server (gRPC backend + MCP client) #87): swap its MCP-client helper to mcp.NewInMemoryTransports() + mcp.NewClient(...).Connect(...) + ClientSession.CallTool.
    • Resolve the KNOWN BUG markers: the advertised schema must now be the top-level request schema.
    • Add a case where invalid arguments (wrong type or unknown field) produce isError: true and never reach the backend.
  • PR: a feat!: title and a BREAKING CHANGE: note in the body listing what users must change.

Acceptance criteria

  • grep -rn mark3labs . finds nothing (outside the CHANGELOG).
  • go build ./..., go vet ./... and go test ./... pass, including the golden and e2e tests.
  • Regeneration: make generate reproduces the committed examples exactly.
  • Smoke test, pasted in the PR: mcp-vibe over stdio answers initialize, tools/list and one tools/call.

Activity

  1. erikist commented on Oct 8, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: picked up by dispatcher; working on branch factory/89-feat-generate-mcp-servers-on-the.

  2. erikist commented on Oct 8, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: opened PR #99 migrating the generator, examples, cmd/mcp-vibe, and the e2e test to github.com/modelcontextprotocol/go-sdk v1.8.0 (Go 1.25). All of gofmt -l ., go vet ./..., go build ./..., and go test ./... pass, make generate reproduces the committed examples exactly, and a stdio smoke test of mcp-vibe (initialize / tools/list / tools/call) succeeds. See the PR body for the full breaking-change list and test evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions