Get the FREE Ultimate OpenClaw Setup Guide →

mysql

🔧 MySQL MCP Server for Model Context Protocol Features: • Execute any MySQL query • List all databases • List tables in database • Describe table structure • Environment-based configuration • Built with TypeScript & MCP SDK Ready to use with Claude Desktop, Cursor, and other MCP clients.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio myheisenberg-mysql-mcp-server node path/to/mysql-mcp-server/dist/index.js \
  --env DB_HOST="localhost" \
  --env DB_PORT="3306" \
  --env DB_USER="your_username" \
  --env DB_PASSWORD="your_password"

How to use

This MCP server provides four tools to interact with a MySQL database from any Model Context Protocol client: mysql_query to run arbitrary SQL queries, mysql_databases to list all databases, mysql_tables to list tables in a database, and mysql_describe to inspect table structures. The server reads database connection details from environment variables, ensuring credentials are not hard-coded. To use it, deploy the server in your environment and point your MCP client to the node-based server entrypoint (dist/index.js) with the appropriate environment variables for DB_HOST, DB_USER, DB_PASSWORD, and DB_PORT. Once running, invoke the specific MCP tools by name (e.g., mysql_query, mysql_databases) and supply the required prompts or messages that describe the operation you want performed.

How to install

Prerequisites:

  • Node.js and npm installed on your system
  • Access to a MySQL server

Installation steps:

  1. Clone the repository:
git clone https://github.com/myheisenberg/mysql-mcp-server.git
cd mysql-mcp-server
  1. Install dependencies:
npm install
  1. Build the project (if applicable):
npm run build
  1. Run the server (example):
DB_HOST=localhost DB_USER=root DB_PASSWORD=your_password DB_PORT=3306 npm start
  1. Verify the server is running and available to MCP clients by checking logs or health endpoints as defined by the project.

Additional notes

Tips and caveats:

  • Do not store credentials in code; use environment variables as shown in the configuration examples.
  • If your MySQL server uses a non-standard port, update DB_PORT accordingly.
  • Ensure your MySQL user has appropriate permissions for the operations you intend to perform via mysql_query (SELECT, INSERT, UPDATE, DELETE).
  • Enable connection pooling in your environment if supported by the driver/version you are using for improved performance.
  • If you encounter connection errors, verify network access from the MCP server host to the MySQL host and confirm user privileges.
  • Review error messages from the MCP server for hints about credentials or network issues, and avoid exposing sensitive details in logs.

Related MCP Servers

Sponsor this space

Reach thousands of developers ↗