mysql
An MCP server provides read-only access to MySQL databases.
claude mcp add --transport stdio dpflucas-mysql-mcp-server npx mysql-mcp-server \ --env MYSQL_HOST="your-mysql-host" \ --env MYSQL_PORT="3306" \ --env MYSQL_USER="your-mysql-user" \ --env MYSQL_DATABASE="your-default-database" \ --env MYSQL_PASSWORD="your-mysql-password"
How to use
This MCP server provides read-only access to a MySQL server. It exposes tools to list databases and tables, inspect table schemas, and run read-only queries against the configured MySQL instance. Use the available commands to discover your data structure and retrieve results without modifying any data. The core tools are: list_databases to enumerate databases, list_tables to show tables in a database, describe_table to view a table’s schema, and execute_query to run safe, read-only SQL statements (only SELECT, SHOW, DESCRIBE, and EXPLAIN are allowed).
To use the tools, connect to the MCP server using your MCP client and invoke the tools with the required parameters. For example, to list all databases you would call list_databases with no arguments. To inspect a specific table, call describe_table with the database name (optional) and the table name. To retrieve data, use execute_query with a read-only query such as SELECT statements, optionally scoped to a database. The documentation examples in the README illustrate the exact JSON payloads you can send to each tool.
How to install
Prerequisites:
- Node.js and npm installed, or a compatible environment for the selected installation method
- Access to an MCP settings file where you can configure mcpServers
- A running MySQL server with credentials that you can supply via environment variables
Installation options:
- Install from NPM (global or local):
# Install globally
npm install -g mysql-mcp-server
# Or install locally in your project
npm install mysql-mcp-server
- Build from source:
# Clone the repository
git clone https://github.com/dpflucas/mysql-mcp-server.git
cd mysql-mcp-server
# Install dependencies and build
npm install
npm run build
- Install via Smithery ( Claude AI integration):
npx -y @smithery/cli install @dpflucas/mysql-mcp-server --client claude
Configure environment variables and MCP settings as described in the README to complete setup.
Additional notes
Tips and notes:
- The server is explicitly read-only. Ensure your queries adhere to this by using only SELECT, SHOW, DESCRIBE, or EXPLAIN statements.
- Set MYSQL_PASSWORD and other credentials securely; consider vaults or environment management in production.
- You can adjust advanced connection pool options via environment variables such as MYSQL_CONNECTION_LIMIT, MYSQL_QUEUE_LIMIT, MYSQL_CONNECT_TIMEOUT, MYSQL_IDLE_TIMEOUT, and MYSQL_MAX_IDLE to tune performance.
- If you encounter connection errors, verify host, port, user permissions, and network access from the MCP host to the MySQL server.
- When using the npm configuration example, remember to replace placeholder values with your real credentials and database defaults.
- Use the provided test scripts in the repository to validate the setup against a test database before connecting to production data.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.