Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
87fff9e
Add MCP (Model Context Protocol) module skeleton
renecannao Jan 11, 2026
245e61e
Make MCP_Threads_Handler a standalone independent class
renecannao Jan 11, 2026
81c5389
Fix MCP module TAP test failures
renecannao Jan 11, 2026
b032c3f
Fix boolean literal handling in SET command for MCP variables
renecannao Jan 11, 2026
221ff23
Add MySQL exploration MCP tools with SQLite catalog
renecannao Jan 11, 2026
4eab519
Implement MySQL connection pool for MySQL_Tool_Handler
renecannao Jan 11, 2026
06aa6d6
Add comprehensive Doxygen documentation for connection pool
renecannao Jan 11, 2026
e9a6dd0
Add comprehensive MCP testing suite in scripts/mcp/
renecannao Jan 11, 2026
ad2e2a2
Add native MySQL mode support to test database setup
renecannao Jan 11, 2026
3d82714
Add required environment variables section to README
renecannao Jan 11, 2026
b3646b4
Fix argument parsing and documentation in setup_test_db.sh
renecannao Jan 11, 2026
c53b28e
Add comprehensive documentation to MCP README
renecannao Jan 11, 2026
2874255
Use relative catalog path instead of absolute path
renecannao Jan 11, 2026
ef07831
Add MCP module to admin bootstrap and SHOW MCP VARIABLES command
renecannao Jan 11, 2026
2874c9a
Fix flush_mcp_variables___database_to_runtime to populate runtime_glo…
renecannao Jan 11, 2026
2e7109d
Fix lock ordering in flush_mcp_variables___database_to_runtime
renecannao Jan 11, 2026
b70b07e
Skip checksum generation for MCP until feature is complete
renecannao Jan 11, 2026
5a85ef0
Fix MCP variables persistence and add DISK command support
renecannao Jan 11, 2026
33a100c
Use relative path mcp_catalog.db in MCP test instead of absolute /var…
renecannao Jan 11, 2026
a5f712e
Add MCP variables documentation
renecannao Jan 11, 2026
60d4a73
Implement automatic MCP server start/stop and add environment variabl…
renecannao Jan 11, 2026
d17fe1d
Fix configure_mcp.sh error handling and endpoint paths
renecannao Jan 11, 2026
aeafa61
Fix test_mcp_tools.sh to use correct MCP endpoint paths
renecannao Jan 11, 2026
40cff23
Initialize MySQL Tool Handler and fix default MySQL port
renecannao Jan 11, 2026
49e6ac5
Revert configure_mcp.sh to respect environment variables
renecannao Jan 11, 2026
991f013
Reinitialize MySQL Tool Handler when MCP variables change
renecannao Jan 11, 2026
7f95708
Fix configure_mcp.sh to allow empty MySQL passwords
renecannao Jan 11, 2026
0935119
Add environment variable printing to MCP scripts
renecannao Jan 11, 2026
c86a048
Implement MCP multi-endpoint architecture with dedicated tool handlers
renecannao Jan 12, 2026
ced10dd
Implement per-endpoint authentication for MCP endpoints
renecannao Jan 12, 2026
25cda31
Update test_mcp_tools.sh with dynamic tool discovery
renecannao Jan 12, 2026
de33d17
Fix verbose mode in test_mcp_tools.sh
renecannao Jan 12, 2026
9042833
Fix critical use-after-free bug in MySQL_Tool_Handler::execute_query
renecannao Jan 12, 2026
acb4c57
Fix case sensitivity issues in MySQL_Tool_Handler::execute_query
renecannao Jan 12, 2026
22db1a5
Fix JSON value extraction in Query_Tool_Handler::execute_tool
renecannao Jan 12, 2026
ef5b99e
Fix MCP tool bugs: NULL value handling and query validation
renecannao Jan 12, 2026
5846cd8
Add Database Discovery Agent architecture documentation
renecannao Jan 12, 2026
07dc887
Add MCP Tool Discovery Guide
renecannao Jan 12, 2026
2ef44e7
Add MCP implementation plans for FTS and Vector Embeddings
renecannao Jan 12, 2026
313f637
Merge branch 'v3.1-vec' into v3.1-MCP1
renecannao Jan 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
465 changes: 465 additions & 0 deletions doc/MCP/Architecture.md

Large diffs are not rendered by default.

800 changes: 800 additions & 0 deletions doc/MCP/Database_Discovery_Agent.md

Large diffs are not rendered by default.

582 changes: 582 additions & 0 deletions doc/MCP/FTS_Implementation_Plan.md

Large diffs are not rendered by default.

475 changes: 475 additions & 0 deletions doc/MCP/Tool_Discovery_Guide.md

Large diffs are not rendered by default.

279 changes: 279 additions & 0 deletions doc/MCP/VARIABLES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
# MCP Variables

This document describes all configuration variables for the MCP (Model Context Protocol) module in ProxySQL.

## Overview

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 a MySQL Tool Handler for database exploration.

All variables are stored in the `global_variables` table with the `mcp-` prefix and can be modified at runtime through the admin interface.

## Variable Reference

### Server Configuration

