Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
6,000+ web scrapers for your AI agent, start free logo6,000+ web scrapers for your AI agent, start free

Apify gives your agent live web data: 6,000+ prebuilt scrapers and actors, MCP-ready. Sign up free with $5 in usage credits.

Try Apify free
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 48,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Provides read-only MySQL database operations for AI agents, supporting multiple database servers with tools for listing tables, describing schemas, and executing SELECT queries.

README.md

MySQL MCP Server

A Model Context Protocol (MCP) server that provides readonly MySQL database operations for AI agents with support for multiple database servers.

Features

  • list_servers: Show all configured MySQL servers
  • list_tables: List all tables in the database
  • describe_table: Show table structure and column information
  • query: Execute SELECT queries (readonly only)
  • show_databases: List available databases
  • use_database: Switch to a different database on a server

Installation

For detailed installation instructions, see INSTALLATION.md

From npm (once published)

npm install -g @your-username/mysql-mcp

From source

git clone <repository-url>
cd mysql-mcp
npm install

Configuration

Option 1: Multiple Servers (Recommended)

Configure multiple MySQL servers using a JSON environment variable MYSQL_SERVERS:

{
  "production": {
    "host": "prod.example.com",
    "port": 3306,
    "user": "prod_user",
    "password": "prod_password",
    "database": "prod_db"
  },
  "staging": {
    "host": "staging.example.com",
    "port": 3306,
    "user": "staging_user",
    "password": "staging_password",
    "database": "staging_db"
  },
  "local": {
    "host": "localhost",
    "port": 3306,
    "user": "root",
    "password": "local_password",
    "database": "test_db"
  }
}

Option 2: Single Server (Backward Compatible)

Copy .env.example to .env and configure your MySQL connection:

cp .env.example .env

Set the following environment variables:

  • MYSQL_HOST: MySQL server host (default: localhost)
  • MYSQL_PORT: MySQL server port (default: 3306)
  • MYSQL_USER: MySQL username (default: root)
  • MYSQL_PASSWORD: MySQL password
  • MYSQL_DATABASE: Database name to connect to

Usage with Claude Desktop

Multiple Servers Configuration

If installed from npm: ``json { "mcpServers": { "mysql": { "command": "mysql-mcp", "env": { "MYSQL_SERVERS": "{\"production\":{\"host\":\"prod.example.com\",\"port\":3306,\"user\":\"prod_user\",\"password\":\"prod_password\",\"database\":\"prod_db\"},\"staging\":{\"host\":\"staging.example.com\",\"port\":3306,\"user\":\"staging_user\",\"password\":\"staging_password\",\"database\":\"staging_db\"}}" } } } } ``

If running from source: ``json { "mcpServers": { "mysql": { "command": "node", "args": ["path/to/mysql-mcp/server.js"], "env": { "MYSQL_SERVERS": "{\"production\":{\"host\":\"prod.example.com\",\"port\":3306,\"user\":\"prod_user\",\"password\":\"prod_password\",\"database\":\"prod_db\"},\"staging\":{\"host\":\"staging.example.com\",\"port\":3306,\"user\":\"staging_user\",\"password\":\"staging_password\",\"database\":\"staging_db\"}}" } } } } ``

Single Server Configuration

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

Using Multiple Servers

When multiple servers are configured, all tools accept an optional server parameter:

// List tables from production server
await list_tables({ server: "production" })

// Query staging server
await query({ 
  sql: "SELECT * FROM users LIMIT 10",
  server: "staging"
})

// Describe table on local server
await describe_table({ 
  table_name: "products",
  server: "local"
})

// If no server is specified, "default" is used
await list_tables() // Uses "default" server

Security

This server only allows readonly operations (SELECT, SHOW, DESCRIBE) for safety. All other SQL operations are blocked.

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Databases servers.