Overview
What is MySQL MCP Server?
MySQL MCP Server is an MCP (Model Context Protocol) server that integrates with MySQL databases. It allows AI assistants and MCP-compatible clients to execute read-only SQL queries, explore database schemas, and retrieve table data. The server is intended for developers who want to connect an AI tool to a MySQL database safely using only query‑side operations.
How to use MySQL MCP Server?
Clone the repository from GitHub, install dependencies with npm install, and add the server configuration to your mcp.json file under mcpServers. The configuration requires setting environment variables for the MySQL connection (MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS, MYSQL_DB). The server is started with the command node ./mysql-mcp/index.js.
Key features of MySQL MCP Server
- Execute read‑only SQL queries (SELECT, SHOW, EXPLAIN, DESCRIBE)
- Retrieve the structure (schema) of any table
- List all tables in the connected database
- Access table data via the resource
table://{name}(up to 100 rows) - Simple environment‑variable based configuration
Use cases of MySQL MCP Server
- Query a MySQL database using natural language through an MCP‑capable AI assistant
- Inspect table schemas and list tables without writing raw SQL
- Quickly fetch sample data from a table for preview or analysis
- Enable read‑only database exploration for non‑technical users via an AI interface
FAQ from MySQL MCP Server
Which SQL statements are supported?
Only SELECT, SHOW, EXPLAIN, and DESCRIBE statements. The server enforces read‑only access, so INSERT, UPDATE, DELETE, and other write commands are not allowed.
How do I configure the MySQL connection?
Set the environment variables MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASS, and MYSQL_DB in the MCP server configuration. They specify the MySQL host, port, username, password, and database name.
Does the server allow write operations to the database?
No. The query tool only accepts read‑only SQL statements, and the other tools (table‑schema, list‑tables) are also read‑only. The server is designed for safe, query‑only access.
How many rows can I retrieve from a table resource?
The table://{name} resource returns up to 100 rows. There is no pagination or limit override described in the README.
What runtime does the server require?
The server runs on Node.js. You need to have Node.js and npm installed to clone the repository and install dependencies before launching the server.