#### `mcp-enabled`
- **Type:** Boolean
- **Default:** `false`
- **Description:** Enable or disable the MCP HTTPS server
- **Runtime:** Yes (requires restart of MCP server to take effect)
- **Example:**
```sql
SET mcp-enabled=true;
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-port`
- **Type:** Integer
- **Default:** `6071`
- **Description:** HTTPS port for the MCP server
- **Range:** 1024-65535
- **Runtime:** Yes (requires restart of MCP server to take effect)
- **Example:**
```sql
SET mcp-port=7071;
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-timeout_ms`
- **Type:** Integer
- **Default:** `30000` (30 seconds)
- **Description:** Request timeout in milliseconds for all MCP endpoints
- **Range:** 1000-300000 (1 second to 5 minutes)
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-timeout_ms=60000;
LOAD MCP VARIABLES TO RUNTIME;
```

### Endpoint Authentication

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`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** Bearer token for `/mcp/config` endpoint
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-config_endpoint_auth='my-secret-token';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-observe_endpoint_auth`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** Bearer token for `/mcp/observe` endpoint
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-observe_endpoint_auth='observe-token';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-query_endpoint_auth`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** Bearer token for `/mcp/query` endpoint
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-query_endpoint_auth='query-token';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-admin_endpoint_auth`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** Bearer token for `/mcp/admin` endpoint
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-admin_endpoint_auth='admin-token';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-cache_endpoint_auth`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** Bearer token for `/mcp/cache` endpoint
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-cache_endpoint_auth='cache-token';
LOAD MCP VARIABLES TO RUNTIME;
```

### MySQL Tool Handler Configuration

The MySQL Tool Handler provides LLM-based tools for MySQL database exploration, including:
- **inventory** - List databases and tables
- **structure** - Get table schema
- **profiling** - Analyze query performance
- **sampling** - Sample table data
- **query** - Execute SQL queries
- **relationships** - Infer table relationships
- **catalog** - Catalog operations

#### `mcp-mysql_hosts`
- **Type:** String (comma-separated)
- **Default:** `"127.0.0.1"`
- **Description:** Comma-separated list of MySQL host addresses
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-mysql_hosts='192.168.1.10,192.168.1.11,192.168.1.12';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-mysql_ports`
- **Type:** String (comma-separated)
- **Default:** `"3306"`
- **Description:** Comma-separated list of MySQL ports (corresponds to `mcp-mysql_hosts`)
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-mysql_ports='3306,3307,3308';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-mysql_user`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** MySQL username for tool handler connections
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-mysql_user='mcp_user';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-mysql_password`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** MySQL password for tool handler connections
- **Runtime:** Yes
- **Note:** Password is stored in plaintext in `global_variables`. Use restrictive MySQL user permissions.
- **Example:**
```sql
SET mcp-mysql_password='secure-password';
LOAD MCP VARIABLES TO RUNTIME;
```

#### `mcp-mysql_schema`
- **Type:** String
- **Default:** `""` (empty)
- **Description:** Default database/schema to use for tool operations
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-mysql_schema='mydb';
LOAD MCP VARIABLES TO RUNTIME;
```

### Catalog Configuration

#### `mcp-catalog_path`
- **Type:** String (file path)
- **Default:** `"mcp_catalog.db"`
- **Description:** Path to the SQLite catalog database (relative to ProxySQL datadir)
- **Runtime:** Yes
- **Example:**
```sql
SET mcp-catalog_path='/path/to/mcp_catalog.db';
LOAD MCP VARIABLES TO RUNTIME;
```

## Management Commands

### View Variables

```sql
-- View all MCP variables
SHOW MCP VARIABLES;

-- View specific variable
SELECT variable_name, variable_value
FROM global_variables
WHERE variable_name LIKE 'mcp-%';
```

### Modify Variables

```sql
-- Set a variable
SET mcp-enabled=true;

-- Load to runtime
LOAD MCP VARIABLES TO RUNTIME;

-- Save to disk
SAVE MCP VARIABLES TO DISK;
```

### Checksum Commands

```sql
-- Checksum of disk variables
CHECKSUM DISK MCP VARIABLES;

-- Checksum of memory variables
CHECKSUM MEM MCP VARIABLES;

-- Checksum of runtime variables
CHECKSUM MEMORY MCP VARIABLES;
```

## Variable Persistence

Variables can be persisted across three layers:

1. **Disk** (`disk.global_variables`) - Persistent storage
2. **Memory** (`main.global_variables`) - Active configuration
3. **Runtime** (`runtime_global_variables`) - Currently active values

```
LOAD 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
```

## Status Variables

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:

```sql
SELECT * FROM stats_mysql_global WHERE variable_name LIKE 'mcp_%';
```

## Security Considerations

1. **Authentication:** Always set authentication tokens for production environments
2. **HTTPS:** The MCP server uses HTTPS with SSL certificates from the ProxySQL datadir
3. **MySQL Permissions:** Create a dedicated MySQL user with limited permissions for the tool handler:
- `SELECT` permissions for inventory/structure tools
- `PROCESS` permission for profiling
- Limited `SELECT` on specific tables for sampling/query tools
4. **Network Access:** Consider firewall rules to restrict access to `mcp-port`

## Version

- **MCP Thread Version:** 0.1.0
- **Protocol:** JSON-RPC 2.0 over HTTPS

## Related Documentation

- [MCP Module README](README.md) - Module overview and setup
- [MCP Endpoints](ENDPOINTS.md) - API endpoint documentation
- [MySQL Tool Handler](TOOL_HANDLER.md) - Tool-specific documentation
Loading