Hi! 👋 We are doing a big documentation refresh. Help us improve — what's missing or could be better? Let us know! Simply send an email or start a conversation in Google Groups!

MCP Server

Overview

ProxySQL v4.0 introduces native support for the Model Context Protocol (MCP). This feature allows ProxySQL to act as an MCP server, enabling AI agents (like Claude, ChatGPT, or custom LLM-based applications) to interact directly with ProxySQL to discover database schemas, execute queries, and manage configuration through a standardized protocol.

By exposing ProxySQL as an MCP server, you can provide LLMs with deep context about your database infrastructure, including:

  • Real-time schema definitions.
  • Query execution capabilities with built-in safety rules.
  • Performance metrics and query digests.
  • Configuration management.

Connectivity

The MCP server in ProxySQL operates over HTTP/HTTPS and supports JSON-RPC 2.0 as defined by the Model Context Protocol specification.

  • Default Port: 6071
  • Protocol: HTTP (can be upgraded to HTTPS with SSL)
  • Authentication: Bearer tokens per endpoint.

Key Features

1. Standardized Interaction

AI agents can use standard MCP clients to “talk” to ProxySQL. This eliminates the need for custom database connectors for every AI application.

2. Built-in Safety (MCP Query Rules)

The released Query handler evaluates MCP Query Rules for run_sql_readonly and explain_sql. Rules can match, rewrite, block, or short-circuit those SQL operations, but they are not a universal filter for every Query tool or MCP endpoint. Combine them with per-endpoint bearer tokens, least-privilege backend profiles, TLS, and network controls.

3. Autodiscovery

ProxySQL can automatically discover the schemas, tables, and relationships within your backend MySQL/PostgreSQL servers and present them as “Context” to the LLM.

4. Tooling

The MCP server exposes a set of Tools that agents can call. These include:

  • run_sql_readonly: Execute guarded read-only SQL.
  • explain_sql: Retrieve a backend execution plan for guarded read-only SQL.
  • catalog.get_object: Retrieve a discovered table or view definition.
  • list_tables: List available tables.
  • discovery.run_static: Harvest metadata for a logical target.

See the exact 29-tool Query registry; other endpoints expose different tool sets.

Getting Started

To enable the MCP server, you need to set the mcp-enabled global variable to true:

SET mcp-enabled='true';
LOAD MCP VARIABLES TO RUNTIME;

For more details on configuration, see the MCP Variables and MCP Configuration Tables sections.