From c52c621b2715fcf0f24601b562bf432badaa8d46 Mon Sep 17 00:00:00 2001 From: Wazir Ahmed Date: Sun, 25 Jan 2026 04:27:43 +0530 Subject: [PATCH] MCP: Add mcp-rag_endpoint_auth config Signed-off-by: Wazir Ahmed --- include/MCP_Thread.h | 2 ++ lib/MCP_Endpoint.cpp | 2 ++ lib/MCP_Thread.cpp | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/include/MCP_Thread.h b/include/MCP_Thread.h index b87d74f70..0b767d66a 100644 --- a/include/MCP_Thread.h +++ b/include/MCP_Thread.h @@ -50,6 +50,8 @@ public: char* mcp_query_endpoint_auth; ///< Authentication for /mcp/query endpoint char* mcp_admin_endpoint_auth; ///< Authentication for /mcp/admin endpoint char* mcp_cache_endpoint_auth; ///< Authentication for /mcp/cache endpoint + char* mcp_rag_endpoint_auth; ///< Authentication for /mcp/rag endpoint + int mcp_timeout_ms; ///< Request timeout in milliseconds (default: 30000) // MySQL Tool Handler configuration char* mcp_mysql_hosts; ///< Comma-separated list of MySQL hosts diff --git a/lib/MCP_Endpoint.cpp b/lib/MCP_Endpoint.cpp index c41c81214..5104dc3bb 100644 --- a/lib/MCP_Endpoint.cpp +++ b/lib/MCP_Endpoint.cpp @@ -40,6 +40,8 @@ bool MCP_JSONRPC_Resource::authenticate_request(const httpserver::http_request& expected_token = handler->variables.mcp_admin_endpoint_auth; } else if (endpoint_name == "cache") { expected_token = handler->variables.mcp_cache_endpoint_auth; + } else if (endpoint_name == "rag") { + expected_token = handler->variables.mcp_rag_endpoint_auth; } else { proxy_error("MCP authentication on %s: unknown endpoint\n", endpoint_name.c_str()); return false; diff --git a/lib/MCP_Thread.cpp b/lib/MCP_Thread.cpp index fdbe94938..f539dc83c 100644 --- a/lib/MCP_Thread.cpp +++ b/lib/MCP_Thread.cpp @@ -23,6 +23,7 @@ static const char* mcp_thread_variables_names[] = { "query_endpoint_auth", "admin_endpoint_auth", "cache_endpoint_auth", + "rag_endpoint_auth", "timeout_ms", // MySQL Tool Handler configuration "mysql_hosts", @@ -48,6 +49,7 @@ MCP_Threads_Handler::MCP_Threads_Handler() { variables.mcp_query_endpoint_auth = strdup(""); variables.mcp_admin_endpoint_auth = strdup(""); variables.mcp_cache_endpoint_auth = strdup(""); + variables.mcp_rag_endpoint_auth = strdup(""); variables.mcp_timeout_ms = 30000; // MySQL Tool Handler default values variables.mcp_mysql_hosts = strdup("127.0.0.1"); @@ -83,6 +85,8 @@ MCP_Threads_Handler::~MCP_Threads_Handler() { free(variables.mcp_admin_endpoint_auth); if (variables.mcp_cache_endpoint_auth) free(variables.mcp_cache_endpoint_auth); + if (variables.mcp_rag_endpoint_auth) + free(variables.mcp_rag_endpoint_auth); // Free MySQL Tool Handler variables if (variables.mcp_mysql_hosts) free(variables.mcp_mysql_hosts); @@ -198,6 +202,10 @@ int MCP_Threads_Handler::get_variable(const char* name, char* val) { sprintf(val, "%s", variables.mcp_cache_endpoint_auth ? variables.mcp_cache_endpoint_auth : ""); return 0; } + if (!strcmp(name, "rag_endpoint_auth")) { + sprintf(val, "%s", variables.mcp_rag_endpoint_auth ? variables.mcp_rag_endpoint_auth : ""); + return 0; + } if (!strcmp(name, "timeout_ms")) { sprintf(val, "%d", variables.mcp_timeout_ms); return 0; @@ -291,6 +299,12 @@ int MCP_Threads_Handler::set_variable(const char* name, const char* value) { variables.mcp_cache_endpoint_auth = strdup(value); return 0; } + if (!strcmp(name, "rag_endpoint_auth")) { + if (variables.mcp_rag_endpoint_auth) + free(variables.mcp_rag_endpoint_auth); + variables.mcp_rag_endpoint_auth = strdup(value); + return 0; + } if (!strcmp(name, "timeout_ms")) { int timeout = atoi(value); if (timeout >= 0) {