doc/MCP/VARIABLES.md
This document describes all configuration variables for the MCP (Model Context Protocol) module in ProxySQL.
The MCP module provides JSON-RPC 2.0 over HTTPS for LLM integration with ProxySQL. It includes endpoints for configuration, observation, querying, administration, caching, and AI features, each with dedicated tool handlers for database exploration and LLM integration.
All variables are stored in the global_variables table with the mcp- prefix and can be modified at runtime through the admin interface.
mcp-enabledfalseSET mcp-enabled=true;
LOAD MCP VARIABLES TO RUNTIME;
mcp-port6071SET mcp-port=7071;
LOAD MCP VARIABLES TO RUNTIME;
mcp-timeout_ms30000 (30 seconds)SET mcp-timeout_ms=60000;
LOAD MCP VARIABLES TO RUNTIME;
The following variables control authentication (Bearer tokens) for
specific MCP endpoints. As of GHSA-7wh6-2vcc-gcm4 / CVE-2026-48774,
every MCP endpoint refuses all requests when its *_endpoint_auth
variable is empty. Each endpoint must be configured with an explicit
non-empty bearer token before it will accept requests; the prior "empty
= no authentication" behaviour has been removed because every endpoint
can either execute SQL on backends or read/mutate sensitive proxy state.
mcp-config_endpoint_auth"" (empty)/mcp/config endpoint. Required:
refuses all requests when empty.SET mcp-config_endpoint_auth='my-secret-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-stats_endpoint_auth"" (empty)/mcp/stats endpoint. Required:
refuses all requests when empty.SET mcp-stats_endpoint_auth='stats-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-query_endpoint_auth"" (empty)/mcp/query endpoint. Required:
refuses all requests when empty. The /mcp/query endpoint executes
SQL on configured MCP target backends; the token must be set before
the endpoint will respond.SET mcp-query_endpoint_auth='query-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-admin_endpoint_auth"" (empty)/mcp/admin endpoint. Required:
refuses all requests when empty. Admin tools (admin_kill_query,
admin_flush_cache, admin_reload) are powerful operations and the
endpoint must not be exposed unauthenticated.SET mcp-admin_endpoint_auth='admin-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-cache_endpoint_auth"" (empty)/mcp/cache endpoint. Required:
refuses all requests when empty.SET mcp-cache_endpoint_auth='cache-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-ai_endpoint_auth"" (empty)/mcp/ai endpoint. Required:
refuses all requests when empty. AI tools can dispatch backend SQL
via LLM-driven tool calls.SET mcp-ai_endpoint_auth='ai-token';
LOAD MCP VARIABLES TO RUNTIME;
The Query Tool Handler provides LLM-based tools for MySQL database exploration and two-phase discovery, including:
list_targets)Query tools use a logical target_id routing model with server-managed credentials:
list_targets to retrieve discoverable backend targets.runtime_mcp_target_profiles joined with runtime_mcp_auth_profiles.target_id -> auth_profile_id and applies backend credentials internally.target_id to query tools instead of host/protocol details.Backend credentials are defined in MCP tables, not in client requests:
mcp_auth_profiles / runtime_mcp_auth_profilesmcp_target_profiles / runtime_mcp_target_profilesThe in-memory target/auth map is loaded by MCP_Threads_Handler from runtime tables and used by the query executor connection pools.
The catalog database path is hardcoded to mcp_catalog.db in the ProxySQL datadir and cannot be changed at runtime. The catalog stores:
-- View all MCP variables
SHOW MCP VARIABLES;
-- View specific variable
SELECT variable_name, variable_value
FROM global_variables
WHERE variable_name LIKE 'mcp-%';
-- Set a variable
SET mcp-enabled=true;
-- Load to runtime
LOAD MCP VARIABLES TO RUNTIME;
-- Save to disk
SAVE MCP VARIABLES TO DISK;
Unified command family for MCP backend profiles (auth + target together):
-- Disk -> Memory
LOAD MCP PROFILES FROM DISK;
LOAD MCP PROFILES TO MEMORY;
-- Memory -> Runtime
LOAD MCP PROFILES TO RUNTIME;
LOAD MCP PROFILES FROM MEMORY;
-- Runtime -> Memory
SAVE MCP PROFILES TO MEMORY;
SAVE MCP PROFILES FROM RUNTIME;
-- Memory -> Disk
SAVE MCP PROFILES TO DISK;
-- Checksum of disk variables
CHECKSUM DISK MCP VARIABLES;
-- Checksum of memory variables
CHECKSUM MEM MCP VARIABLES;
-- Checksum of runtime variables
CHECKSUM MEMORY MCP VARIABLES;
Variables can be persisted across three layers:
disk.global_variables) - Persistent storagemain.global_variables) - Active configurationruntime_global_variables) - Currently active valuesLOAD MCP VARIABLES FROM DISK → Disk to Memory
LOAD MCP VARIABLES TO RUNTIME → Memory to Runtime
SAVE MCP VARIABLES TO DISK → Memory to Disk
SAVE MCP VARIABLES FROM RUNTIME → Runtime to Memory
The following read-only status variables are available:
| Variable | Description |
|---|---|
mcp_total_requests | Total number of MCP requests received |
mcp_failed_requests | Total number of failed MCP requests |
mcp_active_connections | Current number of active MCP connections |
To view status variables:
SELECT * FROM stats_mysql_global WHERE variable_name LIKE 'mcp_%';
SELECT permissions for inventory/structure toolsPROCESS permission for profilingSELECT on specific tables for sampling/query toolsmcp-port