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. If left empty, no authentication is required for that endpoint.
mcp-config_endpoint_auth"" (empty)/mcp/config endpointSET mcp-config_endpoint_auth='my-secret-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-stats_endpoint_auth"" (empty)/mcp/stats endpointSET mcp-stats_endpoint_auth='stats-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-query_endpoint_auth"" (empty)/mcp/query endpointSET mcp-query_endpoint_auth='query-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-admin_endpoint_auth"" (empty)/mcp/admin endpointSET mcp-admin_endpoint_auth='admin-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-cache_endpoint_auth"" (empty)/mcp/cache endpointSET mcp-cache_endpoint_auth='cache-token';
LOAD MCP VARIABLES TO RUNTIME;
mcp-ai_endpoint_auth"" (empty)/mcp/ai endpointSET 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