pg-inspector-mcp
Provides tools for safely inspecting PostgreSQL database schemas, searching tables and columns, describing table structures and relationships, executing bounded read-only queries, and generating query execution plans.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
pg-inspector-mcp
A secure, host-agnostic MCP (Model Context Protocol) server for PostgreSQL. It allows AI coding assistants (like VS Code Copilot, Claude Code, and Cursor) to safely inspect your database schema, understand relationships, and execute read-only queries.
Features
Secure by Design: Database credentials are never exposed to the LLM. Managed securely via a local CLI companion.
Token-Efficient: Merged introspection tools (
describe_table) provide columns, constraints, and indexes in a single call.Smart Search: Find tables and columns instantly without dumping the entire schema into the context window.
Safe Execution: Bounded, read-only SQL execution with automatic result truncation.
Performance Insights: Generate JSON query plans to help the AI optimize slow queries.
Related MCP server: Postgres Scout MCP
Installation & Setup
1. Install the CLI
npm install -g @neb23x/pg-inspector-mcp2. Configure your Database
Run the interactive setup command to securely store your connection string locally:
pg-inspector-mcp add-dbThis creates a secure config file at ~/.pg-inspector/connections.json.
3. Connect to your MCP Host
For VS Code (Copilot):
Add this to your .vscode/mcp.json:
{
"servers": {
"pg-inspector": {
"command": "npx",
"args": ["-p", "@neb23x/pg-inspector-mcp@latest", "pg-inspector-server"]
}
}
}For Claude Desktop / Cursor: Add this to your host's MCP configuration file:
{
"mcpServers": {
"pg-inspector": {
"command": "npx",
"args": ["-p", "@neb23x/pg-inspector-mcp@latest", "pg-inspector-server"]
}
}
}Available Tools
Tool | Description |
| Lists configured database aliases. |
| Changes the active database context. |
| High-level schema and context metadata. |
| Search for tables/columns by keyword. |
| Deep dive: columns, types, PKs, FKs, and indexes. |
| Run bounded, read-only SELECT queries. |
| Get JSON query execution plans. |
Security Best Practices
For production environments, do not use a superuser. Create a dedicated read-only role for the MCP server:
CREATE ROLE mcp_reader WITH LOGIN PASSWORD 'secure_password';
GRANT CONNECT ON DATABASE your_db TO mcp_reader;
GRANT USAGE ON SCHEMA public TO mcp_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_reader;Development & Contributing
Clone the repo and run
npm install.Add your local database to the CLI:
npx tsx src/cli.ts.Run the integration tests (requires Docker):
npm run test.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Query your Postgres from ChatGPT or Claude without exposing the database or handing over credentials. Run npx boltschema connect next to your database and it dials out over HTTPS — no inbound firewall rule, no open port, works with localhost and VPC-private databases. Read-only is enforced by a SQL guard, a Postgres READ ONLY transaction, and a scoped role generated for you.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases using natural language queries, providing secure read-only access to database schemas and SQL translation capabilities.69 npmISC
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to safely explore, analyze, and maintain PostgreSQL databases with read-only mode by default, SQL injection prevention, query performance analysis, and optional write operations.87 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceSecurely connect AI assistants to PostgreSQL databases with read-only access, schema discovery, querying, and performance analysis tools.12 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query PostgreSQL, inspect schemas, and explain queries, designed for local and development databases with read-only safety by default.38 npmMIT