Skip to content

Support Stateless MCP Server Connections #815

@BrandonShar

Description

@BrandonShar

With the streaming http protocol, MCP servers now have the option to be stateless and not care about long-running sessions. If we don't need long-running session support, that also allows us to skip the initial connection to the MCP server that occurs in agent.run_mcp_servers() which is a little performance boost and reduces start-up coupling with any MCP servers.

I'm handling this in a project right now by overriding the MCPServerHTTP's __aenter__ method and running everything except for the client initialize and set logging methods.

I'm happy to put up a PR for this, but I wanted to see if you'd have interest in the idea first. I think the simplest way to handle it would be an additional argument on the MCPServerHTTP class called something like stateless or maybe something more obvious like skip_initial_connection.

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