mysql-mcp

MCP.Pizza Chef: LeonMelamud

mysql-mcp is an MCP server that provides AI agents with direct, structured access to MySQL databases. It supports executing SQL queries, managing notes stored as database entries, and inspecting database schema through tools like listing tables, describing table structure, and searching tables. This server simplifies database interaction for AI workflows by exposing database content and operations via a standardized MCP interface, requiring Node.js and a running MySQL server.

Use This MCP server To

Execute SQL queries via AI agents for dynamic data retrieval Create and manage text notes stored in MySQL databases List and describe database tables for schema exploration Search database tables using pattern matching Count total tables in a MySQL database Integrate MySQL data access into AI-enhanced workflows

README

MySQL MCP Server

A powerful MCP server that provides direct access to MySQL databases. This server enables AI agents to interact with MySQL databases, execute SQL queries, and manage database content through a simple interface.

Features

Resources

  • Access notes stored in the database via note:///{id} URIs
  • Each note has a title and content
  • Plain text mime type for simple content access

Tools

  • create_note - Create new text notes in the database
    • Takes title and content as required parameters
    • Stores note in the MySQL database
  • list_tables - List all tables in the connected database
  • count_tables - Get the total number of tables in the database
  • search_tables - Search for tables using LIKE pattern
  • describe_table - Get the structure of a specific table
  • execute_sql - Execute custom SQL queries

Prerequisites

  • Node.js 18 or higher
  • MySQL server installed and running
  • A database with appropriate permissions

Setup

  1. Clone this repository:

    git clone git@github.com:LeonMelamud/mysql-mcp.git
    cd mysql-mcp
  2. Install dependencies:

    npm install
  3. Create a .env file in the root directory with your MySQL connection details:

    MYSQL_HOST=localhost
    MYSQL_USER=your_username
    MYSQL_PASSWORD=your_password
    MYSQL_DATABASE=your_database
    
  4. Build the server:

    npm run build

Installation

For Claude Desktop

Add the server config to your Claude Desktop configuration file:

On MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json On Windows: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["/path/to/mysql-server/build/index.js"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

For Cline

Add the server config to your Cline MCP settings file:

On MacOS: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json On Windows: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json

{
  "mcpServers": {
    "mysql": {
      "command": "node",
      "args": ["/path/to/mysql-server/build/index.js"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Usage Examples

Once installed, you can use the MySQL MCP server in your conversations with Claude:

List all tables in the database

Please list all the tables in my MySQL database.

Execute a SQL query

Run this SQL query: SELECT * FROM users LIMIT 5

Create a note

Create a note titled "Meeting Notes" with the content "Discussed project timeline and assigned tasks."

Development

For development with auto-rebuild:

npm run watch

Debugging

Use the MCP Inspector to debug the server:

npm run inspector

The Inspector will provide a URL to access debugging tools in your browser.

License

MIT

mysql-mcp FAQ

How do I connect mysql-mcp to my MySQL database?
Configure the connection parameters in the server setup, ensuring your MySQL server is running and accessible with proper credentials.
What Node.js version is required to run mysql-mcp?
Node.js 18 or higher is required to run the mysql-mcp server.
Can mysql-mcp execute arbitrary SQL queries?
Yes, it provides an execute_sql tool to run custom SQL queries directly on the connected MySQL database.
How does mysql-mcp expose database content to AI models?
It exposes notes as resources with note:///{id} URIs and provides tools to list, search, and describe tables, enabling structured data access.
Is it possible to create new notes in the database using mysql-mcp?
Yes, the create_note tool allows creating new text notes with title and content stored in the MySQL database.
What MIME type is used for note content?
Plain text MIME type is used for simple content access to notes.
What prerequisites are needed before installing mysql-mcp?
You need Node.js 18+, a running MySQL server, and a database with appropriate permissions.
Can mysql-mcp be integrated with multiple AI LLM providers?
Yes, it is provider-agnostic and can work with OpenAI, Anthropic Claude, and Google Gemini models.