DBeast PostgreSQL MCP

io.github.snss10由 GitHub 账号 snss10 发布v2.0.2更新于 Oct 24, 2026

PostgreSQL MCP server for schema, query, health, security, and performance analysis.

概览

AI 生成的概览

为 AI 助手提供 21 个专注 PostgreSQL 的 DBA 工具,用于模式发现、只读查询、影响预览、性能、安全与维护分析。

可以做什么
DBeast 通过 MCP stdio 将助手连接到 PostgreSQL 数据库,提供覆盖十个类别的 21 个工具。功能包括连接与健康检查、模式发现(可选生成 Mermaid ERD)、依赖关系梳理、带自动行数限制的只读 SELECT 查询、查询分析与索引建议、写操作影响预览、性能与维护报告、安全与敏感数据审计、数据质量检查、配置审查、复制状态以及审计日志查询。
适用场景
适合需要检查或审计 PostgreSQL 数据库的场景:探索模式、回答查询问题、诊断慢查询、查看 vacuum 与索引健康状况、检查角色与权限,或在执行删除、归档前评估影响范围。
运行要求
以 stdio 子进程方式在本地运行;清单中列出 OCI 镜像 ghcr.io/snss10/dbeast:2.0.2,README 则通过 pip 从源码安装。需要 PostgreSQL 连接,可通过 DATABASE_URL,或 DB_HOST、DB_PORT、DB_USER、DB_PASSWORD、DB_NAME 提供,也可用 AWS_SECRET_NAME 与 AWS_REGION 从 AWS Secrets Manager 获取。仅支持桌面客户端,无需 HTTP 服务。
安装前请注意
凭据通过 DATABASE_URL、DB_PASSWORD 等环境变量传给服务器,因此会保存在 MCP 客户端配置中。服务器会读取数据库模式与数据,其中敏感数据扫描会检查列名与模式,并默认记录工具调用的审计日志。写语句只返回影响预览而不执行,但实际可执行范围仍受所连接数据库账号自身权限限制。

安装

在 SourceWeft 中

  1. 打开 控制台中的 DBeast PostgreSQL MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[DBeast]

A PostgreSQL MCP server that gives AI assistants expert DBA capabilities.

[Python 3.11+] [PostgreSQL 12+] [MCP Compatible] [License: MIT]

Quick Start · Demo · Tools · Safety · Configuration · Docs


DBeast connects AI assistants such as Claude, Cursor, Windsurf, and VS Code Copilot to PostgreSQL through the Model Context Protocol. Instead of exposing one broad execute_sql escape hatch, DBeast provides 21 focused tools for schema discovery, safe query execution, impact analysis, performance review, security checks, maintenance reporting, replication monitoring, and data quality inspection.


Demo

Watch Claude use DBeast MCP tools to audit a PostgreSQL database, identify security and maintenance risks, and preview cleanup impact without executing destructive SQL.


How It Works

text
AI assistant  --MCP stdio-->  DBeast server  --asyncpg-->  PostgreSQLClaude/Cursor                  Python local                 Local, RDS,Windsurf/VS Code               subprocess                   Supabase, Neon

DBeast runs as a local stdio MCP server. Your IDE or desktop assistant starts it as a subprocess and passes database credentials through environment variables. The assistant calls DBeast tools, DBeast queries PostgreSQL, and structured results come back to the assistant. No HTTP service or extra infrastructure is required.


Quick Start

1. Install

bash
git clone https://github.com/snss10/DBeast.gitcd DBeastpip install -e .

For development:

bash
pip install -e ".[dev]"

Optional: copy .env.example to .env and set your database credentials.

2. Verify

bash
dbeast

Or run the source entry point directly:

bash
python src/server.py

3. Configure Your MCP Client

Minimal Cursor or Windsurf config:

json
{  "mcpServers": {    "dbeast": {      "type": "stdio",      "command": "python",      "args": ["/absolute/path/to/DBeast/src/server.py"],      "env": {        "DATABASE_URL": "postgresql://user:password@localhost:5432/mydb"      }    }  }}

Common config locations:

ClientConfig location
Cursor.mcp.json in project root, or ~/.cursor/.mcp.json globally
VS Code.vscode/settings.json or user settings with key mcp.servers
Claude Desktop on macOS~/Library/Application Support/Claude/claude_desktop_config.json
Claude Desktop on Windows%APPDATA%\Claude\claude_desktop_config.json
Windsurf.mcp.json

See SETUP.md for full client examples, Docker, RDS, Supabase, Neon, SSH tunnels, AWS Secrets Manager, and troubleshooting.

4. Ask Simple or Complex Questions

Once connected, your assistant can answer quick lookup questions and also run multi-step database investigations.

Simple examples:

text
Show me the schema for the orders table.Which queries are slowest right now?Run a security audit on the public schema.Generate a Mermaid ERD for the sales schema.

More complex examples:

text
Before I archive old sessions, estimate how many rows would be affected, identify related tables, and tell me the rollback risk.Investigate why the dashboard query is slow, explain the execution plan, and suggest safe indexes.Review the public schema for maintenance issues, security risks, and data quality problems, then summarize the top priorities.Compare table growth, dead tuples, and index health across all schemas and recommend what to vacuum or reindex first.

Tools

DBeast exposes 21 MCP tools across 10 categories.

Connection

