Skip to content

Add real-client integration tests for mcpcompat protocol-status handling #7034

Closed

Description

@jhrozek

Summary

Validate the mcpcompat protocol-status corrections with integration tests that use a real MCP client against a real server, not only unit tests.

Scenarios to cover

  • JSON-RPC errors are preserved (go-sdk v1.8 decodes JSON-RPC error bodies from non-2xx responses)
  • Method-not-found is distinguished from session termination
  • Auth challenges are retained (WWW-Authenticate and the numeric HTTP status, used for RFC 9728 discovery and error classification)
  • Subsequent requests on the same client still work after an error

Notes

  • Independent of any toolhive-core release; the runtime behavior is already in the pinned go-sdk v1.8.0 plus the shim's error-body capture (mcpcompat/client/errorbody.go).
  • Follow-up from the toolhive-core docs commit d8f6f06.

Activity

  1. added
    needs-triage
    on Nov 3, 2026
  2. removed
    needs-triage
    on Nov 3, 2026
  3. rdimitrov commented on Nov 20, 2026

    @rdimitrov
    Member

    Done in stacklok/toolhive-core#522 (merged as 9008cfd). The tests drive the real mcpcompat client over real HTTP against a real go-sdk Streamable HTTP server. A thin handler in front injects faults only for chosen requests.

    • JSON-RPC errors are preserved: TestProtocolStatus_JSONRPCErrorPreserved (code, message and data survive HTTP 400/403/422) and TestProtocolStatus_TransientStatusBodyStillReachesCaller (the shim re-attaches the 503 body, which go-sdk does not decode).
    • Method-not-found vs session termination: TestProtocolStatus_MethodNotFoundVersusTerminatedSession and TestProtocolStatus_Bare404WithJSONRPCBody. The latter pins 404 → ErrSessionTerminated for ToolHive's proxy format (echoed id), the TypeScript SDK (id: null) and the Python SDK (id: "server-error"), since vMCP's session recovery depends on it.
    • Auth challenges are retained: TestProtocolStatus_AuthChallengeOnInitialize, TestProtocolStatus_AuthChallengeMidSession and TestProtocolStatus_CleanupResponseDoesNotOverwriteChallenge (401 status, WWW-Authenticate and the RFC 9728 resource_metadata URL survive, including a cleanup DELETE answered with a different status).
    • The same client works after an error: TestProtocolStatus_RecoveryAfterRecoverableErrors (five error kinds on one client, each checked for its own classification, session ID unchanged), TestProtocolStatus_ConcurrentCallsOnOneClient and TestProtocolStatus_TimeoutAndCancellation.

    Known limits, both in go-sdk v1.8.0 rather than the shim:

    • go-sdk closes the connection on a 4xx without a JSON-RPC body (for example a bodiless 401), so recovery is only asserted where it keeps the session open.
    • go-sdk treats a server error with code -32003 or -32004 as its own "client/server closing" signal. It reports ErrConnectionClosed and drops the *jsonrpc.Error, although the connection stays usable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions