home / mcp / mysql mcp server

MySQL MCP Server

Provides MySQL connectivity via MCP, enabling data access and schema operations through the MCP protocol.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "irwantocrimson-mysql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "[email protected]"
      ],
      "env": {
        "MYSQL_HOST": "your-mysql-host",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your-username",
        "MYSQL_DATABASE": "your-database",
        "MYSQL_PASSWORD": "your-password"
      }
    }
  }
}

You can connect to a MySQL database through this MCP server, enabling your applications to query and manage data via a unified MCP interface. It supports configurable MySQL connections and can be run locally or via a package manager, making it easy to integrate into your development and deployment workflows.

How to use

Start the MCP server in your environment and configure the MySQL connection you want to target. You can run it through an MCP client that communicates with the server using the standard MCP protocol. When you set up the client, you will be able to query the schema of a table, retrieve data, and perform typical database operations through MCP calls.

How to install

Prerequisites: ensure Node.js and npm are installed on your system before starting. You will also need access to a MySQL server to connect to.

Install dependencies and build the project locally to prepare the MCP server for use.

npm install
npm run build

Additional configuration and usage notes

You can configure the server using either environment variables or command-line arguments. Environment variables take precedence over command-line arguments.

Environment variables you can set for MySQL connection include:

- MYSQL_HOST: MySQL host (default: localhost) - MYSQL_PORT: MySQL port (default: 3306) - MYSQL_USER: MySQL user (default: root) - MYSQL_PASSWORD: MySQL password (default: empty) - MYSQL_DATABASE: MySQL database (default: test)

Examples of how to run with explicit host and database using short flags:

- You can also configure the server in a development setup by pointing to your local or remote MySQL instance.

Claude Desktop Configuration

To run from Claude Desktop, you can use a configuration that launches the MCP server via npx with environment variables for your MySQL connection.

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "[email protected]"
      ],
      "env": {
        "MYSQL_HOST": "your-mysql-host",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your-username",
        "MYSQL_PASSWORD": "your-password",
        "MYSQL_DATABASE": "your-database"
      }
    }
  }
}

For local development

Run the server locally by starting the MCP server script with Node.js, pointing to the built index file. This is useful for development and testing.

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": [
        "/path/to/your/crimson-mysql-mcp/build/index.js"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "root",
        "MYSQL_DATABASE": "test"
      }
    }
  }
}

Available tools

get-schema

Retrieve the schema/structure of a specified MySQL table to understand its columns and data types.