[go-fan] Go Module Review: modelcontextprotocol/go-sdk #22389
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Go Fan. A newer discussion is available at Discussion #22626. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🐹 Go Fan Report: MCP Go SDK
The most recently updated unreviewed direct dependency — and gh-aw's most heavily-used external module (21 files!). The v1.4.1 patch dropped just 10 days ago with a security fix that the project gets for free.
Module Overview
github.com/modelcontextprotocol/go-sdkis the official Go SDK for the Model Context Protocol (MCP). It provides both server and client primitives: typed tool registration, stdio/HTTP transports, resource/root querying, and OAuth. This is the backbone of themcp-servercommand and themcp inspecttoolchain.v1.4.1✅ (latest)Current Usage in gh-aw
21 files use this module across the server and client layers.
Server Side (
pkg/cli/mcp_server*.go,mcp_tools_*.go)mcp.NewServer()→ configured withServerCapabilities, custom logger,ListChanged: falsemcp.AddTool()with typed generics:func(ctx, req, args) (*CallToolResult, any, error)mcp.ToolAnnotationson every tool (ReadOnlyHint, IdempotentHint, DestructiveHint, OpenWorldHint)mcp.Iconfor emoji-based tool iconsmcp.NewStreamableHTTPHandler()for the--portHTTP modemcp.StdioTransport{}for the default stdin/stdout modeClient Side (
pkg/cli/mcp_inspect_mcp.go)mcp.NewClient()+mcp.CommandTransport{}for stdio MCP inspectionmcp.StreamableClientTransport{}withDisableStandaloneSSE: truefor HTTP inspection (good practice!)session.ListTools(),session.ListResources()to surface server capabilitiesError Handling
jsonrpc.Error{Code, Message, Data}with a cleannewMCPError()helperjsonrpc.CodeInternalError,CodeInvalidParams,CodeInvalidRequestOverall assessment: Idiomatic, well-annotated, strong error handling. The team clearly knows the SDK well.
Research Findings
Recent Updates (v1.4.1 — 2026-03-13)
This was a security patch release:
http.CrossOriginProtection):Content-Type: application/jsonon POST requestsStreamableHTTPOptions.CrossOriginProtectionMCPGODEBUG=disableoriginverification=1go.modalready declares)Post-Release Main Branch (not yet released)
SetProgressTokenwhenMetais nil (silent data loss bug, feat: only upload docs build artifacts on main branch deployment #846)WWW-Authenticateheader (Remove Claude engine output.txt handling as CLI no longer produces this file #834)Best Practices from Maintainers
DisableStandaloneSSE: truefor query-only clients → already used ✅ListChanged: falsefor static tool sets → already set ✅Improvement Opportunities
🏃 Quick Wins
Paginate
ListToolsandListResourcesin the inspectormcp_inspect_mcp.godoes:This fetches only the first page. If an inspected MCP server has >N tools, the remaining ones are silently dropped. The fix is straightforward — loop on
toolsResult.NextCursor:Same pattern for
ListResources.✨ Feature Opportunities
Progress notifications for long-running tools
logsandaudittools can take up to 50 seconds. The MCP SDK supports progress tokens:progressTokeninCallToolParams.Metasession.SendProgress()to report intermediate statusThis would significantly improve UX for the two most expensive tools.
OutputSchemafor structured toolsTools like
status,compile,logs, andauditreturn well-defined JSON objects. The SDK'smcp.Tool.OutputSchemafield lets you declare the output structure, enabling clients to understand responses without parsing. The typedAddToolhandler already accepts a structured second return value — using a concrete type instead ofnilwould unlock this.📐 Best Practice Alignment
Document cross-origin protection behavior for HTTP users
Since v1.4.1,
mcp.NewStreamableHTTPHandlersilently rejects requests missingContent-Type: application/json(for POSTs) or with unexpected origins. Any HTTP MCP client that doesn't set these headers will get 403s. Worth documenting inmcp-server --portdocs, along with theMCPGODEBUG=disableoriginverification=1escape hatch for debugging.The project is already on v1.4.1 so this protection is active now.
Recommendations
ListTools/ListResourcesin inspector — silent data loss for large serversMCPGODEBUGoptionlogsandaudittoolsOutputSchemaon structured-output toolsNext Steps
ListToolspagination fix (simple, impactful)SetProgressToken— relevant if progress support is addedModule summary saved to:
scratchpad/mods/modelcontextprotocol-go-sdk.mdReferences: §23426091791
Beta Was this translation helpful? Give feedback.
All reactions