[go-fan] Go Module Review: modelcontextprotocol/go-sdk #30965
Replies: 2 comments 2 replies
-
|
/q create-issue instead of create-discussion , label with cookie |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
/plan 3 major quickwins in a single issue |
Beta Was this translation helpful? Give feedback.
1 reply
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 (v1.6.0)
Module Overview
github.com/modelcontextprotocol/go-sdkis the official Go SDK for the Model Context Protocol (MCP) — the open standard for connecting AI models to external tools and data sources. Ingh-aw, this is the most central dependency: the entire MCP server and client functionality is built on top of it.The SDK provides:
mcp.AddTool)jsonrpc.ErrorCurrent Usage in gh-aw
mcp,jsonrpc)mcp.NewServer,mcp.AddTool,mcp.Middleware,mcp.StdioTransport,mcp.StreamableHTTPHandler,mcp.NewClient,mcp.CommandTransport,jsonrpc.Errorgh-awimplements a 10-tool MCP server with:status,compile,mcp-inspect,checkslogs,audit,audit-diffadd,update,fixResearch Findings
The SDK is at v1.6.0, which is solid and production-ready. The codebase is already leveraging several advanced features: automatic schema caching (v1.3.0+, noted in a comment), the middleware system, typed tool handlers via generics, tool annotations (
ReadOnlyHint,IdempotentHint, etc.), and progress notifications for long-running tools.The usage is generally idiomatic and well-structured. A few targeted improvements could sharpen it further:
Improvement Opportunities
🏃 Quick Wins
Add icons to all tools — Only
statususesmcp.Icon{Source: "📊"}. IDE extensions and visual MCP clients display these; adding an emoji to each tool (📋compile,📝logs,🔍audit,🔧fix, etc.) improves UX with trivial effort.Document the
anysecond return in handlers — Every tool handler signature returns(*mcp.CallToolResult, any, error)where theanyis alwaysnil. A one-line comment explaining this is a reserved SDK extension point would save future contributors from wondering why it exists.Use
jsonrpc.CodeMethodNotFoundfor tools with no param registry — WhenmcpToolParams()has no entry for a tool name,argumentValidationMiddlewarereturnsCodeInvalidParams. For a completely unknown tool name,CodeMethodNotFoundis semantically more correct per JSON-RPC 2.0.✨ Feature Opportunities
Expose workflow files as MCP Resources — The SDK supports
mcp.Resourceandmcp.Rootobjects. The project imports and stores these types inMCPServerInfobut the server itself exposes no resources. Registering compiled.lock.ymlfiles (or theagentic-workflows/directory) as resources would let AI agents read workflow content without a tool call.Progress notifications for the
compiletool — Thelogsandaudittools already usereq.Session.NotifyProgress()for streaming updates. Long compiles with security scanners (--zizmor,--poutine,--actionlint) could benefit from the same pattern.Sending middleware for debug tracing —
server.AddSendingMiddleware()could log all outgoing tool results in debug mode, providing end-to-end tracing without modifying individual handlers.📐 Best Practice Alignment
Expand middleware to cover more schema error types — The current
argumentValidationMiddlewareonly intercepts"unexpected additional properties"errors. MCP SDK also surfaces type-mismatch and missing-required-field errors that are equally cryptic. Extending the middleware to rewrite all schema validation errors would give users consistent friendly messages.Replace LCP similarity with Levenshtein distance in
findSimilarParam— The current "Did you mean?" logic uses longest-common-prefix ratio. This works for prefix matches (workflowname→workflow-name) but misses transpositions and insertions (e.g.,worklfow→workflow). A normalized edit distance would improve suggestion quality.🔧 General Improvements
Fail-fast on tool registration errors —
createMCPServerreturns a partially-configured server when schema generation fails for a tool. This silent partial failure is difficult to diagnose. The function should either treat registration errors as fatal or expose a health check mechanism.Table-driven tool registration — The sequential
register*Tool()calls increateMCPServercould be expressed as a slice of registrar closures, making the function easier to scan and reducing boilerplate.Recommendations (Priority Order)
argumentValidationMiddlewareto handle type-mismatch and missing-required-field schema errors (biggest UX impact)mcp.Iconto all 10 tools for visual client consistencyfindSimilarParamto use edit distance for better typo detectioncompiletool for long-running security scans.lock.ymlfiles as MCP ResourcesNext Steps
argumentValidationMiddlewarefor all schema error typesModule summary saved to:
scratchpad/mods/modelcontextprotocol-go-sdk.mdRun: §25545119330
Beta Was this translation helpful? Give feedback.
All reactions