Nuuly Postgres MCP Server
This MCP server provides AI code editors with access to PostgreSQL databases through the Model Context Protocol (MCP). It allows AI assistants to understand database schemas, tables, and to run queries against non-prod PostgreSQL databases. This implementation acts as a client that forwards requests to a remote PostgreSQL MCP server running on Google Cloud Run.
Features
- List available PostgreSQL databases and their aliases
- Get detailed schema information for all tables in a database
- Run SQL queries against PostgreSQL databases
Prerequisites
- Python 3.8+
Installation
Step 1: Install Python (Mac Users)
Option A: Using Homebrew (Recommended)
- Open Terminal
- Check if Homebrew is installed by typing:
brew --version - If Homebrew is not installed, install it by copying and pasting this command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Once Homebrew is installed, install Python:
brew install python
Option B: Download Python directly
- Go to python.org
- Download Python 3.8 or newer
- Run the installer and follow the prompts
Step 2: Install the Postgres MCP Server
- Open Terminal
- Install the server by running:
pip install nuuly-postgres-mcp-server
- Wait for the installation to complete
Step 3: Find the Installation Path
You'll need to find where the server was installed to configure Claude:
- In Terminal, run:
which nuuly-postgres-mcp - This will show something like:
/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp - Copy this path - you'll need it for the next step
Step 4: Configure Claude Desktop
- Open Claude Desktop application
- Find the "MCP Servers" section
- Click "Edit Config" or open the configuration file
- Add the following configuration, replacing the path with your actual path from Step 3:
{
"nuuly-postgres-mcp": {
"command": "/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp",
"env": {
"PYTHONUNBUFFERED": "1",
"POSTGRES_MCP_SERVER_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
"DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
Environment URLs:
- Dev (rental-dev):
https://postgres-mcp-toolbox-186512416539.us-east4.run.app - Staging (rental-staging):
https://postgres-mcp-toolbox-526194183507.us-east4.run.app
Use POSTGRES_MCP_SERVER_URL to switch between dev and staging.
Step 5: Restart Claude
- Restart Claude Desktop
- The PostgreSQL tools should now be available
Available Tools
The server provides the following tools, which are forwarded to the remote PostgreSQL MCP server:
1. list_databases
Lists all databases and their aliases accessible via the Cloud Run DB Proxy.
list_databases()
Example response:
{
"databases": [
{
"name": "orders",
"aliases": ["orders_db", "order_system"],
"instance": "rental-dev:us-east4:orders-db"
},
{
"name": "products",
"aliases": ["product_db"],
"instance": "rental-dev:us-east4:product-db"
}
]
}
2. get_schema
Gets the schema of all tables in the specified database.
get_schema(database="orders")
Example response:
{
"tables": [
{
"name": "orders",
"columns": [
{
"name": "id",
"type": "integer",
"nullable": false,
"primary_key": true
},
{
"name": "customer_id",
"type": "integer",
"nullable": false,
"foreign_key": {
"table": "customers",
"column": "id"
}
},
{
"name": "created_at",
"type": "timestamp",
"nullable": false
}
]
}
],
"success": true
}
3. run_query
Runs a SQL query against the database and returns results.
run_query(database="orders", sql="SELECT * FROM orders LIMIT 10")
Example response:
{
"columns": ["id", "customer_id", "created_at"],
"rows": [
[1001, 5001, "2023-01-15T10:30:00Z"],
[1002, 5002, "2023-01-15T11:45:00Z"]
],
"count": 2,
"success": true
}
Backend Deployment
The Postgres MCP client forwards requests to a Cloud Run DB Proxy. The backend is deployed via Terraform in infra_tools/postgres_mcp_server/terraform/:
- Dev:
rental-dev,config/dev.yaml, Cloud SQL private IPs - Staging:
rental-staging,config/staging.yaml, Cloud SQL + AlloyDB private IPs - Region:
us-east4 - VPC Connector:
rental-vpc-connector
See infra_tools/postgres_mcp_server/README.md for build and deploy instructions.
Troubleshooting
Connection Issues with Claude Desktop
If you experience connection issues with Claude Desktop, ensure that:
- The server is running with the correct URL for the Cloud Run DB Proxy
- The API key is correctly set in your configuration
- The server is properly handling heartbeat and shutdown messages
- The JSON-RPC initialization response includes
keepAlive: trueandsupportsHeartbeats: true
Example curl commands to test the API:
# Dev
curl -X GET "https://postgres-mcp-toolbox-186512416539.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
# Staging
curl -X GET "https://postgres-mcp-toolbox-526194183507.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
Common Issues
- Missing API Key: Ensure the
DB_PROXY_API_KEYenvironment variable is set - Permission Errors: Verify that your API key has the necessary permissions
- Timeout Errors: Check network latency or increase the timeout settings in the code
- Heartbeat Issues: Ensure the MCP server properly implements heartbeat handlers
Metadata
Release files for nuuly-postgres-mcp-server 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nuuly_postgres_mcp_server-1.0.2.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nuuly_postgres_mcp_server-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / nuuly_postgres_mcp_server-1.0.2.tar.gz
| Download URL | nuuly_postgres_mcp_server-1.0.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68ebd0a96fa986dd8c0781d42308a778f2b1f5437aa148b70213c1371ed0f8dd
|
|
BLAKE2b-256 checksum How to use checksums |
6f6a974128321f77859b9e9c3043ab253584413148147736fb5ba2d5a0d45658
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / nuuly_postgres_mcp_server-1.0.2-py3-none-any.whl
| Download URL | nuuly_postgres_mcp_server-1.0.2-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbcd87495947b5764cd0f96fda82c085b6c52d25c9ffc40ab42fcd53c7da9431
|
|
BLAKE2b-256 checksum How to use checksums |
6838c4b1912b36c8738e7416927860778da187ad8ad4e9c93d36985d3f5f108e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for nuuly-postgres-mcp-server 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.