nuuly-postgres-mcp-server 1.0.0__tar.gz → 1.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. nuuly_postgres_mcp_server-1.0.2/PKG-INFO +233 -0
  2. nuuly_postgres_mcp_server-1.0.2/README.md +219 -0
  3. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/pyproject.toml +1 -1
  4. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server/__init__.py +1 -1
  5. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server/server.py +7 -7
  6. nuuly_postgres_mcp_server-1.0.2/src/nuuly_postgres_mcp_server.egg-info/PKG-INFO +233 -0
  7. nuuly_postgres_mcp_server-1.0.0/PKG-INFO +0 -179
  8. nuuly_postgres_mcp_server-1.0.0/README.md +0 -165
  9. nuuly_postgres_mcp_server-1.0.0/src/nuuly_postgres_mcp_server.egg-info/PKG-INFO +0 -179
  10. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/setup.cfg +0 -0
  11. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server/__main__.py +0 -0
  12. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server.egg-info/SOURCES.txt +0 -0
  13. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server.egg-info/dependency_links.txt +0 -0
  14. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server.egg-info/entry_points.txt +0 -0
  15. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server.egg-info/requires.txt +0 -0
  16. {nuuly_postgres_mcp_server-1.0.0 → nuuly_postgres_mcp_server-1.0.2}/src/nuuly_postgres_mcp_server.egg-info/top_level.txt +0 -0
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: nuuly-postgres-mcp-server
3
+ Version: 1.0.2
4
+ Summary: MCP server for accessing Nuuly PostgreSQL database resources
5
+ Author-email: Nuuly Engineering <engineering@nuuly.com>
6
+ License: Proprietary
7
+ Project-URL: Homepage, https://github.com/urbn/r15-mcp
8
+ Project-URL: Repository, https://github.com/urbn/r15-mcp
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: fastmcp>=2.2.1
12
+ Requires-Dist: httpx>=0.24.0
13
+ Requires-Dist: psycopg2-binary>=2.9.5
14
+
15
+ # Nuuly Postgres MCP Server
16
+
17
+ 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.
18
+
19
+ ## Features
20
+
21
+ - List available PostgreSQL databases and their aliases
22
+ - Get detailed schema information for all tables in a database
23
+ - Run SQL queries against PostgreSQL databases
24
+
25
+ ## Prerequisites
26
+
27
+ - Python 3.8+
28
+
29
+ ## Installation
30
+
31
+ ### Step 1: Install Python (Mac Users)
32
+
33
+ **Option A: Using Homebrew (Recommended)**
34
+
35
+ 1. Open Terminal
36
+ 2. Check if Homebrew is installed by typing: `brew --version`
37
+ 3. If Homebrew is not installed, install it by copying and pasting this command:
38
+ ```bash
39
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
40
+ ```
41
+ 4. Once Homebrew is installed, install Python:
42
+ ```bash
43
+ brew install python
44
+ ```
45
+
46
+ **Option B: Download Python directly**
47
+
48
+ 1. Go to [python.org](https://www.python.org/downloads/)
49
+ 2. Download Python 3.8 or newer
50
+ 3. Run the installer and follow the prompts
51
+
52
+ ### Step 2: Install the Postgres MCP Server
53
+
54
+ 1. Open Terminal
55
+ 2. Install the server by running:
56
+ ```bash
57
+ pip install nuuly-postgres-mcp-server
58
+ ```
59
+ 3. Wait for the installation to complete
60
+
61
+ ### Step 3: Find the Installation Path
62
+
63
+ You'll need to find where the server was installed to configure Claude:
64
+
65
+ 1. In Terminal, run:
66
+ ```bash
67
+ which nuuly-postgres-mcp
68
+ ```
69
+ 2. This will show something like:
70
+ `/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp`
71
+ 3. **Copy this path** - you'll need it for the next step
72
+
73
+ ### Step 4: Configure Claude Desktop
74
+
75
+ 1. Open Claude Desktop application
76
+ 2. Find the "MCP Servers" section
77
+ 3. Click "Edit Config" or open the configuration file
78
+ 4. Add the following configuration, replacing the path with your actual path from Step 3:
79
+
80
+ ```json
81
+ {
82
+ "nuuly-postgres-mcp": {
83
+ "command": "/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp",
84
+ "env": {
85
+ "PYTHONUNBUFFERED": "1",
86
+ "POSTGRES_MCP_SERVER_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
87
+ "DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ **Environment URLs:**
94
+ - **Dev** (rental-dev): `https://postgres-mcp-toolbox-186512416539.us-east4.run.app`
95
+ - **Staging** (rental-staging): `https://postgres-mcp-toolbox-526194183507.us-east4.run.app`
96
+
97
+ Use `POSTGRES_MCP_SERVER_URL` to switch between dev and staging.
98
+
99
+ ### Step 5: Restart Claude
100
+
101
+ 1. Restart Claude Desktop
102
+ 2. The PostgreSQL tools should now be available
103
+
104
+ ## Available Tools
105
+
106
+ The server provides the following tools, which are forwarded to the remote PostgreSQL MCP server:
107
+
108
+ ### 1. list_databases
109
+
110
+ Lists all databases and their aliases accessible via the Cloud Run DB Proxy.
111
+
112
+ ```python
113
+ list_databases()
114
+ ```
115
+
116
+ Example response:
117
+ ```json
118
+ {
119
+ "databases": [
120
+ {
121
+ "name": "orders",
122
+ "aliases": ["orders_db", "order_system"],
123
+ "instance": "rental-dev:us-east4:orders-db"
124
+ },
125
+ {
126
+ "name": "products",
127
+ "aliases": ["product_db"],
128
+ "instance": "rental-dev:us-east4:product-db"
129
+ }
130
+ ]
131
+ }
132
+ ```
133
+
134
+ ### 2. get_schema
135
+
136
+ Gets the schema of all tables in the specified database.
137
+
138
+ ```python
139
+ get_schema(database="orders")
140
+ ```
141
+
142
+ Example response:
143
+ ```json
144
+ {
145
+ "tables": [
146
+ {
147
+ "name": "orders",
148
+ "columns": [
149
+ {
150
+ "name": "id",
151
+ "type": "integer",
152
+ "nullable": false,
153
+ "primary_key": true
154
+ },
155
+ {
156
+ "name": "customer_id",
157
+ "type": "integer",
158
+ "nullable": false,
159
+ "foreign_key": {
160
+ "table": "customers",
161
+ "column": "id"
162
+ }
163
+ },
164
+ {
165
+ "name": "created_at",
166
+ "type": "timestamp",
167
+ "nullable": false
168
+ }
169
+ ]
170
+ }
171
+ ],
172
+ "success": true
173
+ }
174
+ ```
175
+
176
+ ### 3. run_query
177
+
178
+ Runs a SQL query against the database and returns results.
179
+
180
+ ```python
181
+ run_query(database="orders", sql="SELECT * FROM orders LIMIT 10")
182
+ ```
183
+
184
+ Example response:
185
+ ```json
186
+ {
187
+ "columns": ["id", "customer_id", "created_at"],
188
+ "rows": [
189
+ [1001, 5001, "2023-01-15T10:30:00Z"],
190
+ [1002, 5002, "2023-01-15T11:45:00Z"]
191
+ ],
192
+ "count": 2,
193
+ "success": true
194
+ }
195
+ ```
196
+
197
+ ## Backend Deployment
198
+
199
+ 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/`:
200
+
201
+ - **Dev**: `rental-dev`, `config/dev.yaml`, Cloud SQL private IPs
202
+ - **Staging**: `rental-staging`, `config/staging.yaml`, Cloud SQL + AlloyDB private IPs
203
+ - Region: `us-east4`
204
+ - VPC Connector: `rental-vpc-connector`
205
+
206
+ See `infra_tools/postgres_mcp_server/README.md` for build and deploy instructions.
207
+
208
+ ## Troubleshooting
209
+
210
+ ### Connection Issues with Claude Desktop
211
+
212
+ If you experience connection issues with Claude Desktop, ensure that:
213
+
214
+ 1. The server is running with the correct URL for the Cloud Run DB Proxy
215
+ 2. The API key is correctly set in your configuration
216
+ 3. The server is properly handling heartbeat and shutdown messages
217
+ 4. The JSON-RPC initialization response includes `keepAlive: true` and `supportsHeartbeats: true`
218
+
219
+ Example curl commands to test the API:
220
+ ```bash
221
+ # Dev
222
+ curl -X GET "https://postgres-mcp-toolbox-186512416539.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
223
+
224
+ # Staging
225
+ curl -X GET "https://postgres-mcp-toolbox-526194183507.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
226
+ ```
227
+
228
+ ### Common Issues
229
+
230
+ - **Missing API Key**: Ensure the `DB_PROXY_API_KEY` environment variable is set
231
+ - **Permission Errors**: Verify that your API key has the necessary permissions
232
+ - **Timeout Errors**: Check network latency or increase the timeout settings in the code
233
+ - **Heartbeat Issues**: Ensure the MCP server properly implements heartbeat handlers
@@ -0,0 +1,219 @@
1
+ # Nuuly Postgres MCP Server
2
+
3
+ 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.
4
+
5
+ ## Features
6
+
7
+ - List available PostgreSQL databases and their aliases
8
+ - Get detailed schema information for all tables in a database
9
+ - Run SQL queries against PostgreSQL databases
10
+
11
+ ## Prerequisites
12
+
13
+ - Python 3.8+
14
+
15
+ ## Installation
16
+
17
+ ### Step 1: Install Python (Mac Users)
18
+
19
+ **Option A: Using Homebrew (Recommended)**
20
+
21
+ 1. Open Terminal
22
+ 2. Check if Homebrew is installed by typing: `brew --version`
23
+ 3. If Homebrew is not installed, install it by copying and pasting this command:
24
+ ```bash
25
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
26
+ ```
27
+ 4. Once Homebrew is installed, install Python:
28
+ ```bash
29
+ brew install python
30
+ ```
31
+
32
+ **Option B: Download Python directly**
33
+
34
+ 1. Go to [python.org](https://www.python.org/downloads/)
35
+ 2. Download Python 3.8 or newer
36
+ 3. Run the installer and follow the prompts
37
+
38
+ ### Step 2: Install the Postgres MCP Server
39
+
40
+ 1. Open Terminal
41
+ 2. Install the server by running:
42
+ ```bash
43
+ pip install nuuly-postgres-mcp-server
44
+ ```
45
+ 3. Wait for the installation to complete
46
+
47
+ ### Step 3: Find the Installation Path
48
+
49
+ You'll need to find where the server was installed to configure Claude:
50
+
51
+ 1. In Terminal, run:
52
+ ```bash
53
+ which nuuly-postgres-mcp
54
+ ```
55
+ 2. This will show something like:
56
+ `/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp`
57
+ 3. **Copy this path** - you'll need it for the next step
58
+
59
+ ### Step 4: Configure Claude Desktop
60
+
61
+ 1. Open Claude Desktop application
62
+ 2. Find the "MCP Servers" section
63
+ 3. Click "Edit Config" or open the configuration file
64
+ 4. Add the following configuration, replacing the path with your actual path from Step 3:
65
+
66
+ ```json
67
+ {
68
+ "nuuly-postgres-mcp": {
69
+ "command": "/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp",
70
+ "env": {
71
+ "PYTHONUNBUFFERED": "1",
72
+ "POSTGRES_MCP_SERVER_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
73
+ "DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ **Environment URLs:**
80
+ - **Dev** (rental-dev): `https://postgres-mcp-toolbox-186512416539.us-east4.run.app`
81
+ - **Staging** (rental-staging): `https://postgres-mcp-toolbox-526194183507.us-east4.run.app`
82
+
83
+ Use `POSTGRES_MCP_SERVER_URL` to switch between dev and staging.
84
+
85
+ ### Step 5: Restart Claude
86
+
87
+ 1. Restart Claude Desktop
88
+ 2. The PostgreSQL tools should now be available
89
+
90
+ ## Available Tools
91
+
92
+ The server provides the following tools, which are forwarded to the remote PostgreSQL MCP server:
93
+
94
+ ### 1. list_databases
95
+
96
+ Lists all databases and their aliases accessible via the Cloud Run DB Proxy.
97
+
98
+ ```python
99
+ list_databases()
100
+ ```
101
+
102
+ Example response:
103
+ ```json
104
+ {
105
+ "databases": [
106
+ {
107
+ "name": "orders",
108
+ "aliases": ["orders_db", "order_system"],
109
+ "instance": "rental-dev:us-east4:orders-db"
110
+ },
111
+ {
112
+ "name": "products",
113
+ "aliases": ["product_db"],
114
+ "instance": "rental-dev:us-east4:product-db"
115
+ }
116
+ ]
117
+ }
118
+ ```
119
+
120
+ ### 2. get_schema
121
+
122
+ Gets the schema of all tables in the specified database.
123
+
124
+ ```python
125
+ get_schema(database="orders")
126
+ ```
127
+
128
+ Example response:
129
+ ```json
130
+ {
131
+ "tables": [
132
+ {
133
+ "name": "orders",
134
+ "columns": [
135
+ {
136
+ "name": "id",
137
+ "type": "integer",
138
+ "nullable": false,
139
+ "primary_key": true
140
+ },
141
+ {
142
+ "name": "customer_id",
143
+ "type": "integer",
144
+ "nullable": false,
145
+ "foreign_key": {
146
+ "table": "customers",
147
+ "column": "id"
148
+ }
149
+ },
150
+ {
151
+ "name": "created_at",
152
+ "type": "timestamp",
153
+ "nullable": false
154
+ }
155
+ ]
156
+ }
157
+ ],
158
+ "success": true
159
+ }
160
+ ```
161
+
162
+ ### 3. run_query
163
+
164
+ Runs a SQL query against the database and returns results.
165
+
166
+ ```python
167
+ run_query(database="orders", sql="SELECT * FROM orders LIMIT 10")
168
+ ```
169
+
170
+ Example response:
171
+ ```json
172
+ {
173
+ "columns": ["id", "customer_id", "created_at"],
174
+ "rows": [
175
+ [1001, 5001, "2023-01-15T10:30:00Z"],
176
+ [1002, 5002, "2023-01-15T11:45:00Z"]
177
+ ],
178
+ "count": 2,
179
+ "success": true
180
+ }
181
+ ```
182
+
183
+ ## Backend Deployment
184
+
185
+ 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/`:
186
+
187
+ - **Dev**: `rental-dev`, `config/dev.yaml`, Cloud SQL private IPs
188
+ - **Staging**: `rental-staging`, `config/staging.yaml`, Cloud SQL + AlloyDB private IPs
189
+ - Region: `us-east4`
190
+ - VPC Connector: `rental-vpc-connector`
191
+
192
+ See `infra_tools/postgres_mcp_server/README.md` for build and deploy instructions.
193
+
194
+ ## Troubleshooting
195
+
196
+ ### Connection Issues with Claude Desktop
197
+
198
+ If you experience connection issues with Claude Desktop, ensure that:
199
+
200
+ 1. The server is running with the correct URL for the Cloud Run DB Proxy
201
+ 2. The API key is correctly set in your configuration
202
+ 3. The server is properly handling heartbeat and shutdown messages
203
+ 4. The JSON-RPC initialization response includes `keepAlive: true` and `supportsHeartbeats: true`
204
+
205
+ Example curl commands to test the API:
206
+ ```bash
207
+ # Dev
208
+ curl -X GET "https://postgres-mcp-toolbox-186512416539.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
209
+
210
+ # Staging
211
+ curl -X GET "https://postgres-mcp-toolbox-526194183507.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
212
+ ```
213
+
214
+ ### Common Issues
215
+
216
+ - **Missing API Key**: Ensure the `DB_PROXY_API_KEY` environment variable is set
217
+ - **Permission Errors**: Verify that your API key has the necessary permissions
218
+ - **Timeout Errors**: Check network latency or increase the timeout settings in the code
219
+ - **Heartbeat Issues**: Ensure the MCP server properly implements heartbeat handlers
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nuuly-postgres-mcp-server"
7
- version = "1.0.0"
7
+ version = "1.0.2"
8
8
  description = "MCP server for accessing Nuuly PostgreSQL database resources"
9
9
  readme = "README.md"
10
10
  authors = [{name = "Nuuly Engineering", email = "engineering@nuuly.com"}]
@@ -4,5 +4,5 @@ Nuuly Postgres MCP Server package.
4
4
 
5
5
  from .server import run
6
6
 
7
- __version__ = "1.0.0"
7
+ __version__ = "1.0.2"
8
8
  __all__ = ["run"]
@@ -13,7 +13,7 @@ from typing import Any, Dict, Optional
13
13
  logger = logging.getLogger(__name__)
14
14
 
15
15
  # Configuration for Cloud Run DB Proxy
16
- CLOUD_RUN_PROXY_URL = os.getenv("CLOUD_RUN_PROXY_URL", "https://www.example.com")
16
+ POSTGRES_MCP_SERVER_URL = os.getenv("POSTGRES_MCP_SERVER_URL", "https://www.example.com")
17
17
  db_proxy_api_key = os.getenv("DB_PROXY_API_KEY")
18
18
 
19
19
  # Import FastMCP
@@ -45,13 +45,13 @@ async def run_query(ctx: Context, database: str, sql: str) -> str:
45
45
  "sql": sql
46
46
  }
47
47
  headers = {"X-API-KEY": db_proxy_api_key}
48
- url = f"{CLOUD_RUN_PROXY_URL}/query"
48
+ url = f"{POSTGRES_MCP_SERVER_URL}/query"
49
49
 
50
50
  logger.info(f"Executing query on database: {database}")
51
51
  async with httpx.AsyncClient(timeout=15) as client:
52
52
  response = await client.post(url, json=payload, headers=headers)
53
53
  response.raise_for_status()
54
- return response.json()
54
+ return json.dumps(response.json())
55
55
  except httpx.HTTPStatusError as e:
56
56
  logger.error(f"HTTPStatusError: status={e.response.status_code}, body={e.response.text}")
57
57
  return json.dumps({"error": f"Cloud Run proxy error: {e.response.status_code}", "details": e.response.text})
@@ -80,13 +80,13 @@ async def get_schema(ctx: Context, database: str) -> str:
80
80
 
81
81
  payload = {"database": database}
82
82
  headers = {"X-API-KEY": db_proxy_api_key}
83
- url = f"{CLOUD_RUN_PROXY_URL}/schema"
83
+ url = f"{POSTGRES_MCP_SERVER_URL}/schema"
84
84
 
85
85
  logger.info(f"Fetching schema for database: {database}")
86
86
  async with httpx.AsyncClient(timeout=15) as client:
87
87
  response = await client.post(url, json=payload, headers=headers)
88
88
  response.raise_for_status()
89
- return response.json()
89
+ return json.dumps(response.json())
90
90
  except httpx.HTTPStatusError as e:
91
91
  logger.error(f"HTTPStatusError: status={e.response.status_code}, body={e.response.text}")
92
92
  return json.dumps({"error": f"Cloud Run proxy error: {e.response.status_code}", "details": e.response.text})
@@ -110,13 +110,13 @@ async def list_databases(ctx: Context) -> str:
110
110
  return json.dumps({"error": "DB_PROXY_API_KEY environment variable not set"})
111
111
 
112
112
  headers = {"X-API-KEY": db_proxy_api_key}
113
- url = f"{CLOUD_RUN_PROXY_URL}/databases"
113
+ url = f"{POSTGRES_MCP_SERVER_URL}/databases"
114
114
 
115
115
  logger.info("Listing available databases")
116
116
  async with httpx.AsyncClient(timeout=15) as client:
117
117
  response = await client.get(url, headers=headers)
118
118
  response.raise_for_status()
119
- return response.json()
119
+ return json.dumps(response.json())
120
120
  except httpx.HTTPStatusError as e:
121
121
  logger.error(f"HTTPStatusError: status={e.response.status_code}, body={e.response.text}")
122
122
  return json.dumps({"error": f"Cloud Run proxy error: {e.response.status_code}", "details": e.response.text})
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: nuuly-postgres-mcp-server
3
+ Version: 1.0.2
4
+ Summary: MCP server for accessing Nuuly PostgreSQL database resources
5
+ Author-email: Nuuly Engineering <engineering@nuuly.com>
6
+ License: Proprietary
7
+ Project-URL: Homepage, https://github.com/urbn/r15-mcp
8
+ Project-URL: Repository, https://github.com/urbn/r15-mcp
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: fastmcp>=2.2.1
12
+ Requires-Dist: httpx>=0.24.0
13
+ Requires-Dist: psycopg2-binary>=2.9.5
14
+
15
+ # Nuuly Postgres MCP Server
16
+
17
+ 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.
18
+
19
+ ## Features
20
+
21
+ - List available PostgreSQL databases and their aliases
22
+ - Get detailed schema information for all tables in a database
23
+ - Run SQL queries against PostgreSQL databases
24
+
25
+ ## Prerequisites
26
+
27
+ - Python 3.8+
28
+
29
+ ## Installation
30
+
31
+ ### Step 1: Install Python (Mac Users)
32
+
33
+ **Option A: Using Homebrew (Recommended)**
34
+
35
+ 1. Open Terminal
36
+ 2. Check if Homebrew is installed by typing: `brew --version`
37
+ 3. If Homebrew is not installed, install it by copying and pasting this command:
38
+ ```bash
39
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
40
+ ```
41
+ 4. Once Homebrew is installed, install Python:
42
+ ```bash
43
+ brew install python
44
+ ```
45
+
46
+ **Option B: Download Python directly**
47
+
48
+ 1. Go to [python.org](https://www.python.org/downloads/)
49
+ 2. Download Python 3.8 or newer
50
+ 3. Run the installer and follow the prompts
51
+
52
+ ### Step 2: Install the Postgres MCP Server
53
+
54
+ 1. Open Terminal
55
+ 2. Install the server by running:
56
+ ```bash
57
+ pip install nuuly-postgres-mcp-server
58
+ ```
59
+ 3. Wait for the installation to complete
60
+
61
+ ### Step 3: Find the Installation Path
62
+
63
+ You'll need to find where the server was installed to configure Claude:
64
+
65
+ 1. In Terminal, run:
66
+ ```bash
67
+ which nuuly-postgres-mcp
68
+ ```
69
+ 2. This will show something like:
70
+ `/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp`
71
+ 3. **Copy this path** - you'll need it for the next step
72
+
73
+ ### Step 4: Configure Claude Desktop
74
+
75
+ 1. Open Claude Desktop application
76
+ 2. Find the "MCP Servers" section
77
+ 3. Click "Edit Config" or open the configuration file
78
+ 4. Add the following configuration, replacing the path with your actual path from Step 3:
79
+
80
+ ```json
81
+ {
82
+ "nuuly-postgres-mcp": {
83
+ "command": "/Users/yourname/Library/Python/3.12/bin/nuuly-postgres-mcp",
84
+ "env": {
85
+ "PYTHONUNBUFFERED": "1",
86
+ "POSTGRES_MCP_SERVER_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
87
+ "DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ **Environment URLs:**
94
+ - **Dev** (rental-dev): `https://postgres-mcp-toolbox-186512416539.us-east4.run.app`
95
+ - **Staging** (rental-staging): `https://postgres-mcp-toolbox-526194183507.us-east4.run.app`
96
+
97
+ Use `POSTGRES_MCP_SERVER_URL` to switch between dev and staging.
98
+
99
+ ### Step 5: Restart Claude
100
+
101
+ 1. Restart Claude Desktop
102
+ 2. The PostgreSQL tools should now be available
103
+
104
+ ## Available Tools
105
+
106
+ The server provides the following tools, which are forwarded to the remote PostgreSQL MCP server:
107
+
108
+ ### 1. list_databases
109
+
110
+ Lists all databases and their aliases accessible via the Cloud Run DB Proxy.
111
+
112
+ ```python
113
+ list_databases()
114
+ ```
115
+
116
+ Example response:
117
+ ```json
118
+ {
119
+ "databases": [
120
+ {
121
+ "name": "orders",
122
+ "aliases": ["orders_db", "order_system"],
123
+ "instance": "rental-dev:us-east4:orders-db"
124
+ },
125
+ {
126
+ "name": "products",
127
+ "aliases": ["product_db"],
128
+ "instance": "rental-dev:us-east4:product-db"
129
+ }
130
+ ]
131
+ }
132
+ ```
133
+
134
+ ### 2. get_schema
135
+
136
+ Gets the schema of all tables in the specified database.
137
+
138
+ ```python
139
+ get_schema(database="orders")
140
+ ```
141
+
142
+ Example response:
143
+ ```json
144
+ {
145
+ "tables": [
146
+ {
147
+ "name": "orders",
148
+ "columns": [
149
+ {
150
+ "name": "id",
151
+ "type": "integer",
152
+ "nullable": false,
153
+ "primary_key": true
154
+ },
155
+ {
156
+ "name": "customer_id",
157
+ "type": "integer",
158
+ "nullable": false,
159
+ "foreign_key": {
160
+ "table": "customers",
161
+ "column": "id"
162
+ }
163
+ },
164
+ {
165
+ "name": "created_at",
166
+ "type": "timestamp",
167
+ "nullable": false
168
+ }
169
+ ]
170
+ }
171
+ ],
172
+ "success": true
173
+ }
174
+ ```
175
+
176
+ ### 3. run_query
177
+
178
+ Runs a SQL query against the database and returns results.
179
+
180
+ ```python
181
+ run_query(database="orders", sql="SELECT * FROM orders LIMIT 10")
182
+ ```
183
+
184
+ Example response:
185
+ ```json
186
+ {
187
+ "columns": ["id", "customer_id", "created_at"],
188
+ "rows": [
189
+ [1001, 5001, "2023-01-15T10:30:00Z"],
190
+ [1002, 5002, "2023-01-15T11:45:00Z"]
191
+ ],
192
+ "count": 2,
193
+ "success": true
194
+ }
195
+ ```
196
+
197
+ ## Backend Deployment
198
+
199
+ 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/`:
200
+
201
+ - **Dev**: `rental-dev`, `config/dev.yaml`, Cloud SQL private IPs
202
+ - **Staging**: `rental-staging`, `config/staging.yaml`, Cloud SQL + AlloyDB private IPs
203
+ - Region: `us-east4`
204
+ - VPC Connector: `rental-vpc-connector`
205
+
206
+ See `infra_tools/postgres_mcp_server/README.md` for build and deploy instructions.
207
+
208
+ ## Troubleshooting
209
+
210
+ ### Connection Issues with Claude Desktop
211
+
212
+ If you experience connection issues with Claude Desktop, ensure that:
213
+
214
+ 1. The server is running with the correct URL for the Cloud Run DB Proxy
215
+ 2. The API key is correctly set in your configuration
216
+ 3. The server is properly handling heartbeat and shutdown messages
217
+ 4. The JSON-RPC initialization response includes `keepAlive: true` and `supportsHeartbeats: true`
218
+
219
+ Example curl commands to test the API:
220
+ ```bash
221
+ # Dev
222
+ curl -X GET "https://postgres-mcp-toolbox-186512416539.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
223
+
224
+ # Staging
225
+ curl -X GET "https://postgres-mcp-toolbox-526194183507.us-east4.run.app/databases" -H 'x-api-key: YOUR_API_KEY_HERE'
226
+ ```
227
+
228
+ ### Common Issues
229
+
230
+ - **Missing API Key**: Ensure the `DB_PROXY_API_KEY` environment variable is set
231
+ - **Permission Errors**: Verify that your API key has the necessary permissions
232
+ - **Timeout Errors**: Check network latency or increase the timeout settings in the code
233
+ - **Heartbeat Issues**: Ensure the MCP server properly implements heartbeat handlers
@@ -1,179 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: nuuly-postgres-mcp-server
3
- Version: 1.0.0
4
- Summary: MCP server for accessing Nuuly PostgreSQL database resources
5
- Author-email: Nuuly Engineering <engineering@nuuly.com>
6
- License: Proprietary
7
- Project-URL: Homepage, https://github.com/urbn/r15-mcp
8
- Project-URL: Repository, https://github.com/urbn/r15-mcp
9
- Requires-Python: >=3.8
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: fastmcp>=2.2.1
12
- Requires-Dist: httpx>=0.24.0
13
- Requires-Dist: psycopg2-binary>=2.9.5
14
-
15
- # Nuuly Postgres MCP Server
16
-
17
- MCP server for accessing Nuuly PostgreSQL database resources through Claude Desktop and other AI assistants.
18
-
19
- ## Contents
20
- - `src/nuuly_postgres_mcp_server/`: Package source code
21
- - `__init__.py`: Package initialization
22
- - `__main__.py`: Entry point for running as a module
23
- - `server.py`: Main server implementation
24
- - `pyproject.toml`: Package configuration
25
- - `.env.example`: Example environment variables
26
-
27
- ## Purpose
28
- 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:
29
-
30
- 1. Understand all tables and schemas
31
- 2. Run queries against the non-prod database
32
- 3. List available databases and their aliases
33
-
34
- ---
35
-
36
- ## Installation
37
-
38
- ### Option 1: Install from PyPI
39
-
40
- ```bash
41
- pip install nuuly-postgres-mcp-server
42
- ```
43
-
44
- ### Option 2: Install from Source
45
-
46
- 1. Clone the repository:
47
- ```bash
48
- git clone <REPO_URL>
49
- cd r15-mcp/mcp_servers/postgres-mcp
50
- ```
51
-
52
- 2. Install the package in development mode:
53
- ```bash
54
- pip install -e .
55
- ```
56
-
57
- ## Local Development
58
-
59
- ### Prerequisites
60
- - Python 3.8 or higher
61
- - pip package manager
62
-
63
- ### Setup
64
-
65
- 1. Clone the repository:
66
- ```bash
67
- git clone <REPO_URL>
68
- cd r15-mcp/mcp_servers/postgres-mcp
69
- ```
70
-
71
- 2. Create and activate a virtual environment (optional but recommended):
72
- ```bash
73
- python -m venv venv
74
- source venv/bin/activate # On Windows: venv\Scripts\activate
75
- ```
76
-
77
- 3. Install development dependencies:
78
- ```bash
79
- pip install -e .
80
- ```
81
-
82
- 4. Set up environment variables:
83
- ```bash
84
- cp .env.example .env
85
- # Edit .env with your actual values
86
- ```
87
-
88
- ## Environment Variables
89
-
90
- The following environment variables can be set to customize the behavior of the MCP server:
91
-
92
- - `CLOUD_RUN_PROXY_URL`: URL of the Cloud Run DB Proxy (default: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app")
93
- - `DB_PROXY_API_KEY`: API key for authenticating with the Cloud Run DB Proxy (required)
94
- - `LOG_LEVEL`: Logging level (default: INFO)
95
-
96
- ## Usage
97
-
98
- ### For Claude Desktop
99
-
100
- Add this configuration to your Claude Desktop settings:
101
-
102
- ```json
103
- {
104
- "Nuuly Postgres MCP": {
105
- "command": "nuuly-postgres-mcp",
106
- "env": {
107
- "PYTHONUNBUFFERED": "1",
108
- "CLOUD_RUN_PROXY_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
109
- "DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
110
- }
111
- }
112
- }
113
- ```
114
-
115
- ### Command Line Usage
116
-
117
- ```bash
118
- nuuly-postgres-mcp
119
- ```
120
-
121
- ## Deployment
122
-
123
- ### As a GCP Cloud Function
124
-
125
- This MCP server is designed to be deployed as a GCP Cloud Function with the following parameters:
126
-
127
- - Project: `rental-dev`
128
- - Region: `us-east4`
129
- - Serverless VPC Connector: `rental-vpc-connector`
130
- - Entry point: `main.py`
131
-
132
- The function connects to CloudSQL PostgreSQL using private IP (10.171.208.52) and uses environment variables for DB credentials.
133
-
134
- ```yaml
135
- environment_variables:
136
- CLOUD_RUN_PROXY_URL: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app"
137
- DB_PROXY_API_KEY: "${DB_PROXY_API_KEY}"
138
- LOG_LEVEL: "INFO"
139
- ```
140
-
141
- ### Building and Publishing the Package
142
-
143
- To build and publish the package to PyPI:
144
-
145
- ```bash
146
- python -m build
147
- python -m twine upload dist/*
148
- ```
149
-
150
- ## Available Tools
151
-
152
- This MCP server provides the following tools to AI assistants:
153
-
154
- - `run_query`: Execute SQL queries against the database
155
- - `get_schema`: Get database schema information
156
- - `list_databases`: List available databases
157
-
158
- ## Troubleshooting
159
-
160
- ### Connection Issues with Claude Desktop
161
-
162
- If you experience connection issues with Claude Desktop (client transport closing), ensure that:
163
-
164
- 1. The server is running with the correct URL for the Cloud Run DB Proxy
165
- 2. The API key is correctly set and properly escaped in any curl commands (use single quotes)
166
- 3. The server is properly handling heartbeat and shutdown messages
167
- 4. The JSON-RPC initialization response includes `keepAlive: true` and `supportsHeartbeats: true`
168
-
169
- Example curl command to test the API:
170
- ```bash
171
- curl -X GET "https://postgres-mcp-toolbox-186512416539.us-east4.run.app/databases" -H 'X-API-KEY: YOUR_API_KEY_HERE'
172
- ```
173
-
174
- ### Common Issues
175
-
176
- - **Missing API Key**: Ensure the `DB_PROXY_API_KEY` environment variable is set
177
- - **Permission Errors**: Verify that your API key has the necessary permissions
178
- - **Timeout Errors**: Check network latency or increase the timeout settings in the code
179
- - **Heartbeat Issues**: Ensure the MCP server properly implements heartbeat handlers
@@ -1,165 +0,0 @@
1
- # Nuuly Postgres MCP Server
2
-
3
- MCP server for accessing Nuuly PostgreSQL database resources through Claude Desktop and other AI assistants.
4
-
5
- ## Contents
6
- - `src/nuuly_postgres_mcp_server/`: Package source code
7
- - `__init__.py`: Package initialization
8
- - `__main__.py`: Entry point for running as a module
9
- - `server.py`: Main server implementation
10
- - `pyproject.toml`: Package configuration
11
- - `.env.example`: Example environment variables
12
-
13
- ## Purpose
14
- 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:
15
-
16
- 1. Understand all tables and schemas
17
- 2. Run queries against the non-prod database
18
- 3. List available databases and their aliases
19
-
20
- ---
21
-
22
- ## Installation
23
-
24
- ### Option 1: Install from PyPI
25
-
26
- ```bash
27
- pip install nuuly-postgres-mcp-server
28
- ```
29
-
30
- ### Option 2: Install from Source
31
-
32
- 1. Clone the repository:
33
- ```bash
34
- git clone <REPO_URL>
35
- cd r15-mcp/mcp_servers/postgres-mcp
36
- ```
37
-
38
- 2. Install the package in development mode:
39
- ```bash
40
- pip install -e .
41
- ```
42
-
43
- ## Local Development
44
-
45
- ### Prerequisites
46
- - Python 3.8 or higher
47
- - pip package manager
48
-
49
- ### Setup
50
-
51
- 1. Clone the repository:
52
- ```bash
53
- git clone <REPO_URL>
54
- cd r15-mcp/mcp_servers/postgres-mcp
55
- ```
56
-
57
- 2. Create and activate a virtual environment (optional but recommended):
58
- ```bash
59
- python -m venv venv
60
- source venv/bin/activate # On Windows: venv\Scripts\activate
61
- ```
62
-
63
- 3. Install development dependencies:
64
- ```bash
65
- pip install -e .
66
- ```
67
-
68
- 4. Set up environment variables:
69
- ```bash
70
- cp .env.example .env
71
- # Edit .env with your actual values
72
- ```
73
-
74
- ## Environment Variables
75
-
76
- The following environment variables can be set to customize the behavior of the MCP server:
77
-
78
- - `CLOUD_RUN_PROXY_URL`: URL of the Cloud Run DB Proxy (default: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app")
79
- - `DB_PROXY_API_KEY`: API key for authenticating with the Cloud Run DB Proxy (required)
80
- - `LOG_LEVEL`: Logging level (default: INFO)
81
-
82
- ## Usage
83
-
84
- ### For Claude Desktop
85
-
86
- Add this configuration to your Claude Desktop settings:
87
-
88
- ```json
89
- {
90
- "Nuuly Postgres MCP": {
91
- "command": "nuuly-postgres-mcp",
92
- "env": {
93
- "PYTHONUNBUFFERED": "1",
94
- "CLOUD_RUN_PROXY_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
95
- "DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
96
- }
97
- }
98
- }
99
- ```
100
-
101
- ### Command Line Usage
102
-
103
- ```bash
104
- nuuly-postgres-mcp
105
- ```
106
-
107
- ## Deployment
108
-
109
- ### As a GCP Cloud Function
110
-
111
- This MCP server is designed to be deployed as a GCP Cloud Function with the following parameters:
112
-
113
- - Project: `rental-dev`
114
- - Region: `us-east4`
115
- - Serverless VPC Connector: `rental-vpc-connector`
116
- - Entry point: `main.py`
117
-
118
- The function connects to CloudSQL PostgreSQL using private IP (10.171.208.52) and uses environment variables for DB credentials.
119
-
120
- ```yaml
121
- environment_variables:
122
- CLOUD_RUN_PROXY_URL: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app"
123
- DB_PROXY_API_KEY: "${DB_PROXY_API_KEY}"
124
- LOG_LEVEL: "INFO"
125
- ```
126
-
127
- ### Building and Publishing the Package
128
-
129
- To build and publish the package to PyPI:
130
-
131
- ```bash
132
- python -m build
133
- python -m twine upload dist/*
134
- ```
135
-
136
- ## Available Tools
137
-
138
- This MCP server provides the following tools to AI assistants:
139
-
140
- - `run_query`: Execute SQL queries against the database
141
- - `get_schema`: Get database schema information
142
- - `list_databases`: List available databases
143
-
144
- ## Troubleshooting
145
-
146
- ### Connection Issues with Claude Desktop
147
-
148
- If you experience connection issues with Claude Desktop (client transport closing), ensure that:
149
-
150
- 1. The server is running with the correct URL for the Cloud Run DB Proxy
151
- 2. The API key is correctly set and properly escaped in any curl commands (use single quotes)
152
- 3. The server is properly handling heartbeat and shutdown messages
153
- 4. The JSON-RPC initialization response includes `keepAlive: true` and `supportsHeartbeats: true`
154
-
155
- Example curl command to test the API:
156
- ```bash
157
- curl -X GET "https://postgres-mcp-toolbox-186512416539.us-east4.run.app/databases" -H 'X-API-KEY: YOUR_API_KEY_HERE'
158
- ```
159
-
160
- ### Common Issues
161
-
162
- - **Missing API Key**: Ensure the `DB_PROXY_API_KEY` environment variable is set
163
- - **Permission Errors**: Verify that your API key has the necessary permissions
164
- - **Timeout Errors**: Check network latency or increase the timeout settings in the code
165
- - **Heartbeat Issues**: Ensure the MCP server properly implements heartbeat handlers
@@ -1,179 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: nuuly-postgres-mcp-server
3
- Version: 1.0.0
4
- Summary: MCP server for accessing Nuuly PostgreSQL database resources
5
- Author-email: Nuuly Engineering <engineering@nuuly.com>
6
- License: Proprietary
7
- Project-URL: Homepage, https://github.com/urbn/r15-mcp
8
- Project-URL: Repository, https://github.com/urbn/r15-mcp
9
- Requires-Python: >=3.8
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: fastmcp>=2.2.1
12
- Requires-Dist: httpx>=0.24.0
13
- Requires-Dist: psycopg2-binary>=2.9.5
14
-
15
- # Nuuly Postgres MCP Server
16
-
17
- MCP server for accessing Nuuly PostgreSQL database resources through Claude Desktop and other AI assistants.
18
-
19
- ## Contents
20
- - `src/nuuly_postgres_mcp_server/`: Package source code
21
- - `__init__.py`: Package initialization
22
- - `__main__.py`: Entry point for running as a module
23
- - `server.py`: Main server implementation
24
- - `pyproject.toml`: Package configuration
25
- - `.env.example`: Example environment variables
26
-
27
- ## Purpose
28
- 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:
29
-
30
- 1. Understand all tables and schemas
31
- 2. Run queries against the non-prod database
32
- 3. List available databases and their aliases
33
-
34
- ---
35
-
36
- ## Installation
37
-
38
- ### Option 1: Install from PyPI
39
-
40
- ```bash
41
- pip install nuuly-postgres-mcp-server
42
- ```
43
-
44
- ### Option 2: Install from Source
45
-
46
- 1. Clone the repository:
47
- ```bash
48
- git clone <REPO_URL>
49
- cd r15-mcp/mcp_servers/postgres-mcp
50
- ```
51
-
52
- 2. Install the package in development mode:
53
- ```bash
54
- pip install -e .
55
- ```
56
-
57
- ## Local Development
58
-
59
- ### Prerequisites
60
- - Python 3.8 or higher
61
- - pip package manager
62
-
63
- ### Setup
64
-
65
- 1. Clone the repository:
66
- ```bash
67
- git clone <REPO_URL>
68
- cd r15-mcp/mcp_servers/postgres-mcp
69
- ```
70
-
71
- 2. Create and activate a virtual environment (optional but recommended):
72
- ```bash
73
- python -m venv venv
74
- source venv/bin/activate # On Windows: venv\Scripts\activate
75
- ```
76
-
77
- 3. Install development dependencies:
78
- ```bash
79
- pip install -e .
80
- ```
81
-
82
- 4. Set up environment variables:
83
- ```bash
84
- cp .env.example .env
85
- # Edit .env with your actual values
86
- ```
87
-
88
- ## Environment Variables
89
-
90
- The following environment variables can be set to customize the behavior of the MCP server:
91
-
92
- - `CLOUD_RUN_PROXY_URL`: URL of the Cloud Run DB Proxy (default: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app")
93
- - `DB_PROXY_API_KEY`: API key for authenticating with the Cloud Run DB Proxy (required)
94
- - `LOG_LEVEL`: Logging level (default: INFO)
95
-
96
- ## Usage
97
-
98
- ### For Claude Desktop
99
-
100
- Add this configuration to your Claude Desktop settings:
101
-
102
- ```json
103
- {
104
- "Nuuly Postgres MCP": {
105
- "command": "nuuly-postgres-mcp",
106
- "env": {
107
- "PYTHONUNBUFFERED": "1",
108
- "CLOUD_RUN_PROXY_URL": "https://postgres-mcp-toolbox-186512416539.us-east4.run.app",
109
- "DB_PROXY_API_KEY": "YOUR_API_KEY_HERE"
110
- }
111
- }
112
- }
113
- ```
114
-
115
- ### Command Line Usage
116
-
117
- ```bash
118
- nuuly-postgres-mcp
119
- ```
120
-
121
- ## Deployment
122
-
123
- ### As a GCP Cloud Function
124
-
125
- This MCP server is designed to be deployed as a GCP Cloud Function with the following parameters:
126
-
127
- - Project: `rental-dev`
128
- - Region: `us-east4`
129
- - Serverless VPC Connector: `rental-vpc-connector`
130
- - Entry point: `main.py`
131
-
132
- The function connects to CloudSQL PostgreSQL using private IP (10.171.208.52) and uses environment variables for DB credentials.
133
-
134
- ```yaml
135
- environment_variables:
136
- CLOUD_RUN_PROXY_URL: "https://postgres-mcp-toolbox-186512416539.us-east4.run.app"
137
- DB_PROXY_API_KEY: "${DB_PROXY_API_KEY}"
138
- LOG_LEVEL: "INFO"
139
- ```
140
-
141
- ### Building and Publishing the Package
142
-
143
- To build and publish the package to PyPI:
144
-
145
- ```bash
146
- python -m build
147
- python -m twine upload dist/*
148
- ```
149
-
150
- ## Available Tools
151
-
152
- This MCP server provides the following tools to AI assistants:
153
-
154
- - `run_query`: Execute SQL queries against the database
155
- - `get_schema`: Get database schema information
156
- - `list_databases`: List available databases
157
-
158
- ## Troubleshooting
159
-
160
- ### Connection Issues with Claude Desktop
161
-
162
- If you experience connection issues with Claude Desktop (client transport closing), ensure that:
163
-
164
- 1. The server is running with the correct URL for the Cloud Run DB Proxy
165
- 2. The API key is correctly set and properly escaped in any curl commands (use single quotes)
166
- 3. The server is properly handling heartbeat and shutdown messages
167
- 4. The JSON-RPC initialization response includes `keepAlive: true` and `supportsHeartbeats: true`
168
-
169
- Example curl command to test the API:
170
- ```bash
171
- curl -X GET "https://postgres-mcp-toolbox-186512416539.us-east4.run.app/databases" -H 'X-API-KEY: YOUR_API_KEY_HERE'
172
- ```
173
-
174
- ### Common Issues
175
-
176
- - **Missing API Key**: Ensure the `DB_PROXY_API_KEY` environment variable is set
177
- - **Permission Errors**: Verify that your API key has the necessary permissions
178
- - **Timeout Errors**: Check network latency or increase the timeout settings in the code
179
- - **Heartbeat Issues**: Ensure the MCP server properly implements heartbeat handlers