If you want to host an MCP Server in the cloud (e.g., on Vercel or AWS) so multiple clients can connect, use the transport patterns documented in the MCP docs and spec. A common production pattern is Streamable HTTP with structured request/response handling.
This allows a single cloud-hosted MCP Server to serve thousands of Clients independently.
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
app.post("/mcp", async (req, res) => {
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
await server.connect(transport);
await transport.handleRequest(req, res);
});
// Legacy SSE transport (deprecated — use StreamableHTTPServerTransport for new servers):
// import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";