- Home
- MCP servers
- PostgreSQL
PostgreSQL
- javascript
0
GitHub Stars
javascript
Language
3 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
PostgreSQL MCP Server lets Claude access and manage your PostgreSQL database through a secure, SSE-based MCP interface. It enables you to run SQL queries, inspect schemas and tables, and monitor database statistics directly from Claude or Claude.ai. This setup is designed to be straightforward and extensible, so you can safely connect Claude to your live database and perform common data tasks with ease.
How to use
You connect an MCP client to the server using either a local Claude Desktop configuration or the remote Claude.ai MCP integration. Once connected, you can run ad hoc SQL queries, list tables with size estimates, describe table schemas, list available schemas, and retrieve database statistics. The tools are designed to give Claude full access to your PostgreSQL database through the SSE endpoint, so you can perform data exploration, modification, and administration tasks directly from your MCP-enabled client.
How to install
Prerequisites: you need Docker and Docker Compose installed on your host machine.
- Copy the example environment file and customize credentials for your PostgreSQL connection.
cp .env.example .env
nano .env # fill in your Postgres credentials
Key settings to configure in the environment file include the PostgreSQL host. If PostgreSQL runs on the same Docker host, you can reference host.docker.internal or the host's LAN IP. If PostgreSQL runs in another Docker container or network, specify the container name and ensure the Docker network is defined in your compose file.
- Build and start the MCP server in detached mode.
docker compose up -d --build
- Verify the server is healthy. You should see a response indicating a healthy connection to the database.
curl http://localhost:3000/health
# → {"status":"ok","database":"connected","sessions":0}
Additional sections
Connect Claude Desktop to the MCP server by editing your Claude Desktop configuration file to include the server as an SSE endpoint.
{
"mcpServers": {
"power-db": {
"transport": "sse",
"url": "http://YOUR_SERVER_IP:3000/sse"
}
}
}
Replace YOUR_SERVER_IP with the Docker host’s IP address. After saving the configuration, restart Claude Desktop. The tools will appear in Claude's tool panel and you can start issuing SQL-related actions directly from Claude.
If you use Claude.ai for remote MCP access, add the MCP server there using the same SSE URL. The URL should be reachable from the internet or via a tunnel (for example, ngrok) if your server is behind a firewall.
Networking tips include ensuring proper host resolution when PostgreSQL runs on the same host or in another Docker network. If PostgreSQL runs on the host, you can use host.docker.internal (Linux may require extra_hosts) or the host’s LAN IP. If PostgreSQL runs in another Docker container, reference the container name and ensure the network is included in docker-compose.yml.
For monitoring, you can view server logs to diagnose startup or runtime issues.
Stop and restart commands are straightforward.
docker compose down
docker compose up -d
Available tools
execute_query
Run any SQL statement, including SELECT, INSERT, UPDATE, DELETE, and DDL commands.
list_tables
List tables with size estimates and row counts to understand data distribution.
describe_table
Provide a full schema for a table, including columns, indexes, and foreign keys.
list_schemas
List all schemas present in the connected PostgreSQL database.
get_db_stats
Retrieve database statistics such as size, connections, cache hit ratio, and top tables.