You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
github.com/modelcontextprotocol/go-sdk (v1.6.1) is the official Go SDK for MCP — the foundation of gh-aw-mcpg. Every MCP connection, session, tool dispatch, and transport negotiation runs through it.
Current Usage
41 Go files import the SDK (17 production + 24 test files) across internal/mcp/, internal/server/, internal/middleware/, internal/testutil/mcptest/
Imported uniformly as sdk "github.com/modelcontextprotocol/go-sdk/mcp"
Key APIs Used
API
Package
Purpose
sdk.Client / sdk.ClientSession
internal/mcp/
Backend MCP connections
sdk.Server / sdk.NewServer
internal/server/
Front-facing MCP server
sdk.StreamableClientTransport
internal/mcp/http_transport.go
HTTP 2025-03-26 spec transport
sdk.SSEClientTransport
internal/mcp/http_transport.go
SSE 2024-11-05 spec transport
sdk.CommandTransport
internal/mcp/connection.go
Stdio for Docker container backends
sdk.NewStreamableHTTPHandler
internal/server/middleware.go
Stateful session management
sdk.NewInMemoryTransports
tests
Zero-dep paired transports for testing
sdk.ErrSessionMissing
internal/mcp/http_transport.go
Session expiry sentinel (v1.5.0+)
sdk.ToolAnnotations
internal/server/unified.go
Tool metadata passthrough
Usage Patterns
Transport fallback chain: streamable HTTP → SSE → plain JSON-RPC
1. ToolAnnotations dropped in routed mode — createFilteredServer constructs &sdk.Tool{} without Annotations: toolInfo.Annotations. Clients on /mcp/{serverID} lose annotation hints (readOnly, destructive) visible on the unified endpoint. Fix: add Annotations: toolInfo.Annotations in routed.go:122.
2. Comment clarity in http_transport.go:117 — the comment says sdk.ErrSessionMissing is "matched by backend error text instead" but doesn't explain why (plain JSON-RPC uses a custom HTTP client that doesn't surface SDK errors). A clearer comment would help future maintainers.
✨ Feature Opportunities
1. Progress notification forwarding — go-sdk supports notifications/progress. Backends can emit progress during long tool calls; the gateway doesn't forward these to clients today.
2. Typed system tool args — sys___init and sys___list_servers have fixed schemas. They could use sdk.AddTool[SysInitArgs, ...] (generics path) for compile-time argument safety, removing the manual json.Unmarshal.
3. Centralize sdk.Implementation — newSDKServer and newMCPClient both construct sdk.Implementation{Name: ..., Version: version.Get()} independently. A shared helper would be a single source of truth.
📐 Best Practice Alignment
✅ sdk.NewInMemoryTransports() for unit tests — already used
✅ DisableStandaloneSSE: true for request-response mode — correctly set
✅ StreamableHTTPOptions.SessionTimeout aligned with gateway session config
⚠️ Upgrade gate canaries exist but aren't documented in AGENTS.md — add an ## SDK Upgrade Process section
Module Overview
github.com/modelcontextprotocol/go-sdk(v1.6.1) is the official Go SDK for MCP — the foundation ofgh-aw-mcpg. Every MCP connection, session, tool dispatch, and transport negotiation runs through it.Current Usage
internal/mcp/,internal/server/,internal/middleware/,internal/testutil/mcptest/sdk "github.com/modelcontextprotocol/go-sdk/mcp"Key APIs Used
sdk.Client/sdk.ClientSessioninternal/mcp/sdk.Server/sdk.NewServerinternal/server/sdk.StreamableClientTransportinternal/mcp/http_transport.gosdk.SSEClientTransportinternal/mcp/http_transport.gosdk.CommandTransportinternal/mcp/connection.gosdk.NewStreamableHTTPHandlerinternal/server/middleware.gosdk.NewInMemoryTransportssdk.ErrSessionMissinginternal/mcp/http_transport.gosdk.ToolAnnotationsinternal/server/unified.goUsage Patterns
streamableMaxRetries = -1disables SDK retries; gateway owns reconnectsServer.AddTool(method, not package-level func) skips argument validation, allowing draft-07 schemas from backends*slog.LoggerTestMaxRetriesSentinelCanary+TestArgumentValidationBypassCanaryguard SDK upgradesImprovement Opportunities
🏃 Quick Wins
1.
ToolAnnotationsdropped in routed mode —createFilteredServerconstructs&sdk.Tool{}withoutAnnotations: toolInfo.Annotations. Clients on/mcp/{serverID}lose annotation hints (readOnly,destructive) visible on the unified endpoint. Fix: addAnnotations: toolInfo.Annotationsinrouted.go:122.2. Comment clarity in
http_transport.go:117— the comment sayssdk.ErrSessionMissingis "matched by backend error text instead" but doesn't explain why (plain JSON-RPC uses a custom HTTP client that doesn't surface SDK errors). A clearer comment would help future maintainers.✨ Feature Opportunities
1. Progress notification forwarding —
go-sdksupportsnotifications/progress. Backends can emit progress during long tool calls; the gateway doesn't forward these to clients today.2. Typed system tool args —
sys___initandsys___list_servershave fixed schemas. They could usesdk.AddTool[SysInitArgs, ...](generics path) for compile-time argument safety, removing the manualjson.Unmarshal.3. Centralize
sdk.Implementation—newSDKServerandnewMCPClientboth constructsdk.Implementation{Name: ..., Version: version.Get()}independently. A shared helper would be a single source of truth.📐 Best Practice Alignment
sdk.NewInMemoryTransports()for unit tests — already usedDisableStandaloneSSE: truefor request-response mode — correctly setStreamableHTTPOptions.SessionTimeoutaligned with gateway session configAGENTS.md— add an## SDK Upgrade ProcesssectionModule Summary
github.com/modelcontextprotocol/go-sdkv1.6.1Recommendations (Priority Order)
ToolAnnotationsincreateFilteredServer— addAnnotations: toolInfo.Annotationsto the&sdk.Tool{}inrouted.go:122## SDK Upgrade ProcesstoAGENTS.mdreferencing the two canary testssdk.Implementationconstruction — singlenewSDKImplementation()helperNext Steps
ToolAnnotationsdrop in routed mode (internal/server/routed.go:122)AGENTS.mdsdk.ImplementationconstructionGenerated by Go Fan 🐹 — §28647220857
References:
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpgSee Network Configuration for more information.