Get the FREE Ultimate OpenClaw Setup Guide →

mysql

An MCP server provides read-only access to MySQL databases.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. 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
  1. 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
  1. 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

Sponsor this space

Reach thousands of developers