Skip to content

Route backend MCP ping responses through Envoy AI Gateway #2715

Description

@waw2637

Description:

When an MCP backend sends a ping request with a numeric JSON-RPC ID, Envoy AI Gateway forwards the request to the client without applying its backend-aware request-ID encoding. The client's response therefore returns the original numeric ID and is rejected with HTTP 400:

Playwright is an example that expects this behavior and is used to cleanup sessions

invalid response ID type: 1

mcpRequestContext.maybeServerToClientRequestModify recognizes other server-to-client request methods before applying the common ID rewrite, but ping currently falls through the default case and returns early.

Expected behavior:

  • A backend ping with numeric ID 1 is exposed to the client as a backend-qualified string ID such as 1__i__mcp-playwright.
  • The client response is routed only to the backend that originated the ping.
  • The backend receives its original numeric response ID 1.
  • Different backends can reuse the same original ping ID without collision.
  • ping is recorded as a recognized server-to-client method rather than unsupported.

This is protocol routing only. It does not enable, schedule, or otherwise change heartbeat behavior.

Protocol version scope:

Envoy AI Gateway v1.1.0 negotiates MCP protocol version 2025-06-18. In that version, the Ping specification states that either the client or server can initiate a ping request and requires the receiver to respond with the same request ID.1

MCP protocol version 2026-07-28 removes ping from the protocol.2 This issue is therefore limited to the legacy 2025-06-18 MCP path and does not propose adding ping handling to the modern 2026-07-28 path.

Repro steps:

  1. Check out v1.1.0 (c217da8a539570ba3f6014a60c2687c29a945f1f).
  2. Pass a JSON-RPC request with method ping and numeric ID 1 through maybeServerToClientRequestModify for backend mcp-playwright.
  3. Observe that the ID remains numeric 1 instead of becoming 1__i__mcp-playwright.
  4. Return a client response with numeric ID 1 and observe HTTP 400 from handleClientToServerResponse.

A focused regression test on the unpatched source reports:

expected: string("1__i__backend")
actual  : int64(1)

Environment:

  • Envoy AI Gateway v1.1.0
  • Linux amd64
  • Go 1.26.4 (selected by the repository toolchain directive)

Logs:

invalid response ID type: 1

Activity

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

    area/mcpMCP proxy, MCPRoute, and MCP spec conformancebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions