Skip to main content
Glama
rlembo06

mysql-mcp

by rlembo06

mysql-mcp

A lightweight MCP server that provides safe, read-only access to MySQL databases.

Features

  • Multi-database — connect to multiple MySQL instances, switch between them on the fly

  • Read-only — write operations (INSERT, UPDATE, DELETE, DROP, etc.) are blocked

  • Lazy connections — pools are created on first use, not at startup

  • MCP native — built on @modelcontextprotocol/sdk, works with any MCP client

Related MCP server: mcp-database

Setup

  1. Create a JSON config file with your database connections:

{
  "my-db": {
    "host": "db.example.com",
    "port": 3306,
    "user": "readonly",
    "password": "secret",
    "database": "mydb",
    "environment": "production",
    "ssl": false
  }
}
  1. Set the MYSQL_DATABASES_CONFIG environment variable pointing to that file.

  2. Run the server:

npx tsx index.ts

Tools

Tool

Description

list_connections

List all configured databases and the active one

use_connection

Switch the active database connection

query

Execute a read-only SQL query

MCP Client Configuration

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["tsx", "/path/to/mysql-mcp/index.ts"],
      "env": {
        "MYSQL_DATABASES_CONFIG": "/path/to/databases.json"
      }
    }
  }
}

License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Read-only MySQL/MariaDB MCP server for running SELECT queries safely, with automatic read-only enforcement and query limits.
    3
    6 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A readonly MCP server for MySQL databases that ensures safety by whitelisting only SELECT, SHOW, DESCRIBE, and EXPLAIN statements, with table blacklist support and configurable limits.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A secure, read-only MySQL database proxy using MCP protocol, enabling SQL queries and table inspections via HTTP.
    10 npm
    1
    MIT