[go-fan] Go Module Review: modelcontextprotocol/go-sdk #18080
Replies: 2 comments
-
|
🤖 Beep boop! The smoke test agent was here! 🚀 Just stopping by to say: all systems nominal, circuits are humming, and the coffee machine is still operational. The robots are taking over... the testing pipeline, at least! 🦾 [automated smoke test visit - run 22340962753]
|
Beta Was this translation helpful? Give feedback.
-
|
🎉 Greetings from the Copilot Smoke Test Bot! 🎉 I've just completed a full smoke test run and I'm pleased to report the automation machinery is purring like a well-oiled robot! 🤖 Here's my haiku tribute to this occasion:
Stay excellent, humans! 🚀 [run 22340962753]
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Selected today because: Most recently updated direct dependency — v1.3.1 released 2026-02-18 with a security fix.
Module Overview
github.com/modelcontextprotocol/go-sdkis the official Go implementation of the Model Context Protocol (MCP), the open standard for connecting AI models to tools and data sources. It is the backbone of gh-aw's MCP server, providing type-safe tool registration, multiple transport mechanisms (stdio, HTTP/SSE), and client-side MCP server inspection.Version in use: v1.3.1 (latest — released 2026-02-18)
Current Usage in gh-aw
The module is used across 9 production files and 14 test files, split between two packages:
mcpjsonrpcFiles:
pkg/cli/mcp_server.go,mcp_server_command.go,mcp_server_http.go,mcp_server_helpers.go,mcp_tools_readonly.go,mcp_tools_privileged.go,mcp_tools_management.go,mcp_inspect_mcp.go,pkg/parser/mcp.goKey APIs in use:
mcp.NewServer/mcp.AddTool(generic, type-safe) — 8 tools registeredmcp.ToolAnnotationswithReadOnlyHint,IdempotentHint,DestructiveHint,OpenWorldHintmcp.StdioTransport+mcp.NewStreamableHTTPHandler— dual transport supportmcp.NewClient+mcp.CommandTransport/mcp.StreamableClientTransport— client-side inspectormcp.Iconwith emoji sources on all toolsjsonrpc.ErrorwithCodeInternalError,CodeInvalidParams,CodeInvalidRequestAddSchemaDefault(compile: strict=true, logs: count=100, timeout=50)Research Findings
Recent Release History (v1.0.0 → v1.3.1)
DisableListeningfor client transport,LoggerinClientOptions, exportedGetError/SetErrorRecent Updates Worth Noting
Security patch (v1.3.1): The SDK's JSON decoder previously allowed case-insensitive struct field matching, which could be exploited to bypass server-side validation. The fix switches to
segmentio/encodingfor case-sensitive decoding. gh-aw is already on v1.3.1 — no action required.Schema caching (v1.3.0): Automatic caching of JSON schemas to avoid repeated reflection. The code in
mcp_server.goalready has a comment acknowledging this: "Schema caching is automatic in go-sdk v1.3.0+ (eliminates repeated reflection overhead)". Well noted.DisableListening(v1.3.0): A new option was added toStreamableClientTransportthat prevents the client from listening for any server-initiated messages at all. More on this below.Best Practices from Maintainers
ReadOnlyHint,OpenWorldHint, etc.) are core to the MCP 2025-11-05 spec and help clients make better decisions about tool invocation. ✅ gh-aw does this correctly.strict,count,timeout.Improvement Opportunities
🏃 Quick Wins
1. Adopt
DisableListening: truein the HTTP MCP inspectormcp_inspect_mcp.go:242usesDisableStandaloneSSE: trueonStreamableClientTransport. v1.3.0 addedDisableListening, which more precisely expresses intent for the inspector: it connects, queries capabilities, and leaves — no server push needed at all.2. Propagate parent context in
checkActorPermissionIn
mcp_server_helpers.go, the actor permission check creates a freshcontext.Background()context:If a tool handler's context is cancelled (e.g., client disconnects), this permission check still runs for up to 5 seconds against the GitHub API. Using the parent context would respect request lifecycle:
3. Release sub-contexts promptly in the MCP inspector
In
connectStdioMCPServerandconnectHTTPMCPServer, threeWithTimeoutcontexts are created sequentially and cancelled viadefer. Since they're used one-at-a-time, callingcancel()immediately after each operation (rather than deferring) would release resources sooner:✨ Feature Opportunities
1. Structured Tool Output via
OutputSchemaThe MCP 2025-11-25 spec supports typed output schemas via
mcp.Tool.OutputSchema. Thestatus,logs, andaudittools all return structured JSON — declaringOutputSchemawould allow LLM clients to understand and validate the tool's output format. The project already usesjsonschema-gofor input schema generation; the same pattern could extend to outputs.2. Consider a
newMCPErrorhelperThere are 30+
&jsonrpc.Error{Code: ..., Message: ..., Data: ...}literals scattered across tool files. A small helper function would reduce repetition and make error patterns more consistent:📐 Best Practice Alignment
ClientOptions.LoggerDisableListeningfor read-only inspectorcontext.Background()instead of caller ctxRecommendations
DisableListening: truein the HTTP inspector'sStreamableClientTransport— simple one-line change, more semantically correct.checkActorPermission— pass the tool handler context (with a 5s cap) to respect request lifecycle.OutputSchemafor the structured-output tools (status,audit,logs) — aligns with MCP 2025-11-25 spec and improves LLM integration.GetError/SetErrormethods exported in v1.3.0 — may simplify some error handling patterns in future cleanup.Next Steps
DisableListeningvsDisableStandaloneSSEbehavior in the HTTP inspectorcheckActorPermissioncontext propagationOutputSchemafor theaudittool as a proof-of-conceptModule summary saved to:
scratchpad/mods/go-sdk.mdWorkflow run: §22340699977
Date: 2026-02-24
Beta Was this translation helpful? Give feedback.
All reactions