Skip to content

Conversation

@luxp
Copy link

@luxp luxp commented Apr 16, 2025

StreamableHTTPServerTransport should support multiple initialization

For stateless mode, mcp server should be able to handle multiple client request. Such as below usage

const server = new McpServer(
    {
      name: "mcp-typescript server on vercel",
      version: "0.1.0",
    },
    serverOptions
 );
 const statelessTransport = new StreamableHTTPServerTransport({
    sessionIdGenerator: ()=> undifined,
 });
server.connect(statelessTransport);
app.post('/mcp', (req, res) => {
  // only one  statelessTransport handle multi request
  // this is important for serverless mode
  statelessTransport.handleRequest(req, res, req.body);
});

Motivation and Context

How Has This Been Tested?

Unit test and local test

Breaking Changes

no

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@luxp
Copy link
Author

luxp commented Apr 16, 2025

can solve #340

@ihrpr
Copy link
Contributor

ihrpr commented Apr 19, 2025

thank you @luxp, sorry, just saw this PR, it was fixed in #363

@ihrpr ihrpr closed this Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants