home / mcp / postgres scout mcp server

Postgres Scout MCP Server

Provides read-only and optional read-write access to PostgreSQL databases with safety, logging, and rate limiting.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "bluwork-postgres-scout-mcp": {
      "command": "node",
      "args": [
        "/absolute/path/to/postgres-scout-mcp/dist/index.js",
        "postgresql://localhost:5432/production"
      ],
      "env": {
        "LOG_DIR": "./logs",
        "LOG_LEVEL": "info",
        "DATABASE_URL": "postgresql://localhost:5432/production",
        "PGIDLETIMEOUT": "10000",
        "PGMAXPOOLSIZE": "10",
        "PGMINPOOLSIZE": "2",
        "QUERY_TIMEOUT": "30000",
        "MAX_RESULT_ROWS": "10000",
        "ENABLE_RATE_LIMIT": "true",
        "RATE_LIMIT_WINDOW_MS": "60000",
        "RATE_LIMIT_MAX_REQUESTS": "100"
      }
    }
  }
}

You are running a Postgres Scout MCP Server that safely exposes PostgreSQL interactions to AI assistants. It provides read-only exploration by default, strong SQL injection prevention through parameterized queries, rate limiting, and comprehensive logging to help you analyze and maintain databases without risking your data.

How to use

To use the MCP server with a compatible client, start in read-only mode to safely inspect your databases. You can switch to read-write mode when you explicitly need to perform data modifications.

Start in read-only mode with a direct connection string. You can later enable write operations by adding a flag to the startup command.

How to install

Prerequisites you need installed on your machine before running the MCP server:

  • Node.js (recommended LTS version)
  • pnpm (preferred)

Step-by-step setup:

# Install dependencies
pnpm install

# Build the MCP server
pnpm build

Run in read-only mode by default

Launch the server in read-only mode by providing a PostgreSQL connection URL. This mode is safe for production database exploration.

node dist/index.js postgresql://localhost:5432/mydb

Run in read-write mode

If you need write access, start the server with the read-write flag. This mode requires explicit permission to modify data.

node dist/index.js --read-write postgresql://localhost:5432/mydb

Available tools

listDatabases

List all databases the user has access to.

getDatabaseStats

Get comprehensive statistics about a database.

listSchemas

List all schemas in the connected database.

listTables

List tables with detailed information in a given schema.

describeTable

Provide detailed information about a table, including columns, constraints, and indexes.

executeQuery

Execute a SELECT query with safety checks and optional timeout and row limit.

explainQuery

Analyze query performance with EXPLAIN ANALYZE, with read-only mode forcing analyze to false.

getHealthScore

Calculate an overall health score for the connected database.

getSlowQueries

Analyze slow queries using pg_stat_statements (extension required).