postgres-mcp
Allows interaction with a PostgreSQL database, providing tools for query execution, schema inspection, CRUD operations, and security features.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@postgres-mcp show me the users table schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PostgreSQL MCP Server
A Model Context Protocol (MCP) server that provides PostgreSQL database access to Claude Desktop. This server enables Claude to interact with your local PostgreSQL database through a secure, well-defined interface.
Features
Query Execution: Execute custom SQL queries with parameterization for security
Schema Inspection: List tables, describe table structures, and get schema overviews
CRUD Operations: Create, read, update, and delete records with structured interfaces
Security Features: Input validation, parameterized queries, and connection pooling
Type Safety: Full TypeScript implementation with Zod validation
Related MCP server: PostgreSQL MCP Server
Available Tools
postgres_query - Execute custom SQL queries
postgres_list_tables - List all tables in the database
postgres_describe_table - Get detailed table information
postgres_schema_overview - Get complete database schema
postgres_select - Select data with filtering and pagination
postgres_insert - Insert new records
postgres_update - Update existing records
postgres_delete - Delete records
Installation
Clone this repository:
git clone <repository-url> cd postgres-mcpInstall dependencies:
npm installBuild the project:
npm run build
Configuration
PostgreSQL Setup
Ensure your PostgreSQL server is running on localhost:5432 with a database named postgres. The default configuration assumes you can connect without username/password (trust authentication).
Claude Desktop Configuration
Add the following to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\\Claude\\claude_desktop_config.json
{
"mcpServers": {
"postgres": {
"command": "node",
"args": ["/path/to/postgres-mcp/dist/index.js"]
}
}
}Replace /path/to/postgres-mcp with the actual path to your project directory.
Usage
Start Claude Desktop
The PostgreSQL MCP server will automatically connect to your database
Use the available tools through Claude's interface
Example Queries
"Show me all tables in the database"
"Describe the users table"
"Select all users where age > 25"
"Insert a new user with name 'John' and email 'john@example.com'"
Security Considerations
All queries use parameterized statements to prevent SQL injection
Input validation using Zod schemas
Connection pooling with timeouts
No hardcoded credentials (uses environment/default connection)
Development
# Development mode (watch for changes)
npm run dev
# Build
npm run build
# Lint
npm run lint
# Test
npm testTroubleshooting
Connection Issues: Ensure PostgreSQL is running and accessible
Permission Errors: Check database user permissions
Tool Not Found: Verify Claude Desktop configuration path
License
MIT
Available Tools
8 toolspostgres_deleteB
Delete records from a table
Inputs: where (required), table_name (required).
postgres_describe_tableA
Get detailed information about a specific table including columns, data types, and constraints
Inputs: table_name (required).
postgres_insertB
Insert a new record into a table
Inputs: data (required), table_name (required).
postgres_list_tablesA
List all tables in the public schema of the PostgreSQL database
Inputs: no named parameters.
postgres_queryA
Execute a custom SQL query against the PostgreSQL database. Use this for complex queries, joins, aggregations, and any SQL operation not covered by other tools.
Inputs: query (required), parameters.
postgres_schema_overviewA
Get a complete overview of the database schema including all tables and their columns
Inputs: no named parameters.
postgres_selectA
Select data from a table with optional filtering, sorting, and pagination
Inputs: table_name (required), limit, where, offset, +3 more.
postgres_updateC
Update existing records in a table
Inputs: data (required), where (required), table_name (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Tools are mostly distinct: CRUD operations are clear, and schema tools are differentiated by scope. Some overlap exists between list_tables and schema_overview, and between select and query, but descriptions clarify when to use each.
All tools share the 'postgres_' prefix and use snake_case, but the pattern is not perfectly uniform: most are verb_noun (e.g., list_tables, describe_table), while query, select, insert, etc. are bare verbs and schema_overview is a noun phrase. This is a minor deviation.
With 8 tools, the server is well-scoped for PostgreSQL interaction. It covers metadata inspection, data manipulation, and custom querying without unnecessary bloat or thinness.
The tool set covers the full data lifecycle: schema inspection (list_tables, schema_overview, describe_table), CRUD (select, insert, update, delete), and a custom query tool for anything else. No obvious gaps for typical database use cases.
Maintenance
Related MCP Connectors
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
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.
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides authenticated access to PostgreSQL databases for Claude AI, enabling users to browse database tables, discover schemas, and execute custom SQL queries through natural language interaction.MIT
- AlicenseNot gradedqualityDmaintenanceEnables Claude to interact with PostgreSQL databases by executing SQL queries, exploring schemas, and monitoring database health. It provides tools for data manipulation and schema management via a secure SSE connection.333 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables Claude Desktop to interact with PostgreSQL databases through natural language for schema exploration, data analysis, and query execution. Users can search schemas, describe tables, and perform read or write operations without needing to write manual SQL.-
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to query and manage local PostgreSQL databases through SQL execution and schema exploration tools. It supports both read-only queries and write operations including table creation and data modification via natural language.32 npm1ISC