Skip to content

Fix test GitHub mcp session#1630

Merged
lpcox merged 7 commits intomainfrom
fix/test-github-mcp-mcp-session-id
Mar 6, 2026
Merged

Fix test GitHub mcp session#1630
lpcox merged 7 commits intomainfrom
fix/test-github-mcp-mcp-session-id

Conversation

@lpcox
Copy link
Collaborator

@lpcox lpcox commented Mar 6, 2026

  • Analyze new comment about readiness loop timing in start_gateway_with_pipe.sh
  • Fix wait_for_gateway to use elapsed timestamp-based timing (date +%s) instead of iteration counting
  • Run make agent-finished to verify - all checks pass

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

lpcox and others added 2 commits March 6, 2026 05:35
…itHubMCPRealBackend

go-sdk v1.4.0 changed session handling so that requests without an
Mcp-Session-Id header create new stateful (not stateless) sessions.
These uninitialized sessions reject tools/list with an error because
the SDK requires initialize to complete before accepting other methods.

Fix by capturing Mcp-Session-Id from the initialize response and
sending it on all subsequent requests (notifications/initialized,
tools/list, tools/call) to reuse the already-initialized SDK session.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ackends

Integration tests were failing because:
- echo Docker image doesn't exist, causing docker pull attempts to hang
- Gateway blocks HTTP server startup until all backends connect (even in routed mode)
- TestPlaywrightWithLocalDockerfile had port conflict (13101 shared with TestPipeBasedLaunch)
- TestSafeinputsHTTPBackend used time.Sleep(2s) which was insufficient

Fixes:
- TestOutputConfigWithAuthHeaders: replace echo container with createMinimalMockMCPBackend
- TestOutputConfigUnifiedMode: replace echo containers with createMinimalMockMCPBackend
- TestBinaryInvocation_ConfigStdin: replace echo container with createMinimalMockMCPBackend
- TestSafeinputsHTTPBackend: add --listen flag, replace sleep with waitForServer
- TestPlaywrightWithLocalDockerfile: change port 13101→13109, add --unified mode so
  health check only passes after Docker backend connects (eliminates timing race),
  update sendMCPRequest URLs from /mcp/mock-playwright to /mcp (unified endpoint)
- TestBinaryInvocation_PipeInputOutput: use mock HTTP backend instead of echo container
- TestPipeBasedLaunch: use MOCK_BACKEND_URL env var to pass mock HTTP backend URL to shell script
- start_gateway_with_pipe.sh: use HTTP backend when MOCK_BACKEND_URL is set, add
  --max-time 2 to curl health checks to prevent indefinite hangs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 6, 2026 17:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates integration tests and helpers to make MCP Gateway startup and session handling more reliable (notably around StreamableHTTP session reuse) and to reduce Docker dependency during automated runs.

Changes:

  • Add/propagate Mcp-Session-Id in the real GitHub MCP integration test to reuse stateful sessions across requests.
  • Introduce an in-process mock MCP HTTP backend and switch several integration tests/scripts from Docker-backed stdio servers to HTTP backends.
  • Reduce startup flakiness by adding explicit --listen in a test and replacing fixed sleeps with readiness checks; adjust Playwright integration test to use unified endpoint.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/integration/start_gateway_with_pipe.sh Supports MOCK_BACKEND_URL to use HTTP backend; adds curl timeout in readiness loop
test/integration/safeinputs_http_test.go Adds explicit --listen and waits for /health instead of sleeping
test/integration/playwright_test.go Switches to unified mode and /mcp endpoint; adjusts test port
test/integration/pipe_launch_test.go Starts shared in-process mock backend and passes it to the shell script via env
test/integration/github_test.go Captures and reuses Mcp-Session-Id; adds extra logging
test/integration/binary_test.go Adds in-process mock backend helper and uses it to avoid Docker in multiple tests
test/integration/auth_config_test.go Uses in-process mock backends instead of Docker containers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 168 to 172
cmd := exec.CommandContext(ctx, binaryPath,
"--config-stdin",
"--listen", "127.0.0.1:3001",
"--routed",
)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test hard-codes port 3001 for the gateway listen address, but doesn’t free it (e.g., via killProcessOnPort) or pick an ephemeral port. This can make the test flaky if 3001 is already in use on a dev machine/CI runner. Consider selecting a free port at runtime (net.Listen("127.0.0.1:0") → close → reuse) or calling killProcessOnPort(t, "3001") before starting the gateway, and use that same port consistently in both configJSON and --listen.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
lpcox and others added 4 commits March 6, 2026 10:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 6, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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
    • Triggering command: /tmp/go-build4187564995/b301/launcher.test /tmp/go-build4187564995/b301/launcher.test -test.testlogfile=/tmp/go-build4187564995/b301/testlog.txt -test.paniconexit0 -test.timeout=10m0s conf�� go /lto-wrapper x_amd64/compile pull.rebase 64/src/runtime/c-unsafeptr=false (dns block)
  • invalid-host-that-does-not-exist-12345.com
    • Triggering command: /tmp/go-build4187564995/b283/config.test /tmp/go-build4187564995/b283/config.test -test.testlogfile=/tmp/go-build4187564995/b283/testlog.txt -test.paniconexit0 -test.timeout=10m0s ortc�� .s 64/src/io/io.go x_amd64/compile pull.rebase (dns block)
  • nonexistent.local
    • Triggering command: /tmp/go-build4187564995/b301/launcher.test /tmp/go-build4187564995/b301/launcher.test -test.testlogfile=/tmp/go-build4187564995/b301/testlog.txt -test.paniconexit0 -test.timeout=10m0s conf�� go /lto-wrapper x_amd64/compile pull.rebase 64/src/runtime/c-unsafeptr=false (dns block)
  • slow.example.com
    • Triggering command: /tmp/go-build4187564995/b301/launcher.test /tmp/go-build4187564995/b301/launcher.test -test.testlogfile=/tmp/go-build4187564995/b301/testlog.txt -test.paniconexit0 -test.timeout=10m0s conf�� go /lto-wrapper x_amd64/compile pull.rebase 64/src/runtime/c-unsafeptr=false (dns block)
  • this-host-does-not-exist-12345.com
    • Triggering command: /tmp/go-build4187564995/b310/mcp.test /tmp/go-build4187564995/b310/mcp.test -test.testlogfile=/tmp/go-build4187564995/b310/testlog.txt -test.paniconexit0 -test.timeout=10m0s go_.�� 4441838/b123/_pkg_.a ternal/fips140cache/cache.go x_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of lpcox March 6, 2026 18:06
@lpcox lpcox merged commit 7fa11e8 into main Mar 6, 2026
11 checks passed
@lpcox lpcox deleted the fix/test-github-mcp-mcp-session-id branch March 6, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants