feat(cli): migrate exp mcp stdio server to official MCP Go SDK by ibetitsmike · Pull Request #28057 · coder/coder · GitHub
Skip to content

feat(cli): migrate exp mcp stdio server to official MCP Go SDK - #28057

Merged
ibetitsmike merged 1 commit into
mainfrom
mike/mcp-go-sdk/cli-stdio-server
Aug 13, 2026
Merged

feat(cli): migrate exp mcp stdio server to official MCP Go SDK#28057
ibetitsmike merged 1 commit into
mainfrom
mike/mcp-go-sdk/cli-stdio-server

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Stack Context

PR 2 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.

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

Why

coder exp mcp server (stdio) now uses the official SDK server with mcp.IOTransport over the invocation's stdin/stdout, and reuses the shared coderd/mcp.RegisterSDKTool helper from PR #28056 so both servers register tools identically.

  • A nopWriteCloser prevents the SDK from closing the invocation's stdout.
  • Tests send spec-compliant initialize params and notifications/initialized before tools/list because the official SDK enforces the protocol lifecycle.

Mux created this PR on Mike's behalf.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a34ad41281

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/exp_mcp_test.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Send initialized before reporter tool calls

The official SDK enforces the MCP initialization lifecycle, but both reporter test paths send tools/call immediately after reading the initialize response without sending notifications/initialized. In TestExpMcpReporter, the SDK can reject the call instead of invoking coder_report_task, causing the subsequent wait on the report channel to time out; send the notification here and in the Reconnect path, as the earlier server tests already do.

Useful? React with 👍 / 👎.

Comment thread cli/exp_mcp.go

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve omitted arguments for no-argument tools

When an MCP client omits the optional arguments field while calling a zero-input tool such as coder_get_authenticated_user or coder_list_templates, RegisterSDKTool forwards the resulting nil json.RawMessage to toolsdk.Generic, whose json.Unmarshal fails with an unexpected end of input. The previous mcpFromSDK adapter encoded the nil arguments map as JSON null, which successfully decoded into NoArgs; normalize missing arguments to {} or null before invoking the shared handler.

Useful? React with 👍 / 👎.

Base automatically changed from mike/mcp-go-sdk/coderd-http-server to main August 13, 2026 09:50
Replace mark3labs/mcp-go with the official SDK for coder exp mcp
server. Tool registration reuses coderd/mcp's RegisterSDKTool
adapter, preserving the allowlist, conditional registration of
user-authenticated tools and coder_report_task, and stdout purity
(protocol frames only, logs to stderr).

The SDK enforces the MCP lifecycle, so test fixtures now send a
spec-compliant initialize handshake before other requests.
@ibetitsmike
ibetitsmike force-pushed the mike/mcp-go-sdk/cli-stdio-server branch from a34ad41 to c13e42e Compare August 13, 2026 09:50
@ibetitsmike
ibetitsmike merged commit 26fe3f3 into main Aug 13, 2026
24 checks passed
@ibetitsmike
ibetitsmike deleted the mike/mcp-go-sdk/cli-stdio-server branch August 13, 2026 10:02
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants