MCP server that gives AI agents a persistent MySQL database via PolarDB-X Cloud Zero
Project description
PolarDB-X Cloud Zero MCP Server
Give any AI agent a persistent MySQL database through the Model Context Protocol.
Create a free PolarDB-X Cloud Zero instance on demand via create_instance(), or bring your own MySQL credentials. No signup, no API keys needed.
How It Works
┌──────────────┐ MCP (stdio/http) ┌──────────────────┐
│ AI Agent │ ◄──────────────────────────► │ MCP Server │
│ (Qoder, etc) │ │ (this project) │
└──────────────┘ └────────┬─────────┘
│
MySQL protocol │ Zero API (HTTP)
(pymysql + SSL) │ (on-demand creation)
│
┌────────▼─────────┐
│ PolarDB-X Cloud │
│ Zero │
└──────────────────┘
- Agent calls
create_instance()(or you provide MySQL credentials via env vars) - Server creates a PolarDB-X Cloud Zero instance and caches credentials locally
- All SQL is executed over the MySQL wire protocol (pymysql + SSL)
Installation
pip install polardbx-zero-mcp
IDE / MCP Client Configuration
Claude Code:
claude mcp add polardbx -- polardbx-zero-mcp
Qoder / Cursor / Windsurf / Claude Desktop — add to mcp.json:
{
"mcpServers": {
"polardbx": {
"command": "polardbx-zero-mcp"
}
}
}
From source
git clone https://github.com/polardb/polardbx-zero-mcp.git
cd polardbx-zero-mcp
pip install -e .
polardbx-zero-mcp
HTTP transport:
polardbx-zero-mcp --transport http(defaulthttp://localhost:8000/mcp)
Configuration
By default, no configuration is needed — just call create_instance() to get a free database.
To connect to your own MySQL or PolarDB-X instance, pass credentials via env:
{
"mcpServers": {
"polardbx": {
"command": "polardbx-zero-mcp",
"env": {
"MYSQL_URL": "mysql://user:password@host:3306/mydb"
}
}
}
}
Or use individual variables:
| Variable | Description | Default |
|---|---|---|
MYSQL_URL |
Full MySQL connection URL | -- |
MYSQL_HOST |
MySQL host | -- |
MYSQL_PORT |
MySQL port | 3306 |
MYSQL_USERNAME |
MySQL user | -- |
MYSQL_PASSWORD |
MySQL password | -- |
MYSQL_DATABASE |
Database name | -- |
Tools
Instance Management
| Tool | Description |
|---|---|
get_instance_status |
Check if an instance is available, show connection info and remaining TTL |
create_instance |
Create a new PolarDB-X Cloud Zero instance |
get_database_info |
Database version, connection info, table count |
SQL Execution
| Tool | Description |
|---|---|
execute_sql_tool |
Execute any SQL statement (no type restrictions) |
batch_execute |
Execute multiple SQL statements sequentially |
list_tables |
List all tables in the database |
describe_table |
Get table schema (columns, types, keys) |
Stateful Connections
For operations that need session state (SET variables, transactions):
| Tool | Description |
|---|---|
acquire_connection |
Create a persistent connection, returns a conn_id |
release_connection |
Release a specific connection (rolls back uncommitted transactions) |
release_all_connections |
Release all connections |
list_connections |
List active connections with idle status |
Key Parameters
create_instance:
| Parameter | Type | Default | Description |
|---|---|---|---|
edition |
string | "standard" |
"standard" or "enterprise" |
ttl_minutes |
int | 720 |
Instance TTL in minutes (default 12h) |
execute_sql_tool:
| Parameter | Type | Default | Description |
|---|---|---|---|
sql |
string | (required) | SQL statement to execute |
database |
string | "" |
Target database (optional) |
conn_id |
string | "" |
Stateful connection ID from acquire_connection() (optional) |
batch_execute:
| Parameter | Type | Default | Description |
|---|---|---|---|
statements |
list[string] | (required) | SQL statements to execute in order |
database |
string | "" |
Target database (optional) |
conn_id |
string | "" |
Stateful connection ID (optional) |
acquire_connection:
| Parameter | Type | Default | Description |
|---|---|---|---|
database |
string | "" |
Target database (optional) |
idle_timeout_minutes |
int | 30 |
Auto-release after idle (minutes) |
Development
pip install -e . # Install in editable mode
mcp dev server.py # Test with MCP Inspector
polardbx-zero-mcp --transport http # Run HTTP server
License
Apache-2.0
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 polardbx_zero_mcp-0.1.3.tar.gz.
File metadata
- Download URL: polardbx_zero_mcp-0.1.3.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c3dd3a8d160e90568ff07e49d3fcabbbd3cf304623a5e41e41dd48abefa8550
|
|
| MD5 |
471d1bfd96616d87726696a649734555
|
|
| BLAKE2b-256 |
a0500878d96472dd2da38d13ffc267b06d84c60f5c9b59fd9f9ad1494f63f522
|
File details
Details for the file polardbx_zero_mcp-0.1.3-py3-none-any.whl.
File metadata
- Download URL: polardbx_zero_mcp-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4e05aa2bccba242a5aa947ad3bc68db5c626743dbb929c9826a272c971bc451
|
|
| MD5 |
1f984c380e383914db2b7b3dc94a470d
|
|
| BLAKE2b-256 |
81ca508bd8e84295894b14804665c5dc5f9bd4defff870b0f858718f2d035488
|