Skip to content

feat: migrate coderd MCP server to official MCP Go SDK - #28056

Draft
ibetitsmike wants to merge 1 commit into
mainfrom
mike/mcp-go-sdk/coderd-http-server
Draft

feat: migrate coderd MCP server to official MCP Go SDK#28056
ibetitsmike wants to merge 1 commit into
mainfrom
mike/mcp-go-sdk/coderd-http-server

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Stack Context

PR 1 of 6 in a stack that migrates every Coder MCP surface from the archived github.com/mark3labs/mcp-go library to the official github.com/modelcontextprotocol/go-sdk v1.7.0, adding MCP 2026-07-28 support while keeping compatibility with clients speaking 2024-11-05 through 2025-06-18.

Stack: #28056 -> #28057 -> #28058 -> #28059 -> #28060 -> #28061

Why

The coderd Streamable HTTP MCP server (/api/experimental/mcp/http) is the foundation layer: it introduces the official SDK dependency and the shared RegisterSDKTool helper the CLI server reuses.

  • The server runs the SDK handler in stateless mode with JSONResponse: true, preserving the previous application/json POST wire format. GET and DELETE return 405, and no Mcp-Session-Id is issued, both permitted by the Streamable HTTP spec.
  • DisableLocalhostProtection is set because coderd commonly listens on loopback behind a reverse proxy with a public Host header; the endpoint's bearer authentication is the relevant access control.
  • Tool registration builds raw JSON object schemas and omits empty required, keeping tools/list output byte-identical to the previous server (verified with a golden comparison).
  • SDK logs are adapted to cdr.dev/slog/v3; only warnings and errors are forwarded because the SDK logs several INFO lines per stateless request.
  • Tests cover the modern 2026-07-28 flow, legacy 2025-06-18 initialize, unsupported protocol version rejection (-32022), and non-POST method behavior.

Mux created this PR on Mike's behalf.

Replace mark3labs/mcp-go with modelcontextprotocol/go-sdk v1.7.0 for
the /api/experimental/mcp/http endpoint. The server now speaks MCP
2026-07-28 (stateless lifecycle, server/discover, -32022 rejection)
while still negotiating down to 2024-11-05 for legacy clients.

The endpoint was already effectively stateless (a fresh server per
request, format-only session validation), so the SDK's stateless mode
changes only spec-permitted surface behavior: no Mcp-Session-Id
header and 405 for GET/DELETE. Tool schemas, annotations, and text
result content are wire-identical (golden-diffed against the old
server). mark3labs remains in go.mod for the not-yet-migrated
surfaces and as the legacy test client.
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.

1 participant