Skip to content

[go-fan] Go Module Review: modelcontextprotocol/go-sdkΒ #67932

Closed

Description

@github-actions

🐹 Go Fan Report: modelcontextprotocol/go-sdk

Deep dive on github.com/modelcontextprotocol/go-sdk v1.8.0 β€” the official Go SDK for MCP servers/clients, picked as today's module because it had the most recent pushed_at among gh-aw's direct dependencies.

Module Overview

The official Go implementation of the Model Context Protocol (JSON-RPC 2.0 wire protocol, tool/resource/prompt registration, stdio + streamable-HTTP transports, OAuth client-auth helpers), maintained by the modelcontextprotocol org with Google.

Current Usage in gh-aw

  • Files: 13 non-test .go files (pkg/cli/mcp_*.go, pkg/parser/mcp.go), ~20 test files.
  • Import count: 18 import lines of mcp/jsonrpc subpackages.
  • Key APIs used: mcp.NewServer/ServerOptions/ServerCapabilities, mcp.AddTool with typed-args generics for all 11 registered tools, mcp.ToolAnnotations (ReadOnly/Idempotent/OpenWorld hints), mcp.NewStreamableHTTPHandler + StreamableHTTPOptions, server.AddReceivingMiddleware (custom argument-validation middleware), req.Session.NotifyProgress for progress on long-running tools, jsonrpc.Error/Code* for structured errors, mcp.Icon, and jsonschema.For[T] (from the companion google/jsonschema-go module) wrapped in a local GenerateSchema[T]() helper.

Usage is idiomatic: a single long-lived *mcp.Server built once, small register<Name>Tool functions per tool, typed handlers returning (*mcp.CallToolResult, any, error), and explicit reliance on the SDK's automatic schema caching (called out in a code comment) instead of a hand-rolled cache.

Research Findings

Version status: go.mod pins v1.8.0, published 2026-09-14 β€” this is the latest stable release. No upgrade needed.

Recent Updates (v1.8.0, since v1.7.0)
  • ServerOptions.SupportedProtocolVersions β€” lets a server explicitly narrow (never widen) the protocol versions it advertises; panics at construction if given an unimplemented version.
  • ServerOptions.SetCacheable β€” post-handler hook to set ttlMs/cacheScope on server/discover, the four list methods, and resources/read results.
  • ServerSession.NotifyElicitationComplete β€” new elicitation-completion notification.
  • Hardening: bounded JSON nesting depth, SSE MaxEventSize caps, stdio MaxLineLength caps, OAuth DCR response size caps β€” resource-exhaustion fixes for any HTTP-exposed server.
  • A stateful streamable handler now returns a proper JSON-RPC -32022 CodeUnsupportedProtocolVersion error instead of a plain-text 400 on protocol mismatch β€” directly relevant to gh-aw's own stay-stateful design (see mcp_server_http.go).
  • Removed legacy MCPGODEBUG flags (seterroroverwrite, enableoriginverification, disablecontenttypecheck, disablelocalhostprotection) β€” gh-aw already uses the correct field replacement (DisableLocalhostProtection), so no action needed.

Best Practices: Typed-args mcp.AddTool generics, ToolAnnotations hints, and structured jsonrpc.Error responses are exactly what the SDK's own docs recommend β€” gh-aw already follows this.

Improvement Opportunities

πŸƒ Quick Wins

  • None required for correctness β€” current usage already matches SDK best practice.

✨ Feature Opportunities

  • ServerOptions.SupportedProtocolVersions: gh-aw currently documents its stateful-mode protocol-negotiation tradeoff only in a code comment in mcp_server_http.go. Setting this option explicitly would make the supported version range self-documenting in code and fail fast (panic at construction) if an unimplemented version is ever referenced by mistake.
  • ServerOptions.SetCacheable: gh-aw's tool list is static (ListChanged: false) β€” exactly the scenario this hook targets. Marking server/discover/tools/list as cacheable with a TTL could reduce repeated list round-trips from polling MCP clients (editor integrations, etc.).
  • ServerSession.NotifyElicitationComplete: not applicable today (no elicitation flow in use), but worth keeping in mind if an interactive tool (add/fix) is ever extended to ask clarifying questions via MCP elicitation instead of CLI prompts.

πŸ“ Best Practice Alignment

  • Progress notifications (notifyProgress/NotifyProgress) are wired up only for logs, audit, and audit-diff. compile (can watch/recompile many files) and work-queue (hits a Git-backed store) are also potentially long-running and could reuse the same helper for a consistent UX.

πŸ”§ General Improvements

  • No redundant or custom reimplementation of SDK functionality found β€” gh-aw consistently leans on the SDK's generics, annotations, and schema caching rather than hand-rolling equivalents.

Recommendations

  1. Consider adding ServerOptions.SupportedProtocolVersions to createMCPServer to make the protocol-version contract explicit in code (low effort, pkg/cli/mcp_server.go).
  2. Evaluate ServerOptions.SetCacheable for tools/list/server/discover given the static tool set (pkg/cli/mcp_server.go).
  3. Extend notifyProgress coverage to compile and work-queue tools for UX consistency with logs/audit/audit-diff (pkg/cli/mcp_tools_readonly.go, pkg/cli/mcp_tools_work_queue.go).

Next Steps

No urgent action required β€” the SDK is already at the latest stable version and usage is idiomatic. The three feature opportunities above are optional enhancements, not fixes.


Generated by Go Fan
Module summary saved to: scratchpad/mods/modelcontextprotocol-go-sdk.md

References:

Generated by 🐹 Go Fan Β· claude Β· agent Β· 167 AIC Β· ⊞ 6.5K Β· β—·

  • expires on Oct 13, 2026, 12:27 AM UTC-08:00

Activity

  1. github-actions commented on Oct 12, 2026

    @github-actions
    ContributorAuthor

    πŸͺ Issue Monster selected this for Copilot

    I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.

    If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.

    Om nom nom! πŸͺ

    πŸͺ Om nom nom by Issue Monster Β· pi Β· gpt54 Β· 11.7 AIC Β· βŒ– 7.1 AIC Β· ⊞ 10.4K Β· β—·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions