Midplane
SQL guardrails for AI agents, sitting between the agent and Postgres to enforce policies, block destructive queries, and audit all access.
README
Midplane
Safe-by-default SQL guardrails for AI agents. Midplane sits in the query path between an AI agent (Claude, Cursor, any MCP client) and your Postgres database. It parses every statement with a real SQL AST — not a regex blocklist — enforces a declarative per-table access policy, blocks destructive DML/DDL, and writes an event-sourced audit log of which agent ran what, before the query executes.
📖 Full documentation lives at midplane.ai/docs — agent setup, the policy reference, self-hosting, deployment, and the threat model. This README is just the orientation.
<img width="960" height="540" alt="midplane-chat-demo" src="https://github.com/user-attachments/assets/d9800b2a-dc45-4a6e-a0b2-3aa219b1009a" />
Why this exists
AI coding agents are being plugged into production Postgres without an audit trail or a safety layer. The deprecated Anthropic reference Postgres MCP shipped a stacked-statement injection vector (Datadog Security Labs, 2025); the common service-role setup hands an agent a connection that can read and write every table. Midplane parses every query as an AST, denies the dangerous shapes, and writes a durable audit row before the query reaches your database.
What it blocks
- Destructive writes by default —
DELETE FROM usersis denied even with aWHERE, until you opt the table intoread_write. - Whole-table wipes and schema destruction — no-
WHEREDELETE/UPDATEand allDROP/TRUNCATE/ALTER, regardless of table policy. - Stacked-statement injection —
SELECT 1; DROP TABLE usersdenied at parse time. - Writes hidden inside a read —
WITH x AS (DELETE FROM users RETURNING *) SELECT * FROM xis denied at the innerDELETE, not the outerSELECT. The same recursive walk covers subqueries, UNION arms, and JOINs.
The full policy model, the parse → policy → audit pipeline, and the adversarial corpus that pins it are documented at midplane.ai/docs.
In a real chat
A delete all users prompt to Claude Code, against a Midplane-fronted DB:
⏺ Hold on — that's destructive and irreversible. Before I run
DELETE FROM public.users, please confirm.user: confirm delete all users
⏺ Midplane blocked it: "writes to table
usersare not allowed by the table-access policy." The DELETE was audited but not executed.
Quick start
Three ways in — same open-core codebase behind all of them. Step-by-step guides are at midplane.ai/docs.
Managed cloud
The fastest way to try Midplane: sign up at app.midplane.ai and go from zero to your first guarded query in a couple of minutes. Dashboard, policy editor, hosted audit log, agent-token issuance. Nothing to install, multi-region, fully supported.
Guard one database yourself
Put the MIT engine in front of a Postgres database and point an agent at it.
Nothing to install — npx ships with Node and fetches the
midplane package on first run
(needs Node 22.16+; on anything older it says so and exits). Add this to your
MCP client's config (Claude Code, Claude Desktop, Cursor — they all take this
shape):
{
"mcpServers": {
"midplane": {
"command": "npx",
"args": ["-y", "midplane", "server", "--stdio"],
"env": { "DATABASE_URL": "postgres://user:pass@host:5432/db" }
}
}
}
Keep the connection string in that env block rather than on a command line,
where it would leak to ps aux and your shell history. The block still lands in
a plaintext config file, so give Midplane its own least-privilege Postgres role:
it governs which SQL runs, not what the role underneath it can reach.
That config is already the safe default: reads allowed, writes and DDL denied,
every query audited to ~/.midplane/audit.db. Read the log back with
npx midplane audit denies. To open specific tables up, generate a policy with
npx midplane init — it introspects your schema over a read-only connection,
suggests a tenant column, and writes a validated midplane.policy.yaml.
For a CI pipeline or a long-lived sidecar, the same engine ships as a self-contained image with no Node in it —
midplane/midplane:0.19.0, serving Streamable HTTP instead of stdio. Setup ·engine/README.md.
Self-host the whole app
The complete single-tenant product — dashboard, policy editor, audit log, agent-token issuance — keyless and uncapped, on your own Postgres. Docker is the only prerequisite:
git clone https://github.com/midplaneai/midplane && cd midplane
./bin/self-host up # → http://localhost:3000
That generates secrets into .env.self-host, brings up Postgres + the web app,
applies migrations on boot, and prints the dashboard URL — the first
email+password signup becomes the owner.
Running from source, the single-image deploy, the engine-spawn topology, and the
full walkthrough: midplane.ai/docs (in-repo:
SELF_HOST.md).
Open core
Midplane is open core, MIT, and self-hostable. Everything outside
apps/web/src/ee/ is the Community Edition — the whole single-tenant product,
uncapped when self-hosted. apps/web/src/ee/ is the commercial Enterprise Edition
(SSO/SAML today; the governance band over time); deleting it leaves a working MIT
build. The managed cloud is the same codebase and the supported, paid path. See
LICENSE for the MIT terms and NOTICE for the ee/
carve-out.
Architecture
One codebase, two deployables:
- Control plane (repo root) — dashboard, policy management, audit views,
agent-token issuance, hosted MCP proxy. MIT except
apps/web/src/ee/. - Engine (
engine/) — the MIT query-path engine, compiled to a self-contained binary. The control plane spawns it per project and never reimplements it, so hosted and self-host run the exact same engine — only the packaging differs.
apps/web Next.js dashboard + Better Auth + projects API
packages/db Drizzle schema (customers, projects, audit index)
packages/kms encryptDsn / decryptDsn (env-mode dev, AWS KMS prod)
packages/router Hosted MCP request handler — token → project → engine
engine/ The MIT query-path engine
infra/telemetry-proxy Cloudflare Worker for anonymized OSS install telemetry
Operating the managed multi-region cloud (Fly + Neon + KMS) is in
docs/deploy.md.
Contributing
Issues and PRs welcome — start with CONTRIBUTING.md. The
single highest-leverage contribution is a new entry in the adversarial SQL corpus:
a bypass attempt and the policy fix that defeats it. Commits are DCO-signed
(git commit -s). For security issues, follow SECURITY.md —
don't open a public issue.
License
MIT — see LICENSE. No copyleft, no BSL, no source-available rug-pull.
The one carve-out is apps/web/src/ee/ (the commercial Enterprise Edition, governed
by apps/web/src/ee/LICENSE and recorded in
NOTICE); deleting it leaves a fully working MIT build.
More: Docs · Pricing · Support · Design system · Code of Conduct
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。