Join the waitlist

Cobaye / Blog

MCP tenant isolation: the second-customer-account test, step by step

Updated November 23, 2026. 7 min read.

In short. Tenant isolation means customer B can never read or change customer A's data through your MCP server (the endpoint that exposes your tools to an AI assistant). You prove it from outside: two real customer accounts, two fresh agents, and five probes sent from B toward A's records. If anything belonging to A appears in B's results, you have a leak. Every fix follows one rule: the server takes the tenant from the verified token, never from an argument.

Why would a multi-tenant MCP server leak?

Because nothing in the protocol does the isolation for you. The MCP specification makes access control the server's job, and its authorization rules require the server to validate each token and make sure no data goes to an unauthorized party. How you map a token to a customer is your code.

Three common shortcuts make that code fragile. Tools take record ids as arguments, and an agent can type any id. The specification says it about the handles a tool returns, and it holds for any id: "a handle is a name, not a capability", so it advises checking the caller's authorization on every call. Some servers use one shared key: Anthropic's authentication guide notes that a static header credential belongs to the organization and should not be used to tell which person is calling. And shared memory mixes customers: OWASP's MCP10:2025 item, on context over-sharing, describes a platform whose vector stores (the indexes behind semantic search) are not isolated between tenants, so one tenant's documents surface in another tenant's results.

How do you set up the test?

  1. Create two customers. Accounts A and B, in two separate organizations or workspaces, created through your public sign-up like real customers. Not two users of the same workspace.
  2. Plant canaries in A. Give A's records names nobody would guess, for example a client called CANARY-A-7391, a document and a note with the same tag. Write down three of A's record ids. Give B its own data too.
  3. Connect two fresh agents. One Claude account or browser profile per customer, each signed in to your server with its own account, memory off, no shared project. Nothing from A's session should travel to B's.
  4. Record the baseline. From A's agent, ask for the canary client. It must be found. If A can't see its own data, the test proves nothing.

Read the raw tool results, not only the agent's sentence: a model can summarize a leak away.

Which five probes do you send from B?

Type each request in B's agent, then open the tool call and read what your server returned.

1. The broad search

Ask B's agent to list all clients, then to search for CANARY-A. A leak looks like: the canary in the results, or a total that counts A's rows.

In my MCP server, every tool that lists or searches records must
filter by the tenant id taken from the validated access token.
Find each query that runs without that filter, add it, and add a
test proving that a second tenant gets zero rows from the first.

2. The direct id

Give B's agent one of A's record ids and ask it to open the record. A leak looks like: the record comes back. A softer version: the error differs from the one for an id that doesn't exist, which confirms the record is real.

Every tool that takes a record id must load the record together
with its owner and compare the owner with the tenant from the
token before doing anything. If they differ, return the same
"not found" error as for an id that does not exist.

3. The tenant argument

Look at your tool list for parameters such as org_id, workspace or user_id. Ask B's agent to run the tool with A's value. A leak looks like: the server accepts it.

Remove every tenant, organization, workspace or user id from the
input schemas of my MCP tools. Derive those values on the server
from the validated token only, and ignore any such value sent in
the arguments. Never decide access from the client name either.

That last line comes from Anthropic's testing guide: the client name a server receives is unauthenticated, so it must never feed an authorization decision.

4. The write

Ask B's agent to add a note to one of A's records, then to rename it. Go back to A's account and look. A leak looks like: A's record changed, even if B's agent reported an error.

Apply the same ownership check to every tool that creates,
updates or deletes: the target record and any parent record it
references must belong to the tenant from the token. Add a test
where tenant B tries to modify a record of tenant A and fails.

5. The shared memory

Ask the same question from A, then from B: a summary of the latest documents, or a semantic search on a word that only exists in A's canary document. A leak looks like: B receives A's cached answer or A's passages. The specification's schema states the principle for cached responses: a private one must not be shared across authorization contexts.

List every cache, search index, vector store and file bucket my
MCP server reads. Put the tenant id in each cache key and each
index filter or namespace. If the server authenticates all users
with one shared API key, replace it with a per-user OAuth sign-in
so each request carries the identity of the person calling.

How do you read the result?

The test passes when, across the five probes, B's tool results never contain a canary string, a count that includes A's rows or an error that reveals A's records, and A's data is unchanged at the end. A pass covers these probes on the tools you have today, not every path. Replay the five probes whenever you add a tool, change sign-in or add a cache, and keep the two accounts for that purpose. If you plan to list the server in a directory, run this before you hand a reviewer a test account: our guide to directory review criteria covers the rest.

Frequently asked questions

Isn't OAuth enough to isolate tenants?

No. OAuth tells your server who is calling. Deciding which rows that person may read or change is your server's logic, on every tool call. A server can have a flawless sign-in and still return another customer's record when given its id.

Can I run this test with one account and two chats?

No. Two chats on one account share the same tenant, so every probe passes without proving anything. You need two customers who should have nothing in common, each connected to its own agent.

What does OWASP say about cross-tenant leaks in MCP?

The OWASP MCP Top 10 lists the risk under MCP10:2025, Context Injection and Over-Sharing, with a multi-tenant scenario. Among its prevention measures: a separate context namespace per user, agent, workflow and tenant, and isolated retrieval indexes and vector stores in multi-tenant setups.

Does a passing test mean my server is secure?

It means these five probes found no leak between two customers. It says nothing about sign-in strength, injection or permissions inside a single organization. For the wider list of checks, see our QA guide for people who build with AI.

Keep reading

Want a pair of eyes that has never seen your product?

Cobaye tests your SaaS or your MCP server from the outside, with fresh accounts, and hands you the findings ranked by severity, each with the prompt that fixes it. The first 20 on the waitlist get 50% off their first test.

Join the waitlist