mcp-gate
mcp-gate
パスはリクエストである。ルートの境界が保証である。
MCP ファイルアクセスサーバーは、モデルが触れてよいファイルを roots(許可されたディレクトリの集合)によって強制します。mcp-gate は、サーバーに「ルート内に留まる」と指示することと、強制することの違いを示します。同じ攻撃スイートを、指示しか持たないバージョンと、読み取り前にすべてのパスを正規化して境界と照合するバージョンの両方に対して実行します。一方は漏えいし、もう一方は守ります。両方向が CI で強制されます。
これは、Anthropic の高度な MCP 教材の概念を独立して実装したもので、次の 3 点を明示的に示すために書かれています。
機能 | 確認できる場所 |
高度な MCP サーバー |
|
ログと進捗 | すべてのツールは、実行時に MCP のログ通知( |
アクセス制御 |
|
2つのモード
モード | 判定方法 | 結果 |
| システムプロンプトの指示は「roots 配下のファイルのみを読み取る」と言うが、パスは渡されたとおりに開かれます。 | 漏れる — 素朴なパスハンドラーは、意図的に最悪のケースの対照となっています。 |
| 各パスはデコードされ、 | 漏れない — 範囲外のリクエストは、ファイルを開く前に拒否されます。 |
攻撃スイート
攻撃 |
|
|
| 配信 ✓ | 配信 ✓ |
| 漏れる | ブロック |
| 漏れる | ブロック |
| 漏れる | ブロック |
| 漏れる | ブロック |
プロンプト層のセキュリティを手短に手動テストすると安全そうに見えるが、試していない攻撃で破綻してしまうためです。
Related MCP server: personal-mcp-bridge
ゲート(CIによる双方向強制)
python -m mcp_gate gate boundary # exit 0 only if 0 escapes
python -m mcp_gate gate prompt # exit 0 only if the leak is still demonstrated
python -m mcp_gate suite # both halves must holdgate prompt が漏れないということは、デモが空虚になったことを意味します(安全でない側も通ってしまうならば、「安全」な結果は無意味だからです)。そのため CI は それ もビルド失敗として扱います。
クイックスタート
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -q
python -m mcp_gate gate boundary
python -m mcp_gate gate prompt
python -m mcp_gate suiteライブの MCP サーバーとクライアントのデモを実行します(サンプリングツールには pip install -e ".[demo]" と、環境内の ANTHROPIC_API_KEY が必要です):
python -m mcp_gate serve ./data/sandbox # start the server over stdio
python -m mcp_gate.client ./data/sandbox # drive it: logs, progress, sampling, a blocked attackRESULTS.md にキャプチャされた出力があります。そこにあるすべてのブロックは実際のコマンド出力であり、scripts/make_results.py によって再生成され、手動編集されたものではありません。
注意
data/配下のデータはすべて架空です。data/out_of_bounds/secret.txtは「サーバーが決して供給してはならないファイル」を示すラベルの付いた代役です。この
-gateシリーズの一部: 自作のゲートを通過するまで何も出すことはありません。
Related MCP Connectors
Bounded readonly SHA256 verification with the official MCP SDK. No code execution or model calls.
Read-only verifier for 25 ProofRelay MCP tools and non-confidential evidence bundles.
MCP enforcement layer that intercepts AI agent actions and blocks rule violations before execution.
Read-only MCP for identity resolution and write guardrails.
Related MCP Servers
- AlicenseAqualityDmaintenanceProvides safe local file operations through MCP, including reading, writing, searching, organizing, and protected deletion with configurable path restrictions.121ISC
- AlicenseNot gradedqualityDmaintenanceEnables safe, read-only browsing of allowlisted local directories through MCP, providing tools to list roots, read files, and search text.MIT
- AlicenseNot gradedqualityDmaintenanceProvides safe, allowlisted local filesystem access for MCP-compatible AI clients, enabling directory listing, file reading/writing (with byte limits), and text search while blocking paths outside approved roots and symlink escapes.MIT
- FlicenseNot gradedqualityCmaintenanceEnables secure filesystem operations (read, write, list, move, search files/directories) through the Model Context Protocol, with dynamic directory access control via MCP Roots.-