PostgreSQL MCP
MCP server for PostgreSQL database operations with schema inspection and query execution.
автор: Anthropic
curl -fsSL https://vibebaza.com/i/postgres | bash
The PostgreSQL MCP server provides Claude with read-only access to PostgreSQL databases for data analysis and schema inspection.
Installation
npm install -g @modelcontextprotocol/server-postgres
Configuration
Add to your Claude Code settings:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost:5432/database"
]
}
}
}
Available Tools
query
Execute a read-only SQL query.
query(sql: string): QueryResult
Note: Only SELECT queries are allowed for safety.
list_tables
List all tables in the database.
list_tables(): TableInfo[]
describe_table
Get schema information for a table.
describe_table(table_name: string): ColumnInfo[]
Resources
The server exposes database schema as resources:
postgres://schema- Full database schemapostgres://tables/{table_name}- Individual table schemas
Security Considerations
- Read-only access by default
- Connection string should use appropriate credentials
- Consider using a read-replica for production
- Limit accessible schemas if needed
Usage Example
Claude, please analyze the users table and show me
the distribution of users by signup month.
Claude will:
1. Inspect the table schema
2. Write an appropriate SQL query
3. Execute and present the results