MySQL MCP Server

by gopikapeenikkal

184 downloads Not rated yet MIT license
GitHub

About

A Model Context Protocol (MCP) server that connects to a MySQL database and exposes a tool for AI models to execute SQL queries via natural language, without direct database access.

Details

License
MIT license

Explore

- Provides a single read_query tool for executing SELECT queries
- Allows natural language querying through AI models like Claude
- Integrates with Cursor via mcp.json configuration
- Supports manual execution and Python client usage
- Requires Python 3.11+ and a MySQL database

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MySQL MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Python 3.11 or above
- MySQL database

Start the server manually:

```bash

export DB_HOST=your-mysql-host
export DB_USER=your-username
export DB_PASSWORD=your-password
export DB_NAME=your-database

The server provides a SQL execution tool that can be used to query your MySQL database:

- read_query(query: str, params: List[str] = None) - Execute a SQL SELECT query against the database

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mysql mcp server": {
            "mysql-mcp-server-gopikapeenikkal": {
                "command": "uv",
                "args": [
                    "pip",
                    "install",
                    "mcp_mysql_connect"
                ]
            }
        }
    }
}

McpServers

{
    "mysql-mcp-server-gopikapeenikkal": {
        "command": "uv",
        "args": [
            "pip",
            "install",
            "mcp_mysql_connect"
        ]
    }
}

A Model Context Protocol (MCP) server that provides an interface for AI models to interact with MySQL databases through natural language queries.

Overview

This package creates an MCP server that connects to a MySQL database and exposes a tool to execute SQL queries. It allows AI models like Claude to interact with your MySQL database without direct database access.

Prerequisites

- Python 3.11 or above
- MySQL database

Installation

You can install the MCP MySQL server using pip:

pip install mcp_mysql_connect

Or using UV:

uv pip install mcp_mysql_connect

Configuration

The server requires the following environment variables:

- DB_HOST - MySQL server host
- DB_USER - MySQL username
- DB_PASSWORD - MySQL password
- DB_NAME - MySQL database name

You can set these using a .env file or directly in your environment.

Usage Options

1. Using with Cursor

Add the following to your ~/.cursor/mcp.json configuration:

"mysql-mcp-server": {
  "command": "uvx",
  "args": [
    "--from",
    "mcp_mysql_connect",
    "mcp_mysql_connect"
  ],
  "env": {
    "DB_HOST": "your-mysql-host",
    "DB_USER": "your-username",
    "DB_PASSWORD": "your-password",
    "DB_NAME": "your-database"
  }
}

Alternative configuration:

"mysql-mcp-server": {
  "command": "uv",
  "args": [
    "run",
    "--with",
    "mcp_mysql_connect",
    "-m",
    "mcp_mysql_connect"
  ],
  "env": {
    "DB_HOST": "your-mysql-host",
    "DB_USER": "your-username",
    "DB_PASSWORD": "your-password",
    "DB_NAME": "your-database"
  }
}

2. Using with Python Code

```python
from mcp.client import Client
from mcp.tools import Tools

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.