scripts/mcp/STDIO_BRIDGE_README.md
A bridge that converts between stdio-based MCP (for Claude Code) and ProxySQL's HTTPS MCP endpoint.
┌─────────────┐ stdio ┌──────────────────┐ HTTPS ┌──────────┐
│ Claude Code│ ──────────> │ stdio Bridge │ ──────────> │ ProxySQL │
│ (MCP Client)│ │ (this script) │ │ MCP │
└─────────────┘ └──────────────────┘ └──────────┘
pip install httpx
chmod +x proxysql_mcp_stdio_bridge.py
| Variable | Required | Default | Description |
|---|---|---|---|
PROXYSQL_MCP_ENDPOINT | No | https://127.0.0.1:6071/mcp/query | ProxySQL MCP endpoint URL |
PROXYSQL_MCP_TOKEN | No | - | Bearer token for authentication (if configured) |
PROXYSQL_MCP_INSECURE_SSL | No | 0 | Set to 1 to disable SSL verification (for self-signed certs) |
Add to your Claude Code MCP settings (usually ~/.config/claude-code/mcp_config.json or similar):
{
"mcpServers": {
"proxysql": {
"command": "python3",
"args": ["./scripts/mcp/proxysql_mcp_stdio_bridge.py"],
"env": {
"PROXYSQL_MCP_ENDPOINT": "https://127.0.0.1:6071/mcp/query",
"PROXYSQL_MCP_TOKEN": "your_token_here",
"PROXYSQL_MCP_INSECURE_SSL": "1"
}
}
}
}
export PROXYSQL_MCP_ENDPOINT="https://127.0.0.1:6071/mcp/query"
export PROXYSQL_MCP_TOKEN="your_token" # optional
export PROXYSQL_MCP_INSECURE_SSL="1" # for self-signed certs
python3 proxysql_mcp_stdio_bridge.py
Then send a JSON-RPC request via stdin:
{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}
| Method | Description |
|---|---|
initialize | Handshake protocol |
tools/list | List available ProxySQL MCP tools |
tools/call | Call a ProxySQL MCP tool |
ping | Health check |
Once connected, the following tools will be available in Claude Code:
list_schemas - List databaseslist_tables - List tables in a schemadescribe_table - Get table structureget_constraints - Get foreign keys and constraintssample_rows - Sample data from a tablerun_sql_readonly - Execute read-only SQL queriesexplain_sql - Get query execution plantable_profile - Get table statisticscolumn_profile - Get column statisticssuggest_joins - Suggest join paths between tablesfind_reference_candidates - Find potential foreign key relationshipsdiscovery.run_static - Run Phase 1 of two-phase discovery (static harvest), requires target_idagent.run_start - Start a new agent run for discovery coordination, requires target_id + run_idagent.run_finish - Mark an agent run as completedagent.event_append - Append an event to an agent runllm.summary_upsert - Store or update a table/column summary generated by LLM (target_id + run_id)llm.summary_get - Retrieve LLM-generated summary for a table or columnllm.relationship_upsert - Store or update an inferred relationship between tablesllm.domain_upsert - Store or update a business domain classificationllm.domain_set_members - Set the members (tables) of a business domainllm.metric_upsert - Store or update a business metric definitionllm.question_template_add - Add a question template that can be answered using this datallm.note_add - Add a general note or insight about the datallm.search - Search LLM-generated content and insightsNote: catalog/agent/llm tools are target-scoped. Always include target_id when a tool accepts run_id.
catalog_upsert - Store data in the catalogcatalog_get - Retrieve from the catalogcatalog_search - Search the catalogcatalog_delete - Delete entry from the catalogcatalog_list - List catalog entries by kindcatalog_merge - Merge multiple catalog entries into a single consolidated entryOnce configured, you can ask Claude:
"List all tables in the testdb schema" "Describe the customers table" "Show me 5 rows from the orders table" "Run SELECT COUNT(*) FROM customers"
For debugging, the bridge writes logs to /tmp/proxysql_mcp_bridge.log:
tail -f /tmp/proxysql_mcp_bridge.log
The log shows:
This can help diagnose communication issues between Claude Code, the bridge, and ProxySQL.
If tools aren't working, check the bridge log file for detailed information:
cat /tmp/proxysql_mcp_bridge.log
Look for:
"tools/call: name=..." - confirms tool calls are being forwarded"response from ProxySQL:" - shows what ProxySQL returned"WRITE stdout:" - confirms responses are being sent to Claude CodeMake sure ProxySQL MCP server is running:
curl -k https://127.0.0.1:6071/mcp/query \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "ping", "id": 1}'
Set PROXYSQL_MCP_INSECURE_SSL=1 to bypass certificate verification.
Check that PROXYSQL_MCP_TOKEN matches the token configured in ProxySQL:
SHOW VARIABLES LIKE 'mcp-query_endpoint_auth';
pip install httpx)