feat(cli): migrate exp mcp stdio server to official MCP Go SDK - #28057
Conversation
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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 👍 / 👎.
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.
a34ad41 to
c13e42e
Compare

Stack Context
PR 2 of 6 in a stack that migrates every Coder MCP surface from the archived
github.com/mark3labs/mcp-golibrary to the officialgithub.com/modelcontextprotocol/go-sdkv1.7.0.Stack: #28056 -> #28057 -> #28058 -> #28059 -> #28060 -> #28061
Why
coder exp mcp server(stdio) now uses the official SDK server withmcp.IOTransportover the invocation's stdin/stdout, and reuses the sharedcoderd/mcp.RegisterSDKToolhelper from PR #28056 so both servers register tools identically.nopWriteCloserprevents the SDK from closing the invocation's stdout.notifications/initializedbeforetools/listbecause the official SDK enforces the protocol lifecycle.