
Postgres Scout Mcp
io.github.bluwork由 GitHub 账号 bluwork 发布v1.0.3更新于 Oct 24, 2026
Scout your PostgreSQL databases with AI - safety features, monitoring, and data quality
概览
让助手通过 38 个工具检查、诊断并可选地修改 PostgreSQL 数据库,涵盖健康度、性能与数据质量。
- 可以做什么
- Postgres Scout 将助手连接到 PostgreSQL 数据库,提供 38 个工具,分为探索、查询、诊断、优化、监控、数据质量、关系、时间序列、导出和写入等类别。它可以列出数据库、模式和表,描述表结构,执行并解释查询,给出整体健康评分,检测异常和表膨胀,建议索引和分区,检查锁和实时活动,查找重复行、缺失值和孤立记录,并将表导出为 CSV、JSON、JSONL 或 SQL。safeUpdate、safeDelete、safeInsert 等写入工具带有试运行预览和行数限制。
- 适用场景
- 适合助手需要回答 PostgreSQL 数据库运维问题的场景,例如哪些表存在膨胀、哪些查询较慢、数据是否有重复或孤立行。适合希望默认只读探索、并在需要时另开实例进行受控写入的开发者和 DBA。
- 运行要求
- 通过 stdio 在本地运行,通常使用 npx postgres-scout-mcp 并附带 PostgreSQL 连接字符串作为参数。需要 Node.js 以及访问数据库的网络。可选环境变量用于配置查询超时、结果行数上限、速率限制、连接池大小和日志。部分诊断功能(如 getSlowQueries)需要 pg_stat_statements 扩展。
安装
在 SourceWeft 中
- 打开 控制台中的 Postgres Scout Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Postgres Scout MCP
Scout your PostgreSQL databases with AI - A production-ready Model Context Protocol server with built-in safety features, monitoring, and data quality tools.
What You Get
You ask:
"How healthy is my production database? Any urgent issues?"
Postgres Scout returns:
Overall Health Score: 78/100
Component Breakdown
Issues Found
- HIGH — Table
ordershas 34% bloat (2.1 GB wasted). VACUUM FULL recommended. - MEDIUM — 3 unused indexes on
sessionsconsuming 890 MB. - LOW — Cache hit ratio for
analytics_eventsis 71% (target: >90%).
Recommendations
- Run
VACUUM FULL ordersduring maintenance window - Drop unused indexes:
idx_sessions_legacy,idx_sessions_old_token,idx_sessions_temp - Consider adding
analytics_eventsto shared_buffers or partitioning by date
That's getHealthScore — one of 38 tools covering exploration, diagnostics, optimization, monitoring, data quality, and safe writes.
Quick Start
Claude Code
Then ask: "Show me the largest tables and whether they have any bloat issues."
Claude Desktop
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
Cursor / VS Code
Add to your MCP settings:
Read-Only vs Read-Write
The server runs in read-only mode by default. For write operations, run a separate instance:
- postgres-scout-readonly: Safe exploration, no risk of data modification
- postgres-scout-readwrite: Write operations when explicitly needed
Tools
Explore — understand your database
listDatabases— databases the user has access togetDatabaseStats— size, cache hit ratio, connection infolistSchemas— all schemas in the current databaselistTables— tables with size and row statisticsdescribeTable— columns, constraints, indexes, and more
Query — run and analyze
executeQuery— run SELECT queries (or writes in read-write mode)explainQuery— EXPLAIN plans for performance analysisoptimizeQuery— optimization recommendations for a specific query
Diagnose — find problems before they find you
getHealthScore— overall health score with component breakdowndetectAnomalies— anomalies in performance, connections, and dataanalyzeTableBloat— bloat analysis for VACUUM planninggetSlowQueries— slow query analysis (requires pg_stat_statements)suggestVacuum— VACUUM recommendations based on dead tuples and bloat
Optimize — make it faster
suggestIndexes— missing index recommendations from query patternssuggestPartitioning— partitioning strategies for large tablesgetIndexUsage— identify unused or underused indexes
Monitor — watch it live
getCurrentActivity— active queries and connectionsanalyzeLocks— lock contention and blocking queriesgetLiveMetrics— real-time metrics over a time windowgetHottestTables— tables with highest activitygetTableMetrics— comprehensive per-table I/O and scan stats
Data Quality — trust your data
findDuplicates— duplicate rows by column combinationfindMissingValues— NULL analysis across columnsfindOrphans— orphaned records with invalid foreign keyscheckConstraintViolations— test constraints before adding themanalyzeTypeConsistency— type inconsistencies in text columns
Relationships — follow the connections
exploreRelationships— multi-hop foreign key traversalanalyzeForeignKeys— foreign key health and performance
Time Series — temporal analysis
findRecent— rows within a time windowanalyzeTimeSeries— window functions and anomaly detectiondetectSeasonality— seasonal pattern detection
Export — get data out
exportTable— CSV, JSON, JSONL, or SQLgenerateInsertStatements— INSERT statements for migration
Write (read-write only) — safe modifications
previewUpdate/previewDelete— see what would change before committingsafeUpdate— UPDATE with dry-run, row limits, empty WHERE protectionsafeDelete— DELETE with dry-run, row limits, empty WHERE protectionsafeInsert— INSERT with validation, batching, ON CONFLICT support
Security
- Read-only by default — write operations must be explicitly enabled
- All queries use parameterized values
- SQL injection prevention with input validation and pattern detection
- Identifier sanitization for table/column names
- Rate limiting on all operations
- Query timeouts to prevent long-running queries
- Response size limits to prevent memory exhaustion
Examples
"What are the largest tables and do they have bloat?"
"Find duplicate emails in the users table."
"Which queries are slowest and how can I speed them up?"
"Show me what's happening on the database right now."
"Find orphaned orders that reference deleted customers."
Configuration
CLI flags: --read-only (default), --read-write, --mode <mode>
Logging
File logging is disabled by default. Set ENABLE_LOGGING=true to enable. Two log files are created in LOG_DIR:
- tool-usage.log — every tool call with timestamp, name, and arguments
- error.log — errors with stack traces
Connection strings are automatically redacted in all output.
Development
License
Apache-2.0
来源:README.md,提交 3cb6fa3
工具
0版本历史
1- v1.0.3最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分