MCP: Add mcp-rag_endpoint_auth config

Signed-off-by: Wazir Ahmed <wazir@proxysql.com>
v4.0_rag_mcp
Wazir Ahmed 3 months ago
parent eb495f42ee
commit c52c621b27

@ -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

@ -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;

@ -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) {

Loading…
Cancel
Save