From ef07831780e2ee153ddad1ce59042ab90cd18ecf Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Sun, 11 Jan 2026 16:42:25 +0000 Subject: [PATCH] Add MCP module to admin bootstrap and SHOW MCP VARIABLES command The MCP module was not being loaded because: 1. The admin bootstrap process was not calling flush_mcp_variables___database_to_runtime - Added the call after flush_sqliteserver_variables___database_to_runtime 2. There was no SHOW MCP VARIABLES command handler - Added the handler in Admin_Handler.cpp, following the same pattern as SHOW MYSQL VARIABLES and SHOW PGSQL VARIABLES Now after this change: - MCP variables (mcp-enabled, mcp-port, mcp-mysql_hosts, etc.) will be automatically inserted into global_variables table during ProxySQL startup - Users can run "SHOW MCP VARIABLES" to list all MCP configuration variables - The configure_mcp.sh script will work correctly Note: Requires rebuilding ProxySQL for changes to take effect. --- lib/Admin_Bootstrap.cpp | 1 + lib/Admin_Handler.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/Admin_Bootstrap.cpp b/lib/Admin_Bootstrap.cpp index 92271f3fd..f27f09f1f 100644 --- a/lib/Admin_Bootstrap.cpp +++ b/lib/Admin_Bootstrap.cpp @@ -1208,6 +1208,7 @@ bool ProxySQL_Admin::init(const bootstrap_info_t& bootstrap_info) { flush_clickhouse_variables___database_to_runtime(admindb,true); #endif /* PROXYSQLCLICKHOUSE */ flush_sqliteserver_variables___database_to_runtime(admindb,true); + flush_mcp_variables___database_to_runtime(admindb, true); if (GloVars.__cmd_proxysql_admin_socket) { set_variable((char *)"mysql_ifaces",GloVars.__cmd_proxysql_admin_socket); diff --git a/lib/Admin_Handler.cpp b/lib/Admin_Handler.cpp index 5bf94247c..2a513278c 100644 --- a/lib/Admin_Handler.cpp +++ b/lib/Admin_Handler.cpp @@ -4016,6 +4016,13 @@ void admin_session_handler(S* sess, void *_pa, PtrSize_t *pkt) { goto __run_query; } + if (query_no_space_length == strlen("SHOW MCP VARIABLES") && !strncasecmp("SHOW MCP VARIABLES", query_no_space, query_no_space_length)) { + l_free(query_length, query); + query = l_strdup("SELECT variable_name AS Variable_name, variable_value AS Value FROM global_variables WHERE variable_name LIKE 'mcp-%' ORDER BY variable_name"); + query_length = strlen(query) + 1; + goto __run_query; + } + strA=(char *)"SHOW CREATE TABLE "; strB=(char *)"SELECT name AS 'table' , REPLACE(REPLACE(sql,' , ', X'2C0A20202020'),'CREATE TABLE %s (','CREATE TABLE %s ('||X'0A20202020') AS 'Create Table' FROM %s.sqlite_master WHERE type='table' AND name='%s'"; strAl=strlen(strA);