mcp-policy-gateway
mcp-policy-gateway
一个策略优先的 MCP 服务器参考实现。它展示了如何为代理提供有用的工具,而不允许模型自行决定授权、跨越租户边界、泄露直接 PII,或自行执行高影响变更。
这是一个作品集/参考实现。所有记录都是合成的;它不是生产软件,也不声称与银行、支付处理器或客户系统集成。
为什么存在
常见的 MCP 演示将原始 API 暴露给模型,并将成功的工具调用视为安全模型。本项目采取相反的立场:
策略是确定性的。 模型不能自行授权。
租户边界在服务端强制执行。 工具参数不能切换租户。
工具输出最小化。 账户摘要故意排除所有者姓名和电子邮件。
高影响操作在审批门处停止。 冻结请求不会产生状态变更。
每个决策都可审计。 允许、拒绝和需要审批的结果都会创建结构化审计事件。
变更请求需要理由和幂等键。
Related MCP server: scopeguard-mcp
架构
MCP client / agent
│ tool call
▼
FastMCP stdio adapter
│ verified principal (demo fixture here)
▼
GatewayService ──► PolicyEngine ──► allow / deny / require approval
│ │
▼ ▼
synthetic domain data structured audit event在生产部署中,主体将来自模型上下文之外的已验证身份/会话。切勿从工具参数或模型输出中接受 tenant_id、角色或作用域。
工具
工具 | 风险 | 行为 |
| 读取 | 仅允许调用者租户内具有正确作用域的案件。 |
| 读取 | 返回最小化摘要;绝不直接返回 PII。 |
| 变更 | 需要作用域、理由和幂等键,然后始终需要人工审批。 |
快速开始
需要 Python 3.11+。
python -m venv .venv
.venv/bin/pip install -e '.[dev]'
.venv/bin/pytest
.venv/bin/ruff check .作为 MCP stdio 服务器运行:
.venv/bin/mcp-policy-gateway适配器故意使用固定的演示主体进行本地探索。真实身份传播被有意记录为生产集成问题,而不是在这里伪造。
演示的滥用控制
测试证明网关:
拒绝来自
tenant_red的代理尝试读取tenant_blue数据;拒绝没有所需作用域的工具调用;
不通过摘要工具返回所有者姓名或电子邮件;
返回
require_approval而不是变更账户状态;以及拒绝省略理由或幂等键的变更状态请求。
威胁模型和非目标
参见 THREAT_MODEL.md。设计有意保持狭窄:它演示了围绕 MCP 工具的策略边界,而不是完整的身份基础设施、持久化审计存储、机密管理或支付/账本系统。
面试讲解
解释项目的一种简洁方式:
我设计了 MCP 边界,使模型能够基于安全、有作用域的数据进行推理,但不能决定访问权限或执行高影响操作。授权是确定性的,租户隔离在服务端强制执行,工具表面最小化 PII,敏感变更终止于可审计的人工审批门。
开发
.venv/bin/pytest
.venv/bin/ruff check .CI 在推送和拉取请求上运行这两项检查。
许可证
MIT。参见 LICENSE。
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
- AlicenseBqualityBmaintenanceA governance and policy enforcement gateway for MCP servers that provides hard guardrails, dynamic parameter bounds, human-in-the-loop approvals, and audit telemetry.211MIT
- AlicenseAqualityCmaintenanceEnables policy-first defensive security operations for MCP, providing repository and web-security analysis with controlled authorization, scoped execution, and auditability.9MIT
- FlicenseNot gradedqualityCmaintenanceEnables approval-gated incident response workflows that gather evidence through read-only MCP tools, perform idempotent writes, and preserve a durable audit trail.1
- AlicenseNot gradedqualityCmaintenanceEnforces fine-grained, context-aware access control on MCP tool calls, with a tamper-evident, replayable audit log that records denials and verifies every decision.MIT
Related MCP Connectors
Remote MCP for A2A caller identity, scope policy, verdict receipts, and audit history.
Paid remote MCP for AI Studio Workspace approval gate MCP, structured receipts, audit logs, and revi
Remote MCP for Copilot CLI switch gate MCP, structured receipts, audit logs, and reviewer-ready evid
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/jcorrego/mcp-policy-gateway'
If you have feedback or need assistance with the MCP directory API, please join our Discord server