Three production lessons for running a multi-tenant MCP server
No_Advertising2536 · reddit · 2026-07-20
The author shares three practical lessons from running a multi-tenant streamable-HTTP MCP server in production.
1) Session transport breaks with multiple workers
The SDK assumes follow-up requests will land on the same worker that handled initialize. With 2+ Gunicorn workers, that assumption fails and clients see intermittent errors. The fix is to make the transport stateless and create a fresh server per request.
2) Starlette route wrappers can break the ASGI cycle
Mounting a plain async function can cause TypeErrors because transport.handlerequest() manages the ASGI lifecycle itself. The solution is to mount a real ASGI callable class.
3) Multi-tenant auth needs per-request server creation
StreamableHTTPSessionManager uses a single server instance, which makes per-request bearer-token auth awkward. The author instead parses auth, constructs a tenant-bound server, and uses a fresh stateless transport.
They add that this has been stable for months, and disclose that the server is Mengram, a long-term memory product for agents with 29 MCP tools, a free tier, paid plans from $5/month, Apache 2.0/self-hostable, and an official MCP registry listing.
More from coding & agent
- A roundup of AI agents and MCP resources, including how to evaluate agents — _jaydeepkarale · 2026-07-21
- Anthropic shares a masterclass on how it builds AI agents — _jaydeepkarale · 2026-07-21
- Anthropic masterclass spotlights how to build and observe AI agents — _jaydeepkarale · 2026-07-21
- A beginner guide to AI agents points readers to a Stanford webinar — _jaydeepkarale · 2026-07-21
- A full course shows how to build and deploy an AI agent with OpenAI and LangChain — _jaydeepkarale · 2026-07-21
- A practical guide on how to evaluate AI agents — _jaydeepkarale · 2026-07-21