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 is the official Go SDK for the Model Context Protocol. It is the single most critical dependency in this repository β the entire gateway is built on top of it. It provides:
MCP server and client implementations
Streamable HTTP and SSE transport handlers
MCP type system (Tool, Content, Resource, Prompt, etc.)
In-memory transports for testing
Typed error sentinels (e.g., ErrSessionMissing since v1.5.0)
Current Usage in gh-aw-mcpg
Files: 29 files (15 production, 14 test)
Import Count: 29 imports (all aliased as sdk)
Key APIs Used:
sdk.NewServer / sdk.NewStreamableHTTPHandler / sdk.StreamableHTTPOptions β HTTP server layer
The project uses this SDK deeply and correctly. The integration covers all major SDK surface areas: server creation, client session lifecycle, transport variants, content types, and error handling.
Notable SDK Usage Pattern
The codebase contains a well-documented workaround (registerToolWithoutValidation) that uses server.AddTool() (the method) instead of the package-level sdk.AddTool[In, Out]() generic function. This deliberately bypasses argument validation to allow backends using JSON Schema draft-07 (which differs from the SDK's expected version) to work correctly. The code includes a comment requiring re-verification on each SDK upgrade β verified correct for v1.5.0.
Improvement Opportunities
π Quick Wins
ValidatorClient pagination gap (internal/testutil/mcptest/validator.go)
ListTools() and ListResources() call the SDK without handling NextCursor
Backends with many tools would silently return only the first page
Fix: Reuse the project's existing paginateAll / listMCPItems helpers, or add cursor loop inline
Missing logger in ValidatorClient (internal/testutil/mcptest/validator.go:22)
sdk.ClientOptions{} has no Logger set, while all production clients pass one
Low-effort: pass logger.NewSlogLoggerWithHandler(logger.New("testutil:validator")) for test visibility
filteredServerCache.getOrCreate holds write lock during creator() (internal/server/routed.go:67)
creator() builds a new sdk.Server and registers all tools for a backend
With many tools, this could block other concurrent session requests under the same lock
Fix: Use a double-checked locking pattern (read lock β check β write lock only if missing)
β¨ Feature Opportunities
Typed tools for sys tools (internal sys___init, sys___list_servers)
These tools have well-known input schemas defined in Go code
Using sdk.AddTool[In, Out]() with typed structs would eliminate manual ParseToolArguments calls and provide compile-time safety
The bypass is only needed for backend-proxy tools forwarding unknown schemas
Leverage InitializeResult().Capabilities for backend capability detection
After client.Connect(), session.InitializeResult() exposes what MCP capabilities (tools, resources, prompts) the backend actually supports
Currently the gateway always attempts all three list operations regardless of backend capabilities
Checking capabilities at connect time would skip unsupported operations per-backend, reducing startup error noise
π Best Practice Alignment
Automate the registerToolWithoutValidation assumption
There's a comment saying SDK behavior must be re-verified on every upgrade (tool_registry.go:52)
Consider a narrow unit test that asserts the method bypasses schema validation vs the function enforces it
This turns a manual process into a compile-time/test-time safety net
Audit the ErrSessionMissing string-match fallback
isSessionNotFoundError() (http_transport.go:78) uses both errors.Is(err, sdk.ErrSessionMissing)and a string-match fallback
Now that v1.5.0 is in use, document whether the fallback is still exercised (it likely is only for the HTTPTransportPlainJSON path which bypasses the SDK entirely)
π§ General Improvements
filteredServerCache true LRU at max capacity (internal/server/routed.go:91)
When the cache hits 1000 entries, it logs a warning but retains all entries
In a high-traffic deployment (1000+ simultaneous sessions), the cache can never evict at capacity
Evicting the least-recently-used entry would bound memory reliably without breaking active sessions
Recommendations
Priority order:
π΄ Fix ValidatorClient pagination β silent data loss risk in tests with tool-rich backends (quick fix)
https://github.com/ktr0731/go-mcpsearch_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".
πΉ Go Fan Report: modelcontextprotocol/go-sdk
Module Overview
github.com/modelcontextprotocol/go-sdkis the official Go SDK for the Model Context Protocol. It is the single most critical dependency in this repository β the entire gateway is built on top of it. It provides:ErrSessionMissingsince v1.5.0)Current Usage in gh-aw-mcpg
sdk)sdk.NewServer/sdk.NewStreamableHTTPHandler/sdk.StreamableHTTPOptionsβ HTTP server layersdk.NewClient/client.Connect/session.*β backend client connectionssdk.CommandTransport,sdk.StreamableClientTransport,sdk.SSEClientTransportβ transport variantssdk.NewInMemoryTransportsβ in-memory test transportssdk.Tool,sdk.CallToolRequest/Result,sdk.Contentsubtypes β MCP type systemsdk.ErrSessionMissingβ typed session error detectionResearch Findings
The project uses this SDK deeply and correctly. The integration covers all major SDK surface areas: server creation, client session lifecycle, transport variants, content types, and error handling.
Notable SDK Usage Pattern
The codebase contains a well-documented workaround (
registerToolWithoutValidation) that usesserver.AddTool()(the method) instead of the package-levelsdk.AddTool[In, Out]()generic function. This deliberately bypasses argument validation to allow backends using JSON Schema draft-07 (which differs from the SDK's expected version) to work correctly. The code includes a comment requiring re-verification on each SDK upgrade β verified correct for v1.5.0.Improvement Opportunities
π Quick Wins
ValidatorClientpagination gap (internal/testutil/mcptest/validator.go)ListTools()andListResources()call the SDK without handlingNextCursorpaginateAll/listMCPItemshelpers, or add cursor loop inlineMissing logger in
ValidatorClient(internal/testutil/mcptest/validator.go:22)sdk.ClientOptions{}has noLoggerset, while all production clients pass onelogger.NewSlogLoggerWithHandler(logger.New("testutil:validator"))for test visibilityfilteredServerCache.getOrCreateholds write lock duringcreator()(internal/server/routed.go:67)creator()builds a newsdk.Serverand registers all tools for a backend⨠Feature Opportunities
Typed tools for sys tools (internal
sys___init,sys___list_servers)sdk.AddTool[In, Out]()with typed structs would eliminate manualParseToolArgumentscalls and provide compile-time safetyLeverage
InitializeResult().Capabilitiesfor backend capability detectionclient.Connect(),session.InitializeResult()exposes what MCP capabilities (tools, resources, prompts) the backend actually supportsπ Best Practice Alignment
Automate the
registerToolWithoutValidationassumptionAudit the
ErrSessionMissingstring-match fallbackisSessionNotFoundError()(http_transport.go:78) uses botherrors.Is(err, sdk.ErrSessionMissing)and a string-match fallbackHTTPTransportPlainJSONpath which bypasses the SDK entirely)π§ General Improvements
filteredServerCachetrue LRU at max capacity (internal/server/routed.go:91)Recommendations
Priority order:
ValidatorClientpagination β silent data loss risk in tests with tool-rich backends (quick fix)registerToolWithoutValidationverification β prevents silent breakage on SDK upgradesfilteredServerCacheLRU improvement β prevents memory growth at scaleNext Steps
ValidatorClient.ListTools/ListResourcesto paginate fullyregisterToolWithoutValidationbypass behavior holds for the current SDK versionfilteredServerCacheLRU eviction strategysdk.AddTool[In, Out]for sys tools (sys___init, sys___list_servers)Generated by Go Fan πΉ
Module summary saved to: session files/go-sdk.md
Run ID: Β§24331592683
Note
π Integrity filter blocked 77 items
The following items were blocked because they don't meet the GitHub integrity level.
get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_tags: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".search_repositories: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".To allow these resources, lower
min-integrityin your GitHub frontmatter: