border-patrol-mcp
A policy-enforcing MCP gateway that intercepts all tool calls to downstream MCP servers, applying allow/deny/ask rules with human approval and audit logging for safe access to dangerous tools.
README
border-patrol-mcp
_______________
| BORDER |
| PATROL |
|_______________|
___
(o_o) "HALT! State your business."
<| |\
| |
_| |_
(_) (_)
A policy-enforcing MCP gateway. Your agent connects to one MCP server — border-patrol — and every tool call to every real MCP server behind it gets stopped at the checkpoint and asked the important questions: allow, deny, or "papers, please" (a human has to approve it).
The agent only ever talks to the guard. The dangerous servers are only reachable through the checkpoint. There is no road around it. We checked.
Agent (Claude, Cursor, …)
│ ← sees ONE MCP server: border-patrol
▼
border-patrol ── policy engine: allow / deny / ask ── audit log (JSONL)
│ │
├──► postgres MCP └── approval CLI (you: `border-patrol approve req_42`)
├──► filesystem MCP
└──► shell MCP
Why does this exist
Because one day your agent will decide the users table is "legacy". Because "drop the test database" and "drop the database" are the same sentence to a language model at 2am. Because client-side permission prompts are inconsistent, easy to click through, and written by optimists.
Border-patrol puts enforcement at the protocol layer, in one place you control, with an audit trail of everything the agent did — and, more importantly, everything it tried to do.
Install & run
npm install -g border-patrol-mcp
(From source instead: git clone, npm install, npm run build, and swap border-patrol for node /path/to/dist/cli.js below.)
Create border-patrol.yaml:
servers:
postgres:
command: npx
args: ["-y", "@modelcontextprotocol/server-postgres", "postgres://localhost/mydb"]
filesystem:
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/you/project"]
rules:
# Hard-block DDL. The users table stays. Forever.
- tool: "postgres__query"
match:
args.query: { regex: "(?i)^\\s*(drop|truncate|alter|grant)\\b" }
action: deny
reason: "DDL is forbidden through this gateway"
# Writes need a human to say yes. Once. Per exact call.
- tool: "postgres__query"
match:
args.query: { regex: "(?i)^\\s*(delete|update)\\b" }
action: ask
# No catch-all needed: unmatched calls fall back to `defaults`
# (onUnknown: allow), while tools annotated destructiveHint still
# route to `ask`. An explicit `- tool: "*", action: allow` would
# override that annotation safety net — write one only if you mean it.
Point your MCP client at border-patrol instead of the real servers:
{
"mcpServers": {
"border-patrol": {
"command": "npx",
"args": ["-y", "border-patrol-mcp", "serve", "--config", "/path/to/border-patrol.yaml"]
}
}
}
Works with any MCP client — it's just a standard stdio MCP server with strong opinions.
How the checkpoint works
Every tool from every downstream server is re-exposed as <server>__<tool> (e.g. postgres__query). For each call, the first matching rule wins:
-
allow— forwarded downstream verbatim. Have a nice day. -
deny— blocked before it reaches the server. The agent gets an error explaining why, and a lecture it didn't ask for. -
ask— not executed. The officer appears, the agent gets an approval id, and tells you. You run:border-patrol list # see what's waiting at the checkpoint border-patrol approve req_42 # stamp it. or: deny req_42The agent then retries the exact same call and it goes through — once. Approvals are single-use and bound to the exact arguments, so an approval for
DELETE FROM users WHERE id = 5does not magically also coverWHERE 1=1. Nice try.
When no rule matches, tool annotations from the MCP spec take over: a tool marked destructiveHint: true defaults to ask (configurable via defaults.onDestructiveHint). You get sane protection even for servers you've never written rules for.
Matchers
Rules match on the namespaced tool name (glob: postgres__*) and on argument values via dot-paths:
match:
args.query: { regex: "(?i)^delete\\b" } # "(?i)" prefix = case-insensitive
args.path: { contains: "/etc/" }
args.env: { equals: "production" }
args.input: { notRegex: "(?i)secret" }
All conditions in a rule must match. String arguments are whitespace-normalized before matching (trimmed, runs collapsed), because "D R O P TABLE" is not as clever as the agent thinks it is.
Fail-closed by design
The officer assumes guilt:
- Invalid config or rule regex → refuses to start.
- Downstream server unreachable → its tools simply don't exist. Nothing bypasses the checkpoint.
- Approval timeout → treated as denied.
- Bug in the guard itself → the call is blocked, not forwarded.
Audit log
Every call is appended to .border-patrol/audit.jsonl (path configurable): tool, arguments, decision, reason, outcome, latency. Grep it, tail it, or frame the entry where the agent tried to DROP TABLE users and you caught it.
CLI
border-patrol serve [--config path] run the gateway (what agents connect to)
border-patrol approve <id> stamp the papers
border-patrol deny <id> turn the call around
border-patrol list [--status pending] see who's waiting at the checkpoint
Config resolution: --config flag → $BORDER_PATROL_CONFIG → ./border-patrol.yaml.
Development
npm run build # compile to dist/
npm test # policy engine unit tests
npm run test:e2e # full gateway e2e (allow/deny/approve/retry/audit)
Honest limitations
- The guard is a tripwire, not a vault door. Regex matching can be defeated by determined obfuscation. Pair it with least-privilege credentials downstream (read-only DB roles, sandboxed shells) for real safety. Officer Pat Rollo is vigilant, but he cannot read base64.
- Enforcement only works if border-patrol is the only path. Don't also connect the raw servers directly to the agent. That's a hole in the fence.
- Resources and prompts are not proxied yet (tools only).
- Approval currently happens out-of-band via the CLI; MCP elicitation support is planned for clients that support it.
Roadmap
- MCP elicitation for inline approval prompts (clients that support it)
- Streamable-HTTP transport so border-patrol can run as a shared team checkpoint
- Rate limits / per-session budgets for destructive calls
- SQL-aware matching via a real parser (so the officer can read base64)
- Small web dashboard for approvals and audit browsing
License
MIT. The checkpoint is open source. The checkpoint never closes.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。