Skip to content

feat(agent/x/agentmcp): migrate workspace agent MCP client to official Go SDK - #28059

Draft
ibetitsmike wants to merge 1 commit into
mike/mcp-go-sdk/chatd-clientfrom
mike/mcp-go-sdk/agent-client
Draft

feat(agent/x/agentmcp): migrate workspace agent MCP client to official Go SDK#28059
ibetitsmike wants to merge 1 commit into
mike/mcp-go-sdk/chatd-clientfrom
mike/mcp-go-sdk/agent-client

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Stack Context

PR 4 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

The workspace agent MCP manager now stores *mcp.ClientSession per configured server.

  • stdio servers use mcp.CommandTransport with an exec.Cmd built from Coder's agentexec.Execer, preserving environment enrichment; the command uses the manager's parent context so a stdio subprocess outlives the connect handshake and stops when the session closes.
  • HTTP and SSE servers use header-injecting HTTP clients.
  • Binary tool content is re-encoded to base64 for the agent API because the official SDK decodes it into raw bytes.
  • The reload test now triggers config diffs via an environment variable because the official SDK drops connections on non-protocol stdout output (flags like -test.v made the fake server chatty).

Mux created this PR on Mike's behalf.

…l Go SDK

Replace the mark3labs client with the official SDK client for
.mcp.json-configured servers. Stdio servers run via CommandTransport
with the same execer-built command and enriched environment; the
subprocess still outlives the connect handshake because the command
context is the manager's, not the bounded connect context. HTTP and
SSE headers move to an http.RoundTripper on the transport's client.

Config parsing, transport inference, tool-name prefixing, catalog
snapshots, and the agent call-tool API keep their external shapes.
The SDK re-encodes binary content as base64 for the agent API and,
unlike mark3labs, closes stdio connections on non-protocol stdout
output, which is what the spec requires of servers.
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