Multi-Tenant Client Support (Server-to-Server) #193
Replies: 8 comments 16 replies
-
|
In my humble opinion, this is one of the biggest limitations of the MCP. I would need to be able to provide additional data to tools called that is not decided by the LLM, such as the identity of the user (email, account id, ...). Note that user authentication has already happened at this point, but tools might use this identity to perform some authorization. |
Beta Was this translation helpful? Give feedback.
-
|
It's indeed the case that stdio MCP servers are geared toward single tenancy (as there is a host application involved in launching them, and we generally assume that there is a single "local user"). I'm not following the way in which remote MCP servers, available over HTTP, cannot be multi-tenant though. We have multiple working examples of MCP servers hosted on HTTP being able to serve multiple clients and users simultaneously. Is this perhaps an issue with the documentation or the SDK? |
Beta Was this translation helpful? Give feedback.
-
i dont see the issue with this and it appears central to the proposal. the "overhead" (protocol wrapper logic / processing) of a stdio server seems minimal relative to the actual processing of the tools. do you think there would be substantive difference between orchestrating 1 container per user vs one container processing configs? |
Beta Was this translation helpful? Give feedback.
-
Hmmm — we've found it to be quite practical and efficient at Cloudflare. With Durable Objects as the underlying compute primitive for building MCP servers on Cloudflare, each MCP client session has its own isolated instance of an MCP Server. We obviously love Durable Objects, but there are other ways to solve this with a process or instance per server, and don't quite see how spec needs to change or get more complex here. Pretty simple and clear as-is to simply say "create unique instances of MCP servers" — clear cut rather than having client IDs bleed into the spec. Don't quite see why client metadata should need to bleed into client space like this? |
Beta Was this translation helpful? Give feedback.
-
|
Both means of transport, the soon-to-be-deprecated existing SSE transport and the soon-to-be-replacement streamable HTTP, reasonably support multi-tenancy. The issue described by the OP is an implementation problem, not a protocol problem. The expectation is that you should be able to run servers explicitly implemented as single-tenant STDIO servers as remote multi-tenant SSE/Streamable servers with minimal backend code changes. Right now, most servers are still relatively nascent because the protocol itself is. I suspect that in the future, as both the protocol and implementations mature, we can expect to see more server implementations capable of operating against most/all supported transports, but they are just not there yet. Also, the protocol is designed to support gateway/proxy processes, and intermediary servers at this layer can solve many authentication/authorization issues. Example SSE multi-tenancyUnique SSE endpoints + Auth bearer tokensEach tenant gets its unique SSE endpoint and bearer token for authorization. Connecting to this endpoint with the correct bearer token will grant you a session-unique POST endpoint. Global SSE endpoint + Identifying and auth via bearer tokenThis is the same as the previous technique but uses a single SSE endpoint and disambiguates/authenticates users via bearer tokens. In this method, the SSE endpoint would still return and point you to a session unique POST endpoint. Example Streamable HTTP multi-tenancyNot much to say here, session id's are natively supported by the protocol. See: https://github.com/modelcontextprotocol/specification/blob/3a57a033865162a09443d4f50992b6e5382d32e6/docs/specification/draft/basic/transports.md#session-management |
Beta Was this translation helpful? Give feedback.
-
|
@mbleigh, I'm curious for your thoughts on #234. It isn't multi-tenancy exactly, but I think it addresses the core problem of handling multiple users in 1 server. |
Beta Was this translation helpful? Give feedback.
-
|
Yeah, this multi-tenant client issue is a big one. Trying to run most current stdio servers for multiple users just doesn't scale for hosted agents. I built the Ithena Governance SDK ( My take on this proposal:
So, adding Happy to chat more about how governance interfaces could use context from these |
Beta Was this translation helpful? Give feedback.
-
|
I would like to add that certain MCP remote hosting platforms, in particular smithery, provide sdk that allows mcp server developers to create mcp server (that actuall talks to the backend API) only upon session creation, that is, POST /mcp. (I am not affiliated to smithery at all, I've just been starting to look into how smithery deploys our mcp servers) It looks like currently there are only two such mcp servers written using smithery sdk (github and slack) from their mcp-servers github repos https://github.com/smithery-ai/mcp-servers. Roughly how it works is -
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Your Idea
MCP is currently designed to favor single-tenant clients. That is, it works well if you have a dedicated device or VM for the client that can install and start up servers on demand. Servers are generally built with the assumption that a single client will be communicating with them.
This becomes a problem when we want to make MCP servers available to server-side agents that serve many users. An MCP server configuration (e.g. via command-line startup args) is a singleton, but it is both inefficient and impractical for server-side agents to spin up new MCP server processes for each user.
What is needed is the ability for MCP to provide server configuration such that each request can "reconfigure" the server for its needs.
Note: While this issue is related to the overall "statefulness" of MCP, it is not strictly an issue of statefulness/statelessness. Servers could remain stateful while supporting multi-tenant clients.
The Problem
Let's imagine an MCP server with specialized tools for managing GitHub issues. The tools are designed to always operate in the context of a single repository, e.g.
searchIssues(query: string)only searches issues in the configured repository. When I start it up I do something like:Fundamentally, this server acts as a simple proxy to the GitHub API by providing a tool. All it needs to properly function is an access token and a repo name. I'd argue that the majority of MCP servers in the wild today operate this way today -- most of their logic is stateless, the only "state" comes from the configuration at startup time.
If I'm building a desktop app that orchestrates MCP servers client-side, this is an acceptable state of affairs. But as soon as I'm building a server-side agent that serves many clients, this becomes an impossible bottleneck. I need to be able to spin up and execute potentially thousands of concurrent instances of the same MCP server, one per user, just to perform a simple API proxy operation with two input variables.
There needs to be a way to operate a single instance of an MCP server that can serve many clients. This is not simply a transport issue because even with HTTP transport, MCP servers are currently built to serve individual clients.
Proposed Solution
The base
RequestandResponseinterfaces could be enhanced to support multi-tenant clients universally in a way that is compatible with the current "stateful" connection between client and server:This relatively simple change opens up multi-tenant clients in a backwards compatible manner. For a server implementor, they just need to take whatever configuration is passed at startup time and make it optionally provided through
clientConfiginstead.If my GitHub MCP server from above implemented
clientConfig, it would start up like so:npx my-github-mcp-server # no config argumentsAnd when queried about its capabilities, it might respond with:
Now when my multi-tenant client calls this MCP server, it can include user metadata:
My server implementation will look at the client config for a particular request and adapt its behavior accordingly.
Secrets and Stored Values
The largest potential issue with the above proposal is the potential for proliferating sending sensitive credentials over the wire between MCP multi-tenant client and MCP server. Safety would be significantly enhanced if secrets could be passed either once per client or never at all.
I won't get into specific solutions for this to keep the discussion focused on multi-tenant client support at the more basic level, but there are a few ways this could be done:
Each of these solutions is more involved than the simple metadata additions proposed above, but for proper multi-client support one of these (or a better idea) would likely need to be pursued.
Conclusion
For MCP to become the universal protocol for adding capabilities to agents, it must evolve to support a multi-tenant client approach. Solving this well would open up a wide world for server-to-server MCP, both multi-tenant clients and multi-tenant servers (an MCP server that can server multi-tenant clients could also reasonably server many single-tenant clients from a hosted URL).
Looking forward to some discussion on the matter!
Scope
Beta Was this translation helpful? Give feedback.
All reactions