Skip to content

Add a special MCP-Version header on http transport can improve the MCP protocol detection #884

@spacewander

Description

@spacewander

Is your feature request related to a problem? Please describe.

In some situations, we need to automatically detect the MCP request so that we can add corresponding features like observability and security to it. Especially, we also need to know which version of the protocol is used by the client.

Describe the solution you'd like

We can add an MCP-Version header when the client sends the HTTP request. For example, MCP-Version: 2025-06-18 means the client is using the 2025-06-18 version.

Describe alternatives you've considered

We can read the body and parse the initialize request for the protocolVersion field to get the MCP version. But it would be cumbersome because of:

  1. It requires reading the whole body to detect if the request is MCP or not
  2. If we miss the first request, we have no way to detect the version, though we can detect if it's MCP or not by the mcp-session-id header, which is set after initialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions