toolfence
ToolFence
MCPツール呼び出しのためのローカルでフェイルクローズするファイアウォール。
ToolFenceは、最小特権ポリシーと人間の承認を、AIエージェントとstdio MCPサーバーの間に配置します。これにより、安全な操作を許可し、危険な操作をブロックし、人間の判断が必要な呼び出しを転送する前に確認を求めます。MCPクライアントやサーバーのコード変更は不要です。
ALLOW Read ./src/index.ts
DENY Read ~/.ssh/id_rsa
ASK Run npm install
DENY Run sudo rm -rf ...ToolFenceの利点
セマンティックポリシー: 一般的なFilesystem、Shell、Git、HTTPツール呼び出しを、
fs.read、shell.exec、git.write、net.requestなどの操作に正規化し、パス、正確なコマンド引数、ホスト、HTTPメソッドを照合します。決定的な施行:
denyは他のすべての一致を上書きし、複数リソースのリクエストは単一のユニットとして評価され、不明または曖昧なアクションはフェイルクローズします。人間の承認: 認証されたローカルBrokerを使用して、1回限りまたはセッションごとの決定を行います。セッション承認はツールスキーマにバインドされ、そのスキーマが変更されると無効になります。
プライバシーに配慮した監査: ツールID、影響を受けるリソース、ポリシー決定、結果のハッシュを記録しますが、生の引数や結果は保存しません。
テスト可能なポリシー: CLIからYAMLポリシーの生成、検証、説明、回帰テストを行うことができます。
Related MCP server: cordon
ステータス
バージョン0.2.0は、最初の安定したオープンソースリリースです。これには、ローカルBrokerによるキャンセル可能な承認、控えめなFilesystem/Shell/Git/HTTPアダプター、ポリシー作成および開発コマンド、スキーマバウンドのセッション承認、実際のMCP統合テストが含まれています。
ToolFenceは悪意のあるMCPサーバープロセスに対するサンドボックスではありません。上流のプロセスは依然として現在のユーザーのオペレーティングシステム権限で実行されます。
ToolFenceはユーザーが設定したプロセスを起動し、Shell、Git、HTTP機能を仲介するため、npmパッケージは透過的に二重使用目的であると宣言されています。意図された正当な使用法とセキュリティ境界については、DISCLOSUREを参照してください。
インストール
npmパッケージ名はtoolfence-mcpです。コマンドはtoolfenceです。
npm install -g toolfence-mcpローカル開発の場合:
npm install
npm run build
npm linkクイックスタート
控えめなスターターポリシーを作成し、レビューしてから、任意のstdio MCPサーバーをラップします:
toolfence policy init
toolfence policy check --policy ./toolfence.yaml生成されたファイルは、既存のポリシーを決して上書きしません。注釈付きのより広範な例については、examples/policy.yamlを参照してください。
toolfence wrap \
--policy ./toolfence.yaml \
--server filesystem \
--workspace "$PWD" \
-- npx -y @modelcontextprotocol/server-filesystem "$PWD"MCPクライアントの設定は次のようになります:
{
"mcpServers": {
"filesystem": {
"command": "toolfence",
"args": [
"wrap",
"--policy", "/absolute/path/policy.yaml",
"--server", "filesystem",
"--workspace", "/absolute/path/project",
"--",
"npx", "-y", "@modelcontextprotocol/server-filesystem", "/absolute/path/project"
]
}
}
}ToolFenceはMCP JSON-RPCメッセージ用にstdoutを予約します。診断情報と上流のstderrはstderrに残ります。各ユーザーのBrokerと承認端末を別々の端末で起動します:
toolfence broker
toolfence approvalswrapはデフォルトでBrokerを使用します。Brokerが見つからない、互換性がない、認証されていない、切断されている、またはタイムアウトした場合、ask決定はフェイルクローズします。直接の/dev/tty承認が必要な場合のみ--approval ttyを使用します。toolfence statusは、Brokerの接続性、プロトコルバージョン、およびソケット権限を確認します。
ポリシー
version: 1
default: ask
rules:
- id: deny-dotenv
effect: deny
operations: [fs.read, fs.write]
resources: ["**/.env", "**/.env.*"]
- id: allow-workspace-read
effect: allow
operations: [fs.read]
resources: ["${workspace}/**"]
- id: allow-tests
effect: allow
operations: [shell.exec]
commands:
- [npm, test]
- id: allow-git-inspection
effect: allow
operations: [git.read]
- id: allow-read-api
effect: allow
operations: [net.request]
hosts: ["api.example.com", "*.internal.example.com"]
methods: [GET, HEAD]ルールは決定的に評価されます:
一致するすべての
denyルールは、他のすべての一致を上書きします。リソースルールの拒否は、要求されたリソースが保護されている場合に一致します。それ以外の場合、最初に一致したルールが優先されます。
何も一致しない場合、
defaultが使用されます。
許可および確認リソースルールでは、要求されたすべてのリソースが一致する必要があります。そのため、複数ファイルの呼び出しで許可されたパスを使用して許可されていないパスを運ぶことはできません。
Filesystemパスは、既存のシンボリックリンクを含めて、照合前に正規化されます。許可されたコマンドには正確なargv照合が使用されます。複合または引用符で囲まれたシェル文字列は安全なargvとして扱われず、デフォルトの決定にフォールバックします。
サポートされているv0.2操作は、fs.read、fs.write、fs.delete、shell.exec、git.read、git.write、git.remote、net.request、およびunknownです。曖昧なGitコマンド、無効なURL、および認識されないツールは、shell.execまたはunknownを介してフェイルクローズします。
ポリシー開発
toolfence policy init [--policy ./toolfence.yaml]
toolfence policy check --policy ./examples/policy.yaml
toolfence policy explain --policy ./examples/policy.yaml --action ./action.json
toolfence policy test --policy ./examples/policy.yaml --cases ./policy-cases.yamlinitは、既存のファイルを上書きせずに控えめなポリシーを作成します。checkは、YAML、厳格なスキーマルール、変数、重複ID、無効なネットワークフィールドの組み合わせを検証します。explainは、一致したルールと最終決定を出力します。testは宣言的なケースを実行し、不一致があるとゼロ以外の終了コードを返します。
監査ログ
デフォルトの監査ファイルは、ワークスペース内の.toolfence/audit.jsonlです。操作名、影響を受けるパス、ツールID、最終的なポリシー決定、および上流結果のSHA-256ハッシュを記録します。生のツール引数、コマンド引数、生の結果は、秘密情報の漏洩を減らすために意図的に省略されています。
別のパスを選択するには、--audit /path/to/audit.jsonlを使用します。
セキュリティ境界
ToolFence v0.2は、ツール呼び出しがこのプロキシを通過する際に、偶発的またはプロンプトインジェクションによるツールの誤用を低減します。上流のサーバープロセスがファイル、環境変数、またはネットワークを直接読み取ることを防ぐことはできません。プロセスの分離、環境フィルタリング、およびネットワーク制御は、後のサンドボックスフェーズに属します。
追加の現在の制限事項:
stdioトランスポートのみ
ローカルBrokerのサポートはPOSIXのみ。Windowsは非対話型でフェイルクローズします
JSON-RPCバッチメッセージは拒否されます
出力の機密情報編集はまだありません。生の結果はそのまま転送されます
HTTP MCPアダプターは、ToolFenceが再評価するためにリダイレクト先(例えば
redirectUrlとして)を公開する必要があります
開発
アーキテクチャ、脅威モデル、セキュリティ不変条件、v0.2実装計画は、開発ガイドで管理されています。
npm run typecheck
npm test
npm run build
npm pack --dry-run
npm audit --omit=dev完全な検証戦略はTESTING.mdにあり、リリース/セキュリティレビューレコードはREVIEW.mdにあります。貢献、脆弱性の報告、またはリリースの発行を行う前に、CONTRIBUTING.md、SECURITY.md、CHANGELOG.md、およびRELEASING.mdを参照してください。
ライセンス
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-quality-maintenanceA transparent proxy and execution firewall that intercepts and audits AI agent tool calls against configurable security policies before forwarding them to downstream MCP servers. It provides safe execution environments with features like data redaction, anti-loop protection, and unified alert dispatching.
- Alicense-qualityAmaintenanceSecurity gateway for MCP tool calls. Sits between your LLM client and MCP servers, enforcing per-tool policies (allow/block/approve/read-only), logging every call, and pausing dangerous operations for human approval in terminal or Slack.21MIT
- Alicense-qualityBmaintenanceA fail-closed cryptographic gate for the MCP tool-call boundary that intercepts tools/call requests, evaluates a policy, and either forwards or denies the call with signed receipts, providing tamper-evident evidence for AI agent actions.225Apache 2.0
- Alicense-qualityDmaintenanceA defensive gateway and firewall for AI agents using MCP servers, scanning tool calls, responses, and manifests for prompt injection, secrets, dangerous commands, and drift before allowing execution.MIT
Related MCP Connectors
Security firewall for AI agents — scans MCP calls for injection, secrets, and risks.
Runtime permission, approval, and audit layer for AI agent tool execution.
Crypto transaction firewall and risk tools for MCP agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/jiangkoumo/toolfence'
If you have feedback or need assistance with the MCP directory API, please join our Discord server