BD

boringsql/dryrun

开发工具官方

本页由 AI 翻译,技术细节请以原文为准。 查看原文

36 stars 4 forks 质量 83 趋势 32BSD-2-Clause

PostgreSQL模式智能MCP服务器,支持离线线条、迁移安全、为AI编码助手提供查询验证。

概览

那个不需要连接生产环境的PostgreSQL MCP服务器。 Dryrun为AI代理、IDE和CI提供完整的架构感知。从离线快照开始,而非实时数据库连接。对模式进行Linping,验证查询,检查迁移安全,探索外键图。所有这些都无需凭证离开DBA机器。 Dryrun是BoringSQL套件的一部分,与RegreSQL和Fixturize并列。 LLM/AI编码助手在编写代码/SQL查询方面非常擅长。但他们是盲目的。他们不知道你的模式、索引或约束。他们可能会生成一个迁移,将你最忙碌的表锁定ACCESS EXCLUSIVE并发送给你的应用。 有些PostgreSQL的MCP服务器会要求你提供数据库连接。而执行管理任务时,你可能需要超级用户权限。但这就像是在自找麻烦。 我们已经看到了结果:生产数据库被AI代理清除,MCP服务器被注入SQL本应只读。

概述(AI 翻译)

那个不需要连接生产环境的PostgreSQL MCP服务器。

dryrun 为 AI 代理、IDE 和 CI 提供完整的模式感知。从离线快照,而非实时数据库连接。用 Linder 你的模式,验证查询,检查迁移安全,并探索外键图。所有这些都无需让凭证离开 DBA 机器。

dryrun 是 boringSQL 套件的一部分,与 RegreSQL 和 Fixturize 一起。

问题所在

LLM/AI编码助手在编写代码/SQL查询方面非常擅长。但他们是盲目的。他们不知道你的模式、索引或约束。他们可能会生成一个迁移,在你最忙的表上锁定ACCESS EXCLUSIVE,然后把你的应用送下去。

有些PostgreSQL的MCP服务器会要求你提供数据库连接。而执行管理任务时,你可能需要超级用户权限。但这就像是在自找麻烦。

我们已经看到了结果:生产数据库被AI代理清除,MCP服务器被注入SQL本应只读。

模型不需要查询你的数据库。它需要理解你的模式:结构、约束、统计数据以及版本特定的行为。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

DryRun PostgreSQL MCP

The PostgreSQL MCP server that doesn’t need connection to the production.

dryrun gives AI agents, IDEs, and CI full schema awareness. From offline snapshot, not live database connection. Lint your schema, validate queries, check migration safety, and explore foreign key graphs. All without credentials leaving the DBA’s machine.

dryrun is part of the boringSQL suite alongside RegreSQL and Fixturize.

The problem

LLM/AI coding assistants are very good in writing code/SQL queries. But they are blind. They don’t know your schema, your indexes or your constraints. They might generate a migration that takes an ACCESS EXCLUSIVE lock on your busiest table and send your app down.

Some PostgreSQL MCP server ask you for the database connection. And to perform the administrative tasks you might need SUPERUSER permission. But that’s like asking for problem.

We’ve already seen where this leads: production databases wiped by AI agents, and SQL injection in MCP servers that were supposed to be read-only.

The model doesn’t need to query your database. It needs to understand your schema: the structure, constraints, statistics, and version-specific behavior. That knowledge is structural. It changes when you deploy a migration, not between queries.

DryRun features

dryrun is two things: a CLI tool and an MCP server. The CLI extracts and analyzes your schema. The MCP server exposes that analysis to AI assistants. They’re separate on purpose.

CLI - extract and analyze

The CLI connects to your PostgreSQL database, introspects the full catalog (tables, views, indexes, constraints, partitions, functions, enums, RLS policies, triggers, extensions, GUCs), and writes a snapshot into .dryrun/history.db. That snapshot is the source of truth for everything else.

Once you have the snapshot, the CLI works offline:

  • Lint - 20+ convention rules (naming, types, primary keys, timestamps, partitioning) and 13 structural audit rules (duplicate indexes, FK coverage, circular FKs, vacuum tuning)
  • Migration safety - lock type analysis, duration estimates, table rewrite detection, safe alternatives for each DDL statement
  • Query validation - SQL parsing via libpg_query, column reference checks against the actual schema, anti-pattern detection
  • Snapshot diff - compare schema, planner stats, or activity between snapshots; detect drift against the live database
  • Query stats - captures pg_stat_statements per node, collapses ORM query variants into shapes, diffs two captures to surface new or slowed queries
在 GitHub 查看完整 README

安装

npx -y @boringsql/dryrun mcp-serve
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "dryrun": { "command": "npx", "args": ["-y", "@boringsql/dryrun", "mcp-serve"] } } }