Skip to content

stateful session enhancement: to support the MCP protocol session management #38983

Closed

Description

@wbpcode

Title: stateful session enhancement: to support the MCP protocol session management

Description:

See https://github.com/modelcontextprotocol/specification/blob/main/docs/specification/2025-03-26/basic/transports.md#session-management

MCP protocol is become more and more popular for AI agent developing. The session affinity is very important part for proxying MCP traffic becase it's stateful protocol.

But fortunately, Envoy have provided the stateful sesssion filter which could provide a stateful session support based on the header or cookie. This would be great if we can support the MCP session affinity support.

[optional Relevant Links:]

Any extra documentation required to understand the issue.

Activity

  1. added
    enhancement
    triage
    and removed
    triage
    on Apr 1, 2025
  2. wbpcode commented on Apr 1, 2025

    @wbpcode
    MemberAuthor
  3. cpakulski commented on Apr 1, 2025

    @cpakulski
    Contributor

    Statefulness support for MCP would be super helpful. Thanks for raising this issue.

  4. botengyao commented on Apr 2, 2025

    @botengyao
    Member

    It seems this is a config stuff, and we can use something like

                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.filters.http.stateful_session.v3.StatefulSession
                  session_state:
                    name: envoy.http.stateful_session.header
                    typed_config:
                      "@type": type.googleapis.com/envoy.extensions.http.stateful_session.header.v3.HeaderBasedSessionState
                      name: Mcp-Session-Id
    

    ?

  5. botengyao commented on Apr 2, 2025

    @botengyao
    Member

    Aha, the difference here is POST InitializeRequest which there is no id, and then we will know the Mcp-Session-Id from the response from the server.

  6. wbpcode commented on Apr 2, 2025

    @wbpcode
    MemberAuthor

    Yeah. I think we need some minor enhancement to encode our selected host to the original session ID from the server. And then, when the client send the request with the ID, we can extract the addresses and rewrite the header to the original session ID.

  7. github-actions commented on May 2, 2025

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

  8. added
    stale
    on May 2, 2025
  9. added
    no stalebot
    and removed
    stale
    on May 6, 2025
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/sessionsenhancementno stalebot

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions