mcp-tenant-isolation

mcp-tenant-isolation is a cursor rule for Cursor from kaminari-ad/mcp. It costs 0 tokens per session (1,792 once invoked), scanned A, original, MIT.

A set of rules for keeping data from different customer organisations separate in a hosted HTTP service. It focuses on passing each request's authentication information only to that request's outgoing API calls.

In plain words
What is it for?
Use it when changing HTTP handling, sessions, or rate limiting in a multi-tenant MCP server. It guides code review and includes rules checked by continuous integration.
Why use it?
It helps prevent one organisation's credentials or data from being used in another organisation's request, especially when requests run at the same time.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when changing HTTP handling, sessions, or rate limiting in a multi-tenant MCP server. It guides code review and includes rules checked by continuous integration.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/kaminari-ad/mcp/mcp-tenant-isolation
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/kaminari-ad/mcp

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for mcp-tenant-isolation

README.md
[![agentmods](https://agentmods.dev/badge/rules/kaminari-ad/mcp/mcp-tenant-isolation/github.svg)](https://agentmods.dev/rules/kaminari-ad/mcp/mcp-tenant-isolation)
Your own site
<a href="https://agentmods.dev/rules/kaminari-ad/mcp/mcp-tenant-isolation"><img src="https://agentmods.dev/badge/rules/kaminari-ad/mcp/mcp-tenant-isolation/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for mcp-tenant-isolation

Your own site · 80×15
<a href="https://agentmods.dev/rules/kaminari-ad/mcp/mcp-tenant-isolation"><img src="https://agentmods.dev/badge/rules/kaminari-ad/mcp/mcp-tenant-isolation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,792 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01792
Opus 5.5 $0.00000 $0.00717
Sonnet 5.5 $0.00000 $0.00358
Haiku 4.5 $0.00000 $0.00179

Measured today against content hash 9dbb0b7bcc4d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

mcp-tenant-isolation scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/mcp-tenant-isolation.mdc · 108 lines

How it starts

The opening of the file, as written. The whole thing — 108 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Tenant Isolation Rules — mcp/ (hosted HTTP mode)

The hosted MCP endpoint at mcp.kaminari.ad serves many organizations from a single process. A bug here = cross-tenant data leak = customer trust event. Read this file before touching any code in mcp/src/presentation/http/, mcp/src/infrastructure/session/, or mcp/src/infrastructure/rate-limit/.

Threat model

The Kaminari Ad API is already secure: middleware resolves the Authorization header into an AuthContext.organization_id, and every use case enforces auth.organization_id == resource.organization_id (see clean-code → "Authorization and org-scoping").

MCP does NOT duplicate those checks. MCP's single job is: the Bearer that came in with request X must reach only the outbound API calls made by request X. Any leak of auth context between concurrent requests = a vulnerability that did not exist at the API.

Hard rules (CI-enforced)

1. No module-level mutable state

let and var are banned at module scope. static class fields must be readonly. ESLint no-restricted-syntax blocks the syntax; mcp/scripts/check-no-shared-state.ts walks the AST as a belt-and-suspenders gate. To bypass either, you must edit BOTH files in the same MR, and reviewers will reject without a multi-tenant safety analysis.

2. No caches indexed by tenant data

Zero caches. No Map<orgId, ...>, no Map<scanId, ...>, no per-Bearer memo, no LRU on tool results. Every tool call is a fresh API request. The performance cost is acceptable; the correctness benefit is non-negotiable.

The two exceptions live in mcp/src/infrastructure/session/ and mcp/src/infrastructure/rate-limit/. They hold only Map<sha256(bearer), {...}> entries, never user data. Both have isolation tests proving they cannot be queried with a different Bearer.

3. ApiGateway per request, never singleton

HttpApiGateway is constructed per incoming HTTP request, from that request's Authorization header. It lives in the request handler's closure and is garbage-collected when the request ends. There is no globalApiGateway.

Read the full file on GitHub · 108 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 108 lines · 0 tokens per session scan A 9dbb0b7bcc4d

Subscribe to this mod's changes

mcp-tenant-isolation is a cursor rule published in the GitHub repository kaminari-ad/mcp (0 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,792 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.