
Mcp Tenant Isolation
io.github.subodhkc由 GitHub 帳號 subodhkc 發布v2.0.0更新於 Oct 24, 2026
Static analysis scanner for MCP server code and multi-tenant SaaS applications.
概覽
對 TypeScript 與 JavaScript 程式碼庫(含 MCP 伺服器程式碼)執行確定性的靜態分析掃描,找出多租戶隔離缺口。
- 可以做什麼
- 此伺服器提供四個工具:scan_tenant_isolation 掃描專案路徑並回傳結構化結果,包含完整性、覆蓋率、問題家族與掃描回執;list_tenant_isolation_rules 回傳全部 57 條規則;explain_tenant_isolation_rule 回傳規則詳情、OWASP 對應、CWE 編號與修正建議;suppress_tenant_isolation_finding 記錄一筆抑制項目。57 條確定性規則涵蓋租戶情境、資料庫查詢、IDOR、快取與工作階段鍵、API 範圍、檔案儲存、日誌、結構描述設計,以及 15 條 MCP 專用模式。輸出支援終端機、JSON、SARIF、AI JSON 或 Markdown。
- 適用情境
- 適合 SaaS 工程團隊、安全團隊與 MCP 伺服器開發者,在開發過程或 CI/CD 中進行租戶隔離檢查,也適合讓 AI 代理隨需掃描程式碼中的跨租戶外洩風險。
- 執行需求
- npm 套件 mcp-tenant-isolation 需要 Node.js 22 或更新版本,也可改用 Docker。MCP 伺服器透過 stdio 在本機執行;未宣告託管、帳號、API 金鑰或環境變數。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mcp Tenant Isolation,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-tenant-isolation
Static analysis scanner for multi-tenant SaaS and MCP server code. 57 deterministic rules that catch cross-tenant data leakage before it reaches production.
[npm version] [npm downloads] [CI] [Docker] [License: MIT]
What it does
If you build multi-tenant software, every query, every cache key, every file access, every API response needs to be scoped to the right tenant. Miss one, and Tenant A sees Tenant B's data. That's not a bug you want to find in production.
This scanner reads your source code and checks whether tenant isolation guards are present where they need to be. It covers 57 patterns across database queries, API routes, cache keys, file storage, schema design, logging, and MCP server architecture. It works with TypeScript, JavaScript, Prisma, Drizzle, raw SQL, Next.js, Express, and Fastify.
The scanner also runs as an MCP server, so you can plug it into Claude Desktop, Cursor, or any MCP-compatible agent and have your AI assistant scan code on demand.
Who uses this
- SaaS engineering teams who need to catch tenant isolation gaps before code ships
- MCP server developers building tools that handle tenant-scoped data
- Security teams who want tenant isolation checks in CI/CD
- AI agent developers who want their agents to scan code for cross-tenant risks
Why this exists
General-purpose security scanners are not purpose-built for tenant isolation patterns. They catch SQL injection and XSS. They do not check whether your findMany query includes an organizationId filter. They do not check whether your MCP tool handler scopes tool visibility by tenant. They do not check whether your cache key includes a tenant prefix.
This scanner does exactly that. 57 rules, each checking for a specific tenant isolation pattern, each producing a finding with the rule ID, file, line, missing guard, and a remediation hint.
Every rule is deterministic. Given the same source code, the scanner produces the same findings. No machine learning, no probabilistic scoring. Static analysis has inherent limitations though. It cannot verify runtime behavior, database-level enforcement, or dynamic tenant isolation. The scan output includes a limitations field that lists what was and was not checked for each run.
Install
Requires Node.js 22 or later.
Quick start
Demo
Rules
42 general multi-tenant rules
15 MCP-specific rules
MCP rules are mapped to the OWASP MCP Top 10 (2025). See docs/OWASP-MAPPING.md for the full mapping. The mappings are advisory, for triage and reporting. This scanner does not certify OWASP compliance.
Architecture
The scanner pipeline runs in six stages:
- Parsers — Babel AST for TypeScript/JavaScript, Prisma schema parser, SQL migration parser, MCP SDK import detection
- IR and Flow Graph — Intermediate representation capturing sources, sinks, guards, routes, MCP tool definitions
- Rule Engine — 57 deterministic rules evaluated against the IR. Each rule defines sources, sinks, and required guards
- False Positive Filter — Test file detection, confidence scoring, pattern refinement
- Reporters — Terminal, JSON, SARIF 2.1.0, AI-friendly JSON with remediation hints, Markdown
- CLI and MCP Server —
mtiCLI with scan/init/rules/suppress/baseline/mcp commands. MCP server exposes 4 tools
Structured output
Scan results include structured metadata beyond just findings:
- Completeness — COMPLETE, PARTIAL, or ERROR. If files fail to parse or rules fail to evaluate, completeness drops to PARTIAL and the reasons are listed.
- Coverage — Files discovered, parsed, failed to parse. Rules available, selected, evaluated, failed, triggered. Unsupported file types counted.
- Concern families — Findings grouped into 8 concern families (Tenant Context, Data Isolation, Cache and Session, MCP Security, Secrets and Credentials, Vector and Storage, API and Access, Audit and Logging) for triage.
- Limitations — What the scan could and could not verify. Always includes static analysis limitation. Includes flow analysis scope and proof-of-fix status.
- Scan receipt — Provenance metadata with engine version, rulepack digest, timestamp, and a SHA-256 receipt hash for tamper detection.
- Proof-of-fix — Each finding is tagged as STILL_PRESENT, NEW, or NOT_VERIFIABLE relative to a baseline file. Run
mti baselineto establish a baseline.
Fingerprints
Findings use v2 semantic fingerprints that are stable under line movement and formatting changes. The fingerprint is derived from the rule ID, file path, normalized code snippet, and sorted missing guards. It does not include the line number. This means if you move code around without changing its semantics, the fingerprint stays the same and baseline tracking remains accurate.
MCP server
The package includes an MCP server for AI agent integration. It runs locally via stdio transport. No hosting, no network exposure.
Add this to your Claude Desktop, Cursor, Windsurf, or other MCP client config to let your AI agent scan code for tenant isolation issues on demand.
MCP tools
The suppression tool is hidden by default. It only appears when the server is started with --allow-write-tools. This is a security boundary: read-only by default, write operations require explicit opt-in.
All filesystem operations during MCP scans are constrained to the project root configured at server startup. Traversal attacks (../), absolute paths outside root, UNC paths, and symlink escapes are rejected. See SECURITY.md for details.
CI/CD integration
Option 1: Pre-built GitHub Action (easiest)
Add this to .github/workflows/tenant-isolation.yml:
Runs the scan, uploads SARIF to GitHub Code Scanning, generates a Markdown report artifact, and fails the workflow if HIGH or CRITICAL findings are detected.
Option 2: Manual npx
Exit codes
GitHub Code Scanning integration
When you upload SARIF output using github/codeql-action/upload-sarif@v3, findings appear in your repository's Security > Code scanning alerts tab. This works with both free and Advanced Security-enabled repos.
What happens:
mti scan --format sarif --output results.sarifgenerates a SARIF 2.1.0 fileupload-sarifaction sends it to GitHub's code scanning API- Each finding becomes a code scanning alert with file, line, severity, and remediation hint
- Alerts can be dismissed, fixed, or tracked directly in the GitHub UI
- Pull request annotations appear automatically on changed files
Requirements:
permissions: security-events: writein your workflow- The SARIF file must be generated before the upload step
Configuration
Create .mtirc.json in your project root:
Advanced configuration
Custom rule packs
You can extend the scanner with custom rules via JSON rule packs. Custom rules are validated at load time:
- Rule IDs must match
PREFIX-NNNformat (e.g.,CUST-001) - Rule IDs cannot collide with built-in rules
- Severity must be one of INFO, LOW, MEDIUM, HIGH, CRITICAL
- Maximum 50 custom rules across all rulepacks
- Rulepack paths are constrained to the project root (MCP mode)
Invalid custom rules are rejected with warnings. The scan continues with built-in rules.
Suppressions
Suppressions require a concrete finding fingerprint, a rule ID, a documented approver identifier, a reason, compensating controls, and an expiry date. Rule-wide suppressions (no fingerprint) are only permitted as documented permanent exceptions.
The documentedApprover field records who approved the suppression. It does not represent independent human verification. It is a recorded attribution string, not a claim of external review.
Baselines
Run mti baseline to snapshot current findings. Future scans compare against the baseline and tag each finding as STILL_PRESENT, NEW, or NOT_VERIFIABLE (if no baseline exists). This gives you proof-of-fix tracking over time.
Report formats
Trust and supply chain
- npm Trusted Publishing — packages are published via GitHub Actions OIDC, not long-lived tokens. Each publish uses a short-lived, workflow-specific credential.
- Provenance attestations — every published package includes a signed provenance statement in the Sigstore transparency log. You can verify that the package was built from the exact source in this repository.
- 0 npm audit vulnerabilities — dependencies are audited on every CI run. The lockfile is committed and CI uses
npm cifor reproducible installs. - Deterministic rules — no machine learning, no probabilistic scoring. Given the same source code, the scanner produces the same findings every time.
- Cross-platform CI — tested on Ubuntu, Windows, and macOS with Node 22 and 24. Node 26 canary runs as informational.
- MIT licensed — free and open source. No telemetry, no phone-home, no data collection.
Limitations
Static analysis has inherent limits. Being upfront about them:
- Intra-procedural flow analysis only. The scanner traces data flow within a single function body. It does not trace flow across function calls, files, or framework middleware boundaries. Most tenant isolation defects are missing-guard-at-sink problems that do not require inter-procedural analysis, but some edge cases may be missed.
- No runtime verification. The scanner checks source code patterns. It cannot verify that database-level RLS policies are actually enabled, that middleware actually runs, or that tenant context is actually propagated at runtime.
- TypeScript and JavaScript only. Python, Go, Ruby, and other languages are not supported yet.
- False positives are possible. The scanner uses pattern-based detection with false-positive filtering (test file exclusion, auth signal detection, confidence scoring). Custom auth helpers and tenant guards can be configured via
.mtirc.jsonto reduce false positives. - MCP stdio transport only. The MCP server runs locally via stdio. Remote/HTTP transport is not supported in v2.0.
See docs/FLOW-ANALYSIS-QUALIFICATION.md for detailed flow analysis scope.
Tech stack
- AST Parsing: @babel/parser (TypeScript, JSX), Prisma schema parser, SQL migration parser
- Rule Engine: RuleSpec declarative pattern with guard detection and evidence building
- CLI: Commander
- MCP: @modelcontextprotocol/server v2 (stdio transport, Zod schemas, structured output)
- Output: Terminal, JSON, SARIF 2.1.0, AI JSON, Markdown
- Testing: Vitest (203 tests, cross-platform CI on Ubuntu, Windows, macOS)
Roadmap
v2.0.0 (Current)
- 57 rules (42 general + 15 MCP-specific)
- TypeScript and JavaScript support
- Prisma schema analysis
- SQL migration analysis (RLS, tenant columns, indexes)
- CLI with terminal, JSON, SARIF, AI JSON, Markdown output
- MCP server v2 SDK (stdio transport, Zod schemas, structured output)
- Structured MCP output with completeness, coverage, and concern families
- Scan Receipt with rulepack digest and tamper-detection hash
- Evidence Envelope for verifiable scan artifacts
- Stable v2 semantic fingerprints (line-movement resistant)
- OWASP MCP Top 10 mapping (official 2025 categories)
- Path boundary enforcement (traversal, symlink, UNC, Windows 8.3)
- Write-tool gating (read-only by default, suppression opt-in)
- Suppression policy with expiration and documented approver
- Baseline tracking with proof-of-fix states
- Severity override in .mtirc.json
- Custom rule packs with validation
- Configurable auth helpers and tenant guards
- Model scope classification with config overrides
- Framework detection (Next.js, Express, Fastify)
- Cross-platform CI matrix (Node 22/24, Ubuntu/Windows/macOS)
Future
- Python support (FastAPI, Django, Flask)
- SQLAlchemy ORM analysis
- Watch mode (mti scan --watch)
- VS Code extension
- Runtime two-tenant adversarial test harness
- Go and Ruby language support
- Incremental scanning with AST cache
Links
- Landing page
- GitHub
- npm
- Docker Hub
- Changelog
- Contributing
- Security policy
- HAIEC (Human AI Evidence Company) — AI security validation and audit-evidence platform
- Subodh Kc — builder
License
MIT. Free and open source.
來源:README.md,提交 afbbf87
工具
0版本歷史
1- v2.0.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分