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

概覽

AI 產生的概覽

讓助理透過 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 擴充功能。
安裝前請注意
伺服器預設為唯讀,但讀寫實例可以對所連資料庫執行 UPDATE、DELETE 與 INSERT;應指向開發資料庫而非正式環境。寫入工具提供試跑與資料列數上限,但仍會修改資料。連線字串以命令列參數傳入,可能出現在行程清單中。啟用檔案記錄會把工具呼叫與參數寫入磁碟,不過連線字串會被遮蔽。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Postgres Scout Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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.

[npm] [License]

What You Get

You ask:

"How healthy is my production database? Any urgent issues?"

Postgres Scout returns:


Overall Health Score: 78/100

Component Breakdown

ComponentScoreStatus
Cache Performance94/100Healthy
Index Efficiency82/100Good
Table Bloat61/100Needs Attention
Connection Usage75/100Fair

Issues Found

  • HIGH — Table orders has 34% bloat (2.1 GB wasted). VACUUM FULL recommended.
  • MEDIUM — 3 unused indexes on sessions consuming 890 MB.
  • LOW — Cache hit ratio for analytics_events is 71% (target: >90%).

Recommendations

  • Run VACUUM FULL orders during maintenance window
  • Drop unused indexes: idx_sessions_legacy, idx_sessions_old_token, idx_sessions_temp
  • Consider adding analytics_events to 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

bash
claude mcp add postgres-scout -- npx -y postgres-scout-mcp postgresql://localhost:5432/mydb

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):

json
{  "mcpServers": {    "postgres-scout": {      "command": "npx",      "args": ["-y", "postgres-scout-mcp", "postgresql://localhost:5432/mydb"],      "type": "stdio"    }  }}
Cursor / VS Code

Add to your MCP settings:

json
{  "postgres-scout": {    "command": "npx",    "args": ["-y", "postgres-scout-mcp", "postgresql://localhost:5432/mydb"]  }}
Read-Only vs Read-Write

The server runs in read-only mode by default. For write operations, run a separate instance:

json
{  "mcpServers": {    "postgres-scout-readonly": {      "command": "npx",      "args": ["-y", "postgres-scout-mcp", "--read-only", "postgresql://localhost:5432/production"],      "type": "stdio"    },    "postgres-scout-readwrite": {      "command": "npx",      "args": ["-y", "postgres-scout-mcp", "--read-write", "postgresql://localhost:5432/development"],      "type": "stdio"    }  }}
  • 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 to
  • getDatabaseStats — size, cache hit ratio, connection info
  • listSchemas — all schemas in the current database
  • listTables — tables with size and row statistics
  • describeTable — columns, constraints, indexes, and more

Query — run and analyze

  • executeQuery — run SELECT queries (or writes in read-write mode)
  • explainQuery — EXPLAIN plans for performance analysis
  • optimizeQuery — optimization recommendations for a specific query

Diagnose — find problems before they find you

  • getHealthScore — overall health score with component breakdown
  • detectAnomalies — anomalies in performance, connections, and data
  • analyzeTableBloat — bloat analysis for VACUUM planning
  • getSlowQueries — 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 patterns
  • suggestPartitioning — partitioning strategies for large tables
  • getIndexUsage — identify unused or underused indexes

Monitor — watch it live

  • getCurrentActivity — active queries and connections
  • analyzeLocks — lock contention and blocking queries
  • getLiveMetrics — real-time metrics over a time window
  • getHottestTables — tables with highest activity
  • getTableMetrics — comprehensive per-table I/O and scan stats

Data Quality — trust your data

  • findDuplicates — duplicate rows by column combination
  • findMissingValues — NULL analysis across columns
  • findOrphans — orphaned records with invalid foreign keys
  • checkConstraintViolations — test constraints before adding them
  • analyzeTypeConsistency — type inconsistencies in text columns

Relationships — follow the connections

  • exploreRelationships — multi-hop foreign key traversal
  • analyzeForeignKeys — foreign key health and performance

Time Series — temporal analysis

  • findRecent — rows within a time window
  • analyzeTimeSeries — window functions and anomaly detection
  • detectSeasonality — seasonal pattern detection

Export — get data out

  • exportTable — CSV, JSON, JSONL, or SQL
  • generateInsertStatements — INSERT statements for migration

Write (read-write only) — safe modifications

  • previewUpdate / previewDelete — see what would change before committing
  • safeUpdate — UPDATE with dry-run, row limits, empty WHERE protection
  • safeDelete — DELETE with dry-run, row limits, empty WHERE protection
  • safeInsert — 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?"

listTables({ schema: "public" })analyzeTableBloat({ schema: "public", minSizeMb: 100 })

"Find duplicate emails in the users table."

findDuplicates({ table: "users", columns: ["email"] })

"Which queries are slowest and how can I speed them up?"

getSlowQueries({ minDurationMs: 100, limit: 10 })suggestIndexes({ schema: "public" })

"Show me what's happening on the database right now."

getCurrentActivity()getLiveMetrics({ metrics: ["queries", "connections", "cache"], duration: 30000, interval: 1000 })getHottestTables({ limit: 5, orderBy: "seq_scan" })

"Find orphaned orders that reference deleted customers."

findOrphans({ table: "orders", foreignKey: "customer_id", referenceTable: "customers", referenceColumn: "id" })

Configuration

VariableDefaultDescription
QUERY_TIMEOUT30000Query timeout in milliseconds
MAX_RESULT_ROWS10000Maximum rows returned per query
ENABLE_RATE_LIMITtrueEnable rate limiting
RATE_LIMIT_MAX_REQUESTS100Requests per window
RATE_LIMIT_WINDOW_MS60000Rate limit window (ms)
PGMAXPOOLSIZE10Connection pool max size
PGMINPOOLSIZE2Connection pool min size
PGIDLETIMEOUT10000Idle connection timeout (ms)
ENABLE_LOGGINGfalseEnable file logging
LOG_DIR./logsLog file directory
LOG_LEVELinfoLog verbosity: debug, info, warn, error

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

bash
git clone https://github.com/bluwork/postgres-scout-mcp.gitcd postgres-scout-mcppnpm installpnpm buildpnpm test

License

Apache-2.0

來源:README.md,提交 3cb6fa3

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.0.3最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分