[go-fan] Go Module Review: modelcontextprotocol/go-sdk #27788
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Go Fan. A newer discussion is available at Discussion #28013. |
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: modelcontextprotocol/go-sdk
The most-recently-updated direct dependency in
go.mod— fresh v1.5.0 just dropped on 2026-04-07!Module Overview
github.com/modelcontextprotocol/go-sdkis the official Go SDK for the Model Context Protocol (MCP). It provides both server and client APIs for building and connecting to MCP servers over stdio or HTTP/SSE transports, with support for tools, resources, prompts, and OAuth.Current Usage in gh-aw
This is one of the most extensively used modules in the codebase — it powers the entire
gh aw mcp-servercommand.mcpandjsonrpcmcp.NewServer+mcp.AddTool(typed generics) — 12 tools registeredmcp.StdioTransport— default transport formcp-servermcp.NewStreamableHTTPHandler+StreamableHTTPOptions— HTTP mode with 2-hour session timeoutmcp.NewClient+mcp.CommandTransport— stdio client formcp-inspectmcp.StreamableClientTransportwithDisableStandaloneSSE: true— efficient HTTP inspectionmcp.ToolAnnotations—ReadOnlyHint,IdempotentHint,OpenWorldHinton all toolsmcp.Icon— emoji icons on every tooljsonrpc.Error— typed JSON-RPC error constructionThe usage is idiomatic and well-structured. The typed generic handler pattern (
func(ctx, *mcp.CallToolRequest, ArgsStruct)) is used consistently across all 12 tools, cancellation checks are at the top of every handler, and the HTTP inspector correctly usesDisableStandaloneSSE: trueto avoid unnecessary server-sent events connections.Research Findings
Recent Updates (v1.5.0 — 2026-04-07)
CallToolResult{IsError:true}instead of a JSON-RPC errorioConn.protocolVersionmutex fix (PR #832)Acceptmedia types (PR #853)http.ResponseControllerfor flushed writes (PR #870)auth/extauth)Best Practices from the SDK
DisableStandaloneSSE: truefor inspection-only HTTP clients ✅ (already done)session.Close()with defer ✅ (already done)ServerOptions.Loggerfor structured logging ✅ (already done)DestructiveHinton tools that modify state — see improvements belowImprovement Opportunities
🏃 Quick Wins
1. Add
DestructiveHintto mutating toolsThe
fix,update, andaddtools all modify the working tree (write files, apply codemods) but theirmcp.ToolAnnotationsdon't setDestructiveHint: true. MCP clients use this hint to warn users before calling destructive tools.2. Fix hardcoded client version in
mcp_inspect_mcp.goBoth
connectStdioMCPServerandconnectHTTPMCPServerhardcodeVersion: "1.0.0":The server uses
GetVersion()already — inspectors should too for traceability in MCP server logs.3. Verify input validation error handling after v1.5.0
PR #863 changed: schema validation failures are now
CallToolResult{IsError: true}instead of JSON-RPC errors. The project usesGenerateSchema[T]()for custom schemas and should check thatmcp_server_tools_test.gocovers invalid-input cases to confirm behavior is correct with this version.✨ Feature Opportunities
Progress reporting for long-running tools
The
logsandaudittools can run for minutes but provide no progress feedback. The SDK supports progress viaProgressToken:This would let MCP clients (e.g., Claude Code) show a spinner or progress percentage instead of a silent wait.
Pagination in
mcp-inspectcapability listingsession.ListToolsandsession.ListResourcesare called with empty params (no cursor). For MCP servers with many tools, paginated results are silently truncated. The fix:📐 Best Practice Alignment
Reduce duplication in
mcp_inspect_mcp.goconnectStdioMCPServerandconnectHTTPMCPServershare ~30 lines of identical capability-query logic (ListTools, ListResources with timeouts, error handling). Extract aqueryMCPCapabilities(ctx, session) (*MCPServerInfo, error)helper to eliminate the duplication.Recommendations (prioritized)
DestructiveHint: truetofix,update,addtool annotations — 3-line change per tool, immediate benefit for MCP client UXVersion: "1.0.0"withGetVersion()in both inspector clientsmcp-inspectcapability listinglogs/audittoolsNext Steps
mcp_server_tools_test.gofor invalid-input coverage to verify v1.5.0 compatibilityDestructiveHintannotationsModule summary saved to:
scratchpad/mods/go-sdk-mcp.mdReferences:
Beta Was this translation helpful? Give feedback.
All reactions