PostgreSQL MCP Server
@aadarshjain
About PostgreSQL MCP Server
MCP Server (STDIO) for PostgreSQL Database
Basic information
Config
Add this server to your MCP-compatible client using the configuration below.
{
"mcpServers": {
"postgres-mcp-server-aadarshjain": {
"command": "python",
"args": [
"server.py",
"postgresql://username:password@hostname:port/database"
]
}
}
}Tools
No tools detected
We auto-extract tools from the README. The maintainer can list them under a ## Tools heading to populate this section.
Overview
What is PostgreSQL MCP Server?
A Model Context Protocol (MCP) server implementation that connects to a PostgreSQL database and exposes data discovery and querying capabilities as MCP tools. It is intended for developers and AI assistants (e.g., Claude Desktop) to explore database structure and query data through a standardized interface.
How to use PostgreSQL MCP Server?
Run the server by providing a PostgreSQL connection string: python server.py postgresql://username:password@hostname:port/database. For integration with Claude Desktop, add the configuration to the Claude Desktop config file (located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows, or ~/.config/Claude/claude_desktop_config.json on Linux) and restart the app.
Key features of PostgreSQL MCP Server
- Connect to any PostgreSQL database using a connection string.
- Execute custom SELECT queries with structured results.
- List all tables in the connected database.
- Get detailed schema information for any table.
- Filter database records with simple equality conditions.
- Get database statistics including size, table count, and largest tables.
Use cases of PostgreSQL MCP Server
- Explore database tables and schemas through an AI assistant.
- Query data from PostgreSQL using natural language in Claude Desktop.
- Retrieve database statistics for monitoring or reporting.
- Filter records based on simple criteria without writing raw SQL.
- Integrate PostgreSQL exploration into MCP-compatible applications.
FAQ from PostgreSQL MCP Server
What types of SQL queries are allowed?
Only SELECT queries are permitted to prevent database modifications. Connection credentials are provided via the command line and not stored.
What are the requirements to run the server?
Python 3.7+ and the required packages (mcp, pg8000, sqlalchemy) must be installed. A virtual environment is recommended.
How do I configure this server for Claude Desktop?
Add a JSON entry to the Claude Desktop config file (see the config file locations above) with the command pointing to the absolute path of server.py and the connection string as an argument. Then restart Claude Desktop.
Where is the Claude Desktop configuration file located?
On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows: %APPDATA%\Claude\claude_desktop_config.json. On Linux: ~/.config/Claude/claude_desktop_config.json.
Why does the server crash or fail to connect?
Check that the PostgreSQL connection string is correct, the server allows connections from your client, and all dependencies are installed. Use absolute paths for the Python executable if needed.
More Databases MCP servers
Elasticsearch MCP Server
elasticClickHouse MCP Server
ClickHouseConnect ClickHouse to your AI assistants.
Dbhub
bytebaseZero-dependency, token-efficient database MCP server for Postgres, MySQL, SQL Server, MariaDB, SQLite.
Snowflake MCP Server
isaacwassermanSail MCP Server for Spark SQL
lakehqDrop-in Apache Spark replacement written in Rust, unifying batch processing, stream processing, and compute-intensive AI workloads.
Comments