[go-fan] Go Module Review: modelcontextprotocol/go-sdk #27516
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Go Fan. A newer discussion is available at Discussion #27788. |
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
Selected because: Most recently pushed direct dependency (2026-04-20T15:09:49Z — yesterday!) · First run, no prior reviews
Module Overview
github.com/modelcontextprotocol/go-sdkis the official Go SDK for the Model Context Protocol, maintained in collaboration with Google. It provides both server and client APIs for building MCP-compatible tools, agents, and integrations. The SDK implements the full MCP spec including tools, resources, roots, sampling, and OAuth.v1.5.0✅ LATEST (released 2026-04-07, 2 weeks ago)Current Usage in gh-aw
gh-aw is a heavy, sophisticated user of this SDK — it's both a server (exposing
gh awcommands as MCP tools) and a client (inspecting external MCP servers).mcpandjsonrpcsub-packages used--portflag)CommandTransport(stdio) +StreamableClientTransport(HTTP)Key APIs Used:
mcp.NewServermcp_server.gomcp.AddTool(typed)mcp.StdioTransportmcp_server_command.gomcp.NewStreamableHTTPHandlermcp_server_http.gomcp.NewClientmcp_inspect_mcp.gomcp.CommandTransportmcp_inspect_mcp.gomcp.StreamableClientTransportmcp_inspect_mcp.gomcp.ToolAnnotationsmcp.Iconjsonrpc.Error+ codesmcp_error.go, toolsResearch Findings
Recent Updates (v1.4.0 → v1.5.0)
CreateMessageWithTools(sampling)NewStreamableHTTPHandlerMemoryEventStoreempty chunk fixhttp.ResponseControllerflushExtensionsfield in capabilitiesBest Practices from Maintainers
mcp.AddToolfor automatic schema generation ✅ (gh-aw does this)session.Close()afterclient.Connect✅ (gh-aw does this)DisableStandaloneSSE: truefor short-lived inspection clients ✅ (gh-aw does this)IsError: trueinCallToolResultfor errors-as-content ✅ (gh-aw does this for audit/audit-diff)Improvement Opportunities
🏃 Quick Wins
1. Paginate
ListTools/ListResourcesin the inspectorThe
connectStdioMCPServerandconnectHTTPMCPServerfunctions both call:The MCP protocol supports cursor-based pagination — if a server returns 100+ tools, only the first page is fetched. The fix: loop until
toolsResult.NextCursor == "":Same pattern for
ListResources.2. Document
SessionTimeoutin HTTP serverpkg/cli/mcp_server_http.gosetsSessionTimeout: 2 * time.Hourwith no comment explaining the rationale. A brief note (e.g., "accounts for long-running agent workflows") helps future maintainers.✨ Feature Opportunities
3. Expose workflow files as MCP Resources
The server currently registers no MCP resources. Workflow
.mdand compiled.lock.ymlfiles could be exposed as resources (e.g.,(redacted) allowing AI agents to read workflow content directly viaresources/readwithout needing a custom tool. This is especially useful for agents that want to understand the current workflow state before callingcompileorfix`.4. Use
session.ListRootsin inspector (with fallback)pkg/cli/mcp_inspect_mcp.gousesextractRootsFromResources— a heuristic that guesses root URIs by parsing resource URI schemes. If the inspected server supports therootscapability,session.ListRootswould return the actual roots. The current heuristic could serve as a fallback.5. Declare Output Schemas for JSON-returning tools
The
mcp.AddToolhandler signature returns(*mcp.CallToolResult, any, error)— the second value is a typed struct that declares the output schema. Currently all tools returnnil. Tools likestatus,checks, andauditalways emit a known JSON structure; declaring their output schema would:📐 Best Practice Alignment
6. Cross-origin protection is now automatic — document it
Since
v1.4.1,mcp.NewStreamableHTTPHandlerautomatically verifiesOriginandContent-Typeheaders to protect against CSRF attacks. Sincev1.4.0, DNS rebinding protection is automatic for localhost. gh-aw gets both for free — worth a comment inmcp_server_http.goso maintainers know not to add redundant middleware.7. SDK now handles input validation errors as tool results
In v1.5.0, JSON schema validation errors from
mcp.AddToolare returned asCallToolResultwithIsError: trueinstead of JSON-RPC errors. This improves LLM interaction (LLMs can read the error, fix their inputs, and retry). gh-aw's custom validators (e.g., conflictingfirewall/no_firewallflags) still correctly returnjsonrpc.Error— that's the right choice for logical errors, not schema errors.Recommendations
ListTools/ListResourcesin inspectorstatus,checks,audit)SessionTimeoutrationale in HTTP serverOverall Assessment
gh-aw is a sophisticated and idiomatic user of the MCP Go SDK. The project is on the latest version (v1.5.0), uses the typed
mcp.AddToolpattern, properly applies tool annotations, handles errors correctly, and already adopts performance optimizations likeDisableStandaloneSSE. The main gaps are the missing tool listing pagination (a real correctness issue for servers with many tools) and the untapped structured output feature.Module summary saved to:
scratchpad/mods/modelcontextprotocol-go-sdk.mdReferences: §24712025716
Note
🔒 Integrity filter blocked 1 item
The following item was blocked because it doesn't meet the GitHub integrity level.
get_commit: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter:Beta Was this translation helpful? Give feedback.
All reactions