
PostgreSQL
Read-only database access with schema inspection
Send to Your Agent
Copy this prompt and paste it into Claude, Cursor, or any MCP client to install instantly.
Install the PostgreSQL MCP server for me.
Server: PostgreSQL
Description: Read-only database access with schema inspection
Install command: npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@host/db
Environment variables needed:
- DATABASE_URL: PostgreSQL connection string (required)
GitHub: https://github.com/modelcontextprotocol/servers-archived/tree/main/src/postgres
Please install this MCP server and confirm when ready. Paste into any AI agent with MCP support — works with Claude Desktop, Cursor, Cline, and more.
Quick Install
Config file: ~/Library/Application Support/Claude/claude_desktop_config.json
- Open Claude Desktop app
- Go to Settings → Developer → Edit Config
- Paste the config below into the file
- Restart Claude Desktop
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:pass@host/db"
],
"env": {
"DATABASE_URL": "postgresql://user:password@localhost:5432/mydb"
}
}
}
} Add this to your ~/Library/Application Support/Claude/claude_desktop_config.json
Installation Methods
npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@host/dbTools (3)
query Execute a read-only SQL query against the database
execute Execute a SQL command (INSERT, UPDATE, DELETE)
get_schema Get the database schema including tables and columns
Environment Variables
DATABASE_URL RequiredPostgreSQL connection string
postgresql://user:password@localhost:5432/mydb| Name | Description | Required | Example |
|---|---|---|---|
| DATABASE_URL | PostgreSQL connection string | Required | postgresql://user:password@localhost:5432/mydb |
Compatibility
About
A Model Context Protocol server that provides access to PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.
Key Features
- Schema inspection — View tables, columns, types, and relationships
- Read-only queries — Execute SELECT statements safely
- Write operations — Execute INSERT, UPDATE, DELETE when enabled
- Connection via URL — Simple connection string configuration
Security
By default, the server operates in read-only mode. Write operations must be explicitly enabled. Always use a dedicated database user with minimal permissions.
Use Cases
- Database exploration — "Show me all tables and their columns"
- Query generation — "Write a query to find all users who signed up last week"
- Data analysis — "What's the average order value by month?"
- Schema design — "Suggest indexes for this query pattern"
- Debugging — "Find all records where status is null"
Related Resources
SQLite
MCP ServerDatabase interaction and business intelligence capabilities
Database Migration Planner
PromptPlan zero-downtime database migrations with rollback strategies and data integrity checks.
Database Optimization Expert
SkillAnalyze and optimize database performance with query tuning, indexing strategies, schema design, and data modeling best practices for SQL and NoSQL databases.
Artificial Intelligence
GlossaryThe broad field of creating machines that can perform tasks requiring human-like intelligence, such as reasoning, learning, and perception.
Redis
MCP ServerInteract with Redis key-value stores
Compare LLM Pricing
This server works with Claude, GPT-4o, and other models. Compare API costs side-by-side to find the cheapest option for your workflow.