[go-fan] Go Module Review: modelcontextprotocol/go-sdk #16774
Replies: 1 comment
-
|
/plan |
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.
-
The Go Fan is here! Today's deep dive focuses on
github.com/modelcontextprotocol/go-sdk— the most recently updated direct dependency in this project (pushed yesterday, 2026-02-18). This is a particularly exciting module because gh-aw is, at its core, an MCP server — so this SDK is central to everything.Module Overview
The official Go SDK for Model Context Protocol provides both server and client implementations for building MCP-compliant services. It exposes tools, resources, and roots over stdio or HTTP (SSE/streamable) transports. Maintained in collaboration with Google, it's actively developed with frequent releases.
Current version:
v1.3.0| Latest:v1.3.1(released yesterday!)Current Usage in gh-aw
mcp.NewServer()+mcp.AddTool()— 8 tools registered (status, compile, logs, audit, mcp-inspect, add, update, fix)mcp.StdioTransport{}+mcp.NewStreamableHTTPHandler()— dual transport supportmcp.NewClient()+mcp.CommandTransport+mcp.StreamableClientTransport— inspector clientjsonrpc.Error{Code, Message, Data}— structured error responsesmcp.Tool.Icons(SEP-973),mcp.ServerOptions.Capabilities(v1.2.0), elicitation defaults (SEP-1024)The project makes excellent use of the typed
mcp.AddTool[T]()generic API pattern, which automatically derives JSON schemas from Go struct types. The code is well-integrated with proper timeouts, logger wiring, and transport selection logic.Research Findings
v1.3.1 — Security Patch (released 2026-02-18)
This is a patch release for v1.3.0 containing a cherry-pick security fix for issue #805.
The issue: Go's standard library JSON decoder allows case-insensitive matches to struct field names (or
jsontags). This was exploited as a security concern in MCP message parsing.The fix: Switched the JSON decoder to
github.com/segmentio/encodingwhich provides case-sensitive matching.Impact on gh-aw: The project is running
v1.3.0which lacks this fix. Since gh-aw is an MCP server that receives JSON-RPC messages from external MCP clients, upgrading tov1.3.1is recommended for security hardening.v1.3.0 — Schema Caching & Enhanced Logging
// Note: Schema caching is automatic in go-sdk v1.3.0+.DisableListeningoption forStreamableClientTransport— useful for query-only clientsLoggerinClientOptions— replaces deprecated logger field (already used in project)GetError/SetErrormethods exported forjsonrpc.Errorv1.2.0 — 2025-11-25 Spec Support
Already leveraged by gh-aw:
mcp.Icon{Source: "emoji"}on all tools ✅AddSchemaDefault()on compile/logs tools ✅Capabilitiesfield onServerOptions: Used increateMCPServer()✅jsonrpc.Errorsentinels:CodeInvalidRequest,CodeInternalError,CodeInvalidParams✅UserIDinTokenInfo: Not currently used (gh-aw uses env-based actor)Improvement Opportunities
🚨 Critical — Security Patch
Upgrade to v1.3.1 immediately. This is a security fix for case-insensitive JSON unmarshaling. As an MCP server receiving external JSON-RPC messages, gh-aw should be on the patched version.
🏃 Quick Wins
1. Refactor duplicate root extraction code
connectStdioMCPServer()andconnectHTTPMCPServer()inmcp_inspect_mcp.gocontain identical root URI extraction logic (~20 lines each). This is a straightforward refactor:2. Add
LoggertoStreamableClientTransportin inspectorconnectHTTPMCPServer()setsLoggeronClientOptionsbut not onStreamableClientTransport. The transport itself can log connection-level events:3. Use
DisableListening: truein inspectorThe inspector client only queries capabilities — it never needs to receive server-initiated messages. Setting
DisableListening: trueonStreamableClientTransportfor the HTTP inspector reduces resource usage:✨ Feature Opportunities
4. Add
OutputSchemato MCP server toolsv1.2.0+ supports structured
OutputSchemaon tools. The inspect display code indisplayDetailedToolInfo()already handlesOutputSchema, but no tools inmcp_server.godefine output schemas. Adding output schemas forstatus,compile,logs, andauditwould:Example for the
statustool:5. Direct
ListRootsinstead of resource heuristicThe current root extraction uses a heuristic (parsing
://from resource URIs). The MCP spec supports direct roots querying. Consider usingsession.ListRoots()if available in the SDK for more accurate root discovery.📐 Best Practice Alignment
6. Add
ToolAnnotationsto server toolsThe
displayDetailedToolInfo()function already renders tool annotations (ReadOnlyHint,IdempotentHint,DestructiveHint,OpenWorldHint), but the MCP server tools don't defineAnnotations. Adding them improves LLM understanding:Suggested annotations:
7. Elicitation defaults for
mcp-inspectThe
mcp-inspecttool has no elicitation defaults. Consider ifcheck-secrets: truecould be an elicitation default to surface this option to LLM clients.Recommendations (Prioritized)
go get github.com/modelcontextprotocol/go-sdk@v1.3.1mcp_inspect_mcp.goOutputSchemato tools — Start withstatusandcompileas they have well-defined JSON structuresToolAnnotations— Improve LLM understanding of tool behaviorDisableListeningon inspector HTTP transport — Reduce resource usageOverall Assessment
The go-sdk integration in gh-aw is well-implemented and up-to-date with the v1.2.0/v1.3.0 feature set. The team has already adopted icons (SEP-973), elicitation defaults (SEP-1024), the Capabilities API, and typed tool handlers. The main action item is the v1.3.1 security patch, followed by nice-to-have improvements around output schemas and tool annotations.
Next Steps:
go get github.com/modelcontextprotocol/go-sdk@v1.3.1 && go mod tidyOutputSchematostatustool (best structured output)ToolAnnotationsto all 8 server toolsextractRootsFromResources()helperGenerated by Go Fan 🐹
Module summary saved to:
scratchpad/mods/modelcontextprotocol-go-sdk.mdReferences: §22172332637
Beta Was this translation helpful? Give feedback.
All reactions