MCP server for accessing Nuuly PostgreSQL database resources
Project description
Nuuly Postgres MCP Server
MCP server for accessing Nuuly PostgreSQL database resources through Claude Desktop and other AI assistants.
Contents
src/nuuly_postgres_mcp_server/: Package source code__init__.py: Package initialization__main__.py: Entry point for running as a moduleserver.py: Main server implementation
pyproject.toml: Package configuration.env.example: Example environment variables
Purpose
This MCP server provides PostgreSQL database connectivity functionality for the broader MCP platform. It connects to CloudSQL Postgres non-prod databases and enables AI code editors to:
- Understand all tables and schemas
- Run queries against the non-prod database
- List available databases and their aliases
Installation
Option 1: Install from PyPI
pip install nuuly-postgres-mcp-server
Option 2: Install from Source
- Clone the repository:
git clone <REPO_URL>
cd r15-mcp/mcp_servers/postgres-mcp
- Install the package in development mode:
pip install -e .
Local Development
Prerequisites
- Python 3.8 or higher
- pip package manager
Setup
- Clone the repository:
git clone <REPO_URL>
cd r15-mcp/mcp_servers/postgres-mcp
- Create and activate a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies:
pip install -e .
- Set up environment variables:
cp .env.example .env
# Edit .env with your actual values
Environment Variables
The following environment variables can be set to customize the behavior of the MCP server:
CLOUD_RUN_PROXY_URL: URL of the Cloud Run DB Proxy (default: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app")DB_PROXY_API_KEY: API key for authenticating with the Cloud Run DB Proxy (required)LOG_LEVEL: Logging level (default: INFO)
Usage
For Claude Desktop
Add this configuration to your Claude Desktop settings:
{
"Nuuly Postgres MCP": {
"command": "nuuly-postgres-mcp",
"env": {
"PYTHONUNBUFFERED": "1",
"CLOUD_RUN_PROXY_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
"DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
Command Line Usage
nuuly-postgres-mcp
Deployment
As a GCP Cloud Function
This MCP server is designed to be deployed as a GCP Cloud Function with the following parameters:
- Project:
rental-dev - Region:
us-east4 - Serverless VPC Connector:
rental-vpc-connector - Entry point:
main.py
The function connects to CloudSQL PostgreSQL using private IP (10.171.208.52) and uses environment variables for DB credentials.
environment_variables:
CLOUD_RUN_PROXY_URL: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app"
DB_PROXY_API_KEY: "${DB_PROXY_API_KEY}"
LOG_LEVEL: "INFO"
Building and Publishing the Package
To build and publish the package to PyPI:
python -m build
python -m twine upload dist/*
Available Tools
This MCP server provides the following tools to AI assistants:
run_query: Execute SQL queries against the databaseget_schema: Get database schema informationlist_databases: List available databases
Troubleshooting
Connection Issues with Claude Desktop
If you experience connection issues with Claude Desktop (client transport closing), ensure that:
- The server is running with the correct URL for the Cloud Run DB Proxy
- The API key is correctly set and properly escaped in any curl commands (use single quotes)
- The server is properly handling heartbeat and shutdown messages
- The JSON-RPC initialization response includes
keepAlive: trueandsupportsHeartbeats: true
Example curl command to test the API:
curl -X GET "https://postgres-mcp-toolbox-186512416539.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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nuuly_postgres_mcp_server-1.0.0.tar.gz.
File metadata
- Download URL: nuuly_postgres_mcp_server-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dcebd70265fad53db98b52e3badac0a12447e84123a17eca31c1278e117d1eb
|
|
| MD5 |
6edcf1af90852b89a7fa0d8a6d85fcbf
|
|
| BLAKE2b-256 |
4547c4163a8d79c5e6a3e03ac20a61c56639fc2ddb12cd402939717a8200dcb3
|
File details
Details for the file nuuly_postgres_mcp_server-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nuuly_postgres_mcp_server-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
504a85d7e6cbf3722ec42228e7240a3f2acbc6910c4a8100841c8927851e0f4b
|
|
| MD5 |
351379ac53c92f16d2e40b9d197c8224
|
|
| BLAKE2b-256 |
7da887628ad5e99523605b8368d90d47f8599dd2057759e20bb4f5fa1035dc2e
|