Skip to content

[test] Add tests for mcp.callSDKMethodWithReconnect and reconnectSDKTransport#6956

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
add-tests-mcp-reconnect-sdk-134ccef5ae6c60ee
Draft

[test] Add tests for mcp.callSDKMethodWithReconnect and reconnectSDKTransport#6956
github-actions[bot] wants to merge 1 commit into
mainfrom
add-tests-mcp-reconnect-sdk-134ccef5ae6c60ee

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Jun 3, 2026

Test Coverage Improvement: mcp reconnect SDK functions

Function Analyzed

  • Package: internal/mcp
  • Functions: reconnectSDKTransport, callSDKMethodWithReconnect, listResources, listPrompts, readResource, getPrompt, ServerInfo
  • Previous Coverage: reconnectSDKTransport 0%, callSDKMethodWithReconnect 33.3%, package overall 84.5%
  • New Coverage: reconnectSDKTransport 100%, callSDKMethodWithReconnect 100%, package overall 92.2%
  • Complexity: High

Why These Functions?

reconnectSDKTransport and callSDKMethodWithReconnect implement the session reconnect state machine — the most complex, branchy logic in internal/mcp — yet had 0% and 33.3% coverage respectively. listResources, listPrompts, and related methods had only their error path covered (28.6%), missing the happy path through a real SDK session entirely.

Tests Added

  • reconnectSDKTransport — unsupported transport type (default branch)
  • reconnectSDKTransport — Streamable connect failure (bad URL)
  • reconnectSDKTransport — SSE connect failure
  • reconnectSDKTransport — existing session closed before reconnect
  • callSDKMethodWithReconnect — happy path (no error)
  • callSDKMethodWithReconnect — non-session-not-found error (no reconnect triggered)
  • callSDKMethodWithReconnect — session-not-found + reconnect fails
  • callSDKMethodWithReconnect — session-not-found + reconnect succeeds + retry succeeds
  • listResources — with real streamable session, empty result
  • listPrompts — with real streamable session, empty result
  • readResource — with real streamable session (error from server expected)
  • getPrompt — with real streamable session (error from server expected)
  • ServerInfo — with and without session
  • NewHTTPConnection — server info population from initialize response

Coverage Report

Before: reconnectSDKTransport 0.0%, callSDKMethodWithReconnect 33.3%, package 84.5%
After:  reconnectSDKTransport 100%, callSDKMethodWithReconnect 100%, package 92.2%
Improvement: +7.7% overall package

Test Execution

All 18 tests pass:

--- PASS: TestReconnectSDKTransport_UnsupportedType (0.00s)
--- PASS: TestReconnectSDKTransport_EmptyType (0.00s)
--- PASS: TestReconnectSDKTransport_StreamableConnectFailure (0.00s)
--- PASS: TestReconnectSDKTransport_SSEConnectFailure (0.00s)
--- PASS: TestReconnectSDKTransport_ExistingSessionClosed (0.00s)
--- PASS: TestCallSDKMethodWithReconnect_NoError (0.00s)
--- PASS: TestCallSDKMethodWithReconnect_NonSessionError (0.00s)
--- PASS: TestCallSDKMethodWithReconnect_SessionNotFoundReconnectFails (0.00s)
--- PASS: TestCallSDKMethodWithReconnect_SessionNotFoundReconnectSucceeds (0.00s)
--- PASS: TestListResources_WithSession (0.00s)
--- PASS: TestListResources_Empty (0.00s)
--- PASS: TestListPrompts_WithSession (0.00s)
--- PASS: TestListPrompts_Empty (0.00s)
--- PASS: TestReadResource_WithSession (0.00s)
--- PASS: TestGetPrompt_WithSession (0.00s)
--- PASS: TestServerInfo_WithSession (0.00s)
--- PASS: TestServerInfo_WithoutSession (0.00s)
--- PASS: TestNewHTTPConnection_ServerInfoPopulated (0.00s)
PASS

Generated by Test Coverage Improver
Next run will target the next most complex under-tested function

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • 172.30.0.50
  • go.opentelemetry.io
  • go.yaml.in
  • golang.org
  • google.golang.org
  • gopkg.in
  • proxy.golang.org
  • releaseassets.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "172.30.0.50"
    - "go.opentelemetry.io"
    - "go.yaml.in"
    - "golang.org"
    - "google.golang.org"
    - "gopkg.in"
    - "proxy.golang.org"
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · sonnet46 15M ·

Adds 18 comprehensive tests covering:
- reconnectSDKTransport: unsupported transport, connection failures, session cleanup
- callSDKMethodWithReconnect: happy path, non-session errors, session-not-found reconnect logic
- listResources, listPrompts, readResource, getPrompt with real sessions
- ServerInfo with and without session
- NewHTTPConnection server info population

Coverage improvements in internal/mcp:
- reconnectSDKTransport: 0% → 100%
- callSDKMethodWithReconnect: 33.3% → 100%
- listResources: 28.6% → 85.7%
- listPrompts: 28.6% → 85.7%
- readResource: 50% → 100%
- getPrompt: 50% → 100%
- ServerInfo: 0% → 85.7%
- Package overall: 84.5% → 92.2%

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants