postgres-mcp
Allows interaction with a PostgreSQL database, providing tools for query execution, schema inspection, CRUD operations, and security features.
Click on "Install 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-mcpshow 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
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
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/chenz4027/postgres-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server