postgres-mcp
Enables Claude to interact with a local PostgreSQL database through SQL queries, schema inspection, and CRUD operations.
README
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-mcp -
Install dependencies:
npm install -
Build 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 test
Troubleshooting
- Connection Issues: Ensure PostgreSQL is running and accessible
- Permission Errors: Check database user permissions
- Tool Not Found: Verify Claude Desktop configuration path
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.