ToolDescription
connectConnect to PostgreSQL, check current status, or discover local databases
disconnectClose the current database connection
health_checkVerify connectivity, pool health, PostgreSQL version, and extensions

Schema Discovery

ToolDescription
get_schemaList schemas, tables, columns, indexes, relationships, and optional Mermaid ERDs
dependency_analysisMap object dependencies before renaming, dropping, or changing database objects

Data Access

ToolDescription
execute_queryRun read-only SELECT queries with automatic row-limit injection

Query Analysis

ToolDescription
analyze_queryParse and inspect query structure, warnings, and optimization hints
query_optimizerRecommend indexes and rewrites for a given query
analyze_impactPreview write-query impact, risk level, affected rows, and rollback context without executing

Database Health

ToolDescription
database_healthReview cache hit rates, connections, transaction age, table health, and overall health signals
query_performanceReport slow or expensive queries from PostgreSQL statistics

Security

ToolDescription
security_auditInspect roles, privileges, superuser accounts, and public schema exposure
sensitive_data_scanDetect likely PII or secrets by column names and schema patterns

Maintenance

ToolDescription
maintenance_analysisReview vacuum status, dead tuples, analyze timestamps, and index health
partition_analysisInspect partition health, row distribution, and missing partition risks

Data Quality

ToolDescription
data_quality_reportAnalyze null rates, cardinality, value distributions, and outliers
duplicate_detectionFind duplicate rows across selected key columns

Server Config

ToolDescription
configuration_reviewReview PostgreSQL configuration and tuning opportunities
replication_statusInspect replication lag, WAL sender/receiver state, and replication slots

Audit

ToolDescription
get_audit_logsRetrieve logged MCP tool calls for a given date
list_audit_filesList available audit log files

Recommended Workflow

Start by discovering schemas:

text
get_schema()get_schema(schema='public')

Run safe read queries:

text
execute_query(query='SELECT * FROM orders ORDER BY created_at DESC')

Preview risky writes:

text
analyze_impact(query='DELETE FROM sessions WHERE last_active < now() - interval ''30 days''')

Check health and maintenance:

text
database_health()maintenance_analysis(schema='public')query_performance()

Most analysis tools accept a schema parameter:

text
maintenance_analysis(schema='public')  -> analyze one schemamaintenance_analysis(schema='all')     -> analyze every schemaget_schema(format='mermaid')           -> generate an ERD diagram

Supported Databases

ProviderConnection method
Local PostgreSQLDATABASE_URL or individual DB_* variables
Docker PostgreSQLExplicit variables or connect(discover=true)
AWS RDS / AuroraDirect URL, SSH tunnel, or AWS Secrets Manager
SupabasePooler connection string from Dashboard settings
NeonConnection string from Console connection details
Railway / Render / Fly.ioProvider connection string
Any PostgreSQL hostStandard PostgreSQL URL

Configuration

Choose one connection method.

env
# Full URLDATABASE_URL=postgresql://user:pass@host:5432/db
# Or individual variablesDB_HOST=localhostDB_PORT=5432DB_USER=postgresDB_PASSWORD=secretDB_NAME=mydbDB_SSLMODE=prefer
# Or AWS Secrets ManagerAWS_SECRET_NAME=my-rds-secretAWS_REGION=us-west-2

You can also connect at runtime:

text
connect(url='postgresql://user:pass@host:5432/db')connect(host='localhost', user='postgres', password='secret', database='mydb')connect(aws_secret_name='my-secret', aws_region='us-west-2')

Key settings:

VariableDefaultDescription
DBEAST_DEFAULT_ROW_LIMIT100Max rows returned by execute_query
DBEAST_QUERY_TIMEOUT300Query execution timeout in seconds
DBEAST_COMMAND_TIMEOUT300SQL command timeout in seconds
DBEAST_SSL_VERIFYtrueSet false for SSH tunnels where certificates do not match localhost
DBEAST_SCHEMA_CACHE_TTL60Schema cache TTL in seconds, 0 disables caching
DBEAST_AUDIT_ENABLEDtrueLog MCP tool calls
DBEAST_AUDIT_DIRlogs/mcp_auditAudit log directory

See SETUP.md for the complete configuration reference.


Safety Model

Query typeWhat DBeast does
SELECTExecutes with automatic row limits
INSERT / UPDATE / DELETENever executed; returns an impact preview
DROP / TRUNCATENever executed; reports affected objects and risk

Formatted and JSON responses use a consistent wrapper:

json
{  "success": true,  "data": { "...": "..." },  "meta": {    "connected": true,    "source": "tool"  }}

Audit Logging

DBeast logs MCP tool calls for accountability and debugging.

env
DBEAST_AUDIT_ENABLED=trueDBEAST_AUDIT_DIR=logs/mcp_audit

Audit files are stored as daily markdown files and include timestamps, tool names, durations, masked parameters, truncated responses, and errors.


Development

bash
pip install -e ".[dev]"pre-commit installpytest tests/ -vruff check src/ tests/ruff format src/ tests/

Start the optional local PostgreSQL test database:

bash
docker compose up -d postgres

Legacy Compose:

bash
docker-compose up -d postgres

Documentation

  • SETUP.md - Full client setup, connection scenarios, configuration, and troubleshooting
  • CONTRIBUTING.md - Development setup, tests, style, commits, and PR process
  • CODE_OF_CONDUCT.md - Community guidelines

License

MIT

来源:README.md,提交 18f6dcf

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v2.0.2最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分