mirror of https://github.com/sysown/proxysql
MCP TAP startup: fix tool-handler initialization order, improve MCP PROFILES observability, and seed monitor users
This change fixes recurring MCP TAP failures where `/mcp/query` returned: Tool Handler not initialized for endpoint: query and where backend monitor auth failures flooded logs. Problem summary - MCP server startup can occur before runtime target/auth profiles and backend server mappings are loaded. - If that happens, Query_Tool_Handler initialization sees no executable targets and remains NULL. - MCP endpoint resources bind the handler pointer at creation time, so a NULL query handler at startup breaks `/mcp/query` until server restart. Code changes 1) Add explicit admin command logging for MCP PROFILES commands - Added `Received <command>` logging in the MCP PROFILES command block, matching behavior of other admin command handlers. - File: `lib/Admin_Handler.cpp` 2) Trigger MCP server refresh after `LOAD MCP PROFILES TO RUNTIME` - After copying profiles into runtime and rebuilding target/auth map, call `ProxySQL_Admin::load_mcp_server()`. - This allows MCP to self-heal when profiles become available after initial startup. - File: `lib/Admin_Handler.cpp` 3) Restart MCP server when query handler is missing - Extended `ProxySQL_Admin::load_mcp_server()` restart checks to include: - running server + `query_tool_handler == NULL` - Restart reason now includes tool handler initialization mismatch. - File: `lib/ProxySQL_Admin.cpp` 4) Fix TAP configurator load order to avoid early MCP startup - Reordered `test/tap/tests/mcp_rules_testing/configure_mcp.sh` runtime sequence: - `LOAD MYSQL SERVERS TO RUNTIME` - `LOAD PGSQL SERVERS TO RUNTIME` (best effort) - `LOAD MCP PROFILES TO RUNTIME` - `LOAD MCP VARIABLES TO RUNTIME` (last) - This ensures MCP starts only after routing/auth context is present. 5) Seed monitor credentials in AI local infra pre-hook - Added backend user/role creation for default monitor credentials `monitor/monitor`: - MySQL: create user + monitor-relevant grants - PostgreSQL: create role + `pg_monitor` + DB connect grants - Reduces monitor auth noise in local AI TAP dockerized setup. - File: `test/tap/groups/ai/pre-proxysql.bash` 6) Mark new TAP phase scripts executable - `test_phase10_eval_explain.sh` - `test_phase11_pgsql_target.sh` Expected outcome - MCP query endpoint no longer stays stuck with an uninitialized tool handler after TAP configuration. - MCP query-rules admin commands stop failing due to missing Query_Tool_Handler. - MCP profile command flow is visible in logs for easier debugging. - Local AI TAP infra no longer emits continuous monitor authentication failures for default monitor credentials.pull/5386/head
parent
af0411bd46
commit
998bd82387
Loading…
Reference in new issue