# postgres-scout-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/bluwork/postgres-scout-mcp  
**GitHub Stars:** 0  
**npm Downloads (last month):** 294  
**Views:** 3  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/postgres-scout-mcp

## Description
Scout your PostgreSQL databases with AI - safety features, monitoring, and data quality

## Tools
Capabilities this server exposes over MCP:

- **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
- **executeQuery** — run SELECT queries (or writes in read-write mode)
- **explainQuery** — EXPLAIN plans for performance analysis
- **optimizeQuery** — optimization recommendations for a specific query
- **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
- **suggestIndexes** — missing index recommendations from query patterns
- **suggestPartitioning** — partitioning strategies for large tables
- **getIndexUsage** — identify unused or underused indexes
- **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
- **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
- **exploreRelationships** — multi-hop foreign key traversal
- **analyzeForeignKeys** — foreign key health and performance
- **findRecent** — rows within a time window
- **analyzeTimeSeries** — window functions and anomaly detection
- **detectSeasonality** — seasonal pattern detection
- **exportTable** — CSV, JSON, JSONL, or SQL
- **generateInsertStatements** — INSERT statements for migration
- **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

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "postgres-scout-mcp": {
    "command": "npx",
    "args": ["-y","postgres-scout-mcp","read-only","postgresql://localhost:5432/postgres"]
  }
}
```

## Documentation

## What postgres-scout-mcp MCP server does

postgres-scout-mcp MCP server gives an AI client structured access to PostgreSQL database information and analysis operations. It can enumerate accessible databases, schemas, and tables; inspect columns, constraints, and indexes; and return table size and row statistics. The query tools support SELECT statements by default, with write statements available when the server is explicitly started in read-write mode.

Its diagnostic capabilities cover database health, cache performance, connection information, table bloat, slow queries, index usage, locks, active sessions, and table activity. Data-quality tools can look for duplicate rows, missing values, orphaned records, constraint violations, inconsistent text-column types, and foreign-key issues. Relationship and time-based analysis are also supported through foreign-key traversal, recent-row searches, and time-series analysis.

## How it works

The server is launched with `npx` and a PostgreSQL connection string, then exposes MCP tools to a compatible client. Exploration and analysis calls query PostgreSQL metadata and statistics. For example, an agent can combine `listTables` with `analyzeTableBloat`, or use `getSlowQueries` followed by `suggestIndexes` when investigating performance.

The default operating mode is read-only. A read-write instance must be selected explicitly with `--read-write`; the documented setup uses separate instances for production read-only access and development writes. Write tools include query execution in read-write mode and guarded update, delete, and insert operations with dry-run or validation features as applicable.

## Setup and configuration

Install and run the package through `npx` with a database URL:

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

Claude Code can register the command with `claude mcp add`. Claude Desktop, Cursor, and VS Code can configure it as a stdio MCP server with `npx` and the same connection-string argument.

Configuration is available through environment variables for query timeout, maximum result rows, rate limiting, connection-pool sizing, logging, and log verbosity. File logging is disabled unless `ENABLE_LOGGING=true`; when enabled, usage and error logs are written under `LOG_DIR`. Connection strings are redacted from output.

## Tools and capabilities

The postgres-scout-mcp MCP server groups its tools around practical database work:

- Explore databases, schemas, tables, columns, constraints, and indexes.
- Execute and explain queries, then request query-specific optimization recommendations.
- Review health scores, anomalies, bloat, slow queries, vacuum needs, and index opportunities.
- Monitor current activity, locks, live metrics, hottest tables, and per-table I/O or scan statistics.
- Check duplicates, NULLs, orphaned rows, constraint readiness, type consistency, and foreign keys.
- Trace multi-hop relationships and analyze recent or time-series data.

## Limitations and notes

`getSlowQueries` requires PostgreSQL's `pg_stat_statements` extension. Query results are bounded by the configured maximum row count, and queries have a configurable timeout. Rate limiting is enabled by default and can be configured.

Read-only mode prevents write operations through the server, but write access is available if the process is intentionally started in read-write mode. The documented safety controls include parameterized values, input and identifier validation, rate limiting, query timeouts, and response-size limits.

_Full upstream README: https://allmcps.com/mcp/postgres-scout-mcp/readme_

