SuperAPI AI Directory

mysql-mcp-server

Read-only MySQL database access.

Open website

About this tool

Purpose

mysql-mcp-server is a Model Context Protocol (MCP) server that provides read-only access to MySQL databases. It acts as an intermediary between a large language model (LLM) and a MySQL database, handling requests according to the Model Context Protocol, enabling the LLM to inspect the database structure and execute read-only queries.

Key Capabilities

  1. Read-only database access: Enforces read-only operations through SQL validation and READ ONLY transactions.
  2. Structure discovery: Automatically identifies and exposes the database table structure.
  3. SQL query execution: Provides a query tool that accepts and executes SELECT statements.
  4. Model Context Protocol compliance: Implements the MCP specification and can integrate seamlessly with compatible LLMs.
  5. Simple configuration: Requires minimal configuration and is easy to set up.

Usage

The server provides a query tool for executing read-only SQL queries against the connected database.

  • Input: sql (string), the SQL query to execute.
  • All queries are executed in a READ ONLY transaction.

The server provides structural information for each table in the database:

  • Table structure (mysql://user:password@localhost:3306/database)
  • JSON structural information for each table
  • Includes column names and data types
  • Automatically discovered from database metadata

MCP setup configuration file:

Recommended usage: replace mysql://user:password@localhost:port/ and npm run inspector

System Architecture

MySQL MCP Server acts as an intermediary between the LLM and the MySQL database, handling requests according to the Model Context Protocol.

Component interaction: MySQL MCP Server implements a strict security model to ensure that database access is read-only.

Security measures include:

  1. SQL query validation, allowing only SELECT statements.
  2. All queries are executed in a READ ONLY transaction.
  3. Data modification operations (INSERT, UPDATE, DELETE, etc.) are not supported.
  4. Database structure modification (CREATE, ALTER, DROP, etc.) is not supported.

Integration with LLMs

MySQL MCP Server is designed for any LLM system that supports the Model Context Protocol. It communicates via JSON-RPC over stdio, following the MCP specification.

Applicable Scenarios and Limitations

It is suitable for scenarios where an LLM needs to safely read the MySQL database structure and execute read-only queries. The limitation is that only read-only operations are supported, and no data modification or database structure modification is supported.