Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wbpcode opened this issue Apr 1, 2025 · 5 comments · May be fixed by #39004
Open

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

wbpcode opened this issue Apr 1, 2025 · 5 comments · May be fixed by #39004
Labels
area/sessions enhancement Feature requests. Not bugs or questions.

Comments

@wbpcode
Copy link
Member

wbpcode commented Apr 1, 2025

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.

@wbpcode wbpcode added enhancement Feature requests. Not bugs or questions. triage Issue requires triage area/sessions and removed triage Issue requires triage labels Apr 1, 2025
@wbpcode
Copy link
Member Author

wbpcode commented Apr 1, 2025

@wbpcode @cpakulski

@cpakulski
Copy link
Contributor

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

@botengyao
Copy link
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

?

@botengyao
Copy link
Member

botengyao commented Apr 2, 2025

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.

@wbpcode
Copy link
Member Author

wbpcode commented Apr 2, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sessions enhancement Feature requests. Not bugs or questions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants