# PostgreSQL MCP Server — Database Queries for AI > MCP server for PostgreSQL database access. Run read-only SQL queries, inspect schemas, list tables, and analyze data directly from Claude Code or Cursor. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use ```json { "mcpServers": { "postgres": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@localhost:5432/mydb"] } } } ``` --- ## Intro Connect your AI coding tools directly to PostgreSQL databases. Inspect schemas, run queries, analyze data, and generate reports — all through natural language. Read-only by default for safety. **Best for**: Data analysis, schema exploration, query debugging, report generation **Works with**: Claude Code, Cursor, Gemini CLI --- ## Capabilities - **Schema inspection**: List tables, columns, types, constraints, indexes - **SQL queries**: Run SELECT queries with results returned as structured data - **Data analysis**: Ask questions about your data in natural language - **Query building**: Describe what you need, get optimized SQL --- ## Safety - Read-only mode by default (SELECT only) - Connection string passed as argument, not stored - No DDL operations unless explicitly enabled --- ### FAQ **Q: What is PostgreSQL MCP Server?** A: MCP server for PostgreSQL database access. Run read-only SQL queries, inspect schemas, list tables, and analyze data directly from Claude Code or Cursor. **Q: How do I install PostgreSQL MCP Server?** A: Check the Quick Use section above for step-by-step installation instructions. Most assets can be set up in under 2 minutes. ## Source & Thanks > Created by [Anthropic](https://github.com/modelcontextprotocol). Licensed under MIT. > [modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers) --- Source: https://tokrepo.com/en/workflows/1ca69a22-de42-4722-af49-3d0869362e2d Author: MCP Hub