MySQL

v1.0.0Databasesstable

Provides access to MySQL databases with fine-grained access control, supporting multiple databases simultaneously with configurable access modes (readonly, readwrite, full) and table-level permissions using whitelists, blacklists, wildcards, and rege

mcp-server-for-mysqlmcpai-integration
Share:
1,696
Stars
0
Downloads
0
Weekly
0/5

What is MySQL?

MySQL is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to provides access to mysql databases with fine-grained access control, supporting multiple databases simultaneously with configurable access modes (readonly, readwrite, full) and table-level permissions...

Provides access to MySQL databases with fine-grained access control, supporting multiple databases simultaneously with configurable access modes (readonly, readwrite, full) and table-level permissions using whitelists, blacklists, wildcards, and rege

This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Provides access to MySQL databases with fine-grained access

Use Cases

Access MySQL databases with fine-grained access control.
Manage multiple databases with configurable readonly, readwrite, and full access modes.
Apply table-level permissions using whitelists and blacklists.
benborla

Maintainer

LicenseMIT License
Languagejavascript
Versionv1.0.0
UpdatedMay 22, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-server-for-mysql

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use MySQL

MCP Server for MySQL gives AI assistants secure, fine-grained access to MySQL databases by exposing a `mysql_query` tool with configurable access controls and safety guardrails. It supports multiple simultaneous database connections, read-only mode by default (with explicit opt-in for INSERT, UPDATE, DELETE, and DDL), query rate limiting, SSL/TLS encryption, schema-level permission granularity using whitelists and blacklists, and SQL injection prevention through prepared statements. Database administrators and developers use it to let Claude query production or development databases without granting unrestricted access.

Prerequisites

  • Node.js 18+ installed
  • A running MySQL server (local or remote) with valid credentials
  • The database user should have the minimum required privileges for the intended access mode
  • An MCP-compatible client such as Claude Desktop or Claude Code
1

Install the package globally

Install the MCP server package from npm. The package name on npm is @benborla29/mcp-server-mysql.

npm install -g @benborla29/mcp-server-mysql
2

Add to Claude Code

Use the claude mcp add command to register the server and pass your database credentials as environment variables.

claude mcp add mcp_server_mysql \
  -e MYSQL_HOST="127.0.0.1" \
  -e MYSQL_PORT="3306" \
  -e MYSQL_USER="your_db_user" \
  -e MYSQL_PASS="your_db_password" \
  -e MYSQL_DB="your_database" \
  -- npx @benborla29/mcp-server-mysql
3

Configure Claude Desktop

Add the server block to your Claude Desktop configuration file with the required connection environment variables.

{
  "mcpServers": {
    "mcp_server_mysql": {
      "command": "npx",
      "args": ["-y", "@benborla29/mcp-server-mysql"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_db_user",
        "MYSQL_PASS": "your_db_password",
        "MYSQL_DB": "your_database"
      }
    }
  }
}
4

Enable write operations (optional)

By default only SELECT queries are allowed. To permit INSERT, UPDATE, or DELETE, explicitly set the corresponding environment variables to 'true'.

# Add these env vars to your config to enable write access:
ALLOW_INSERT_OPERATION=true
ALLOW_UPDATE_OPERATION=true
ALLOW_DELETE_OPERATION=false
ALLOW_DDL_OPERATION=false
5

Verify the connection

Restart your MCP client and ask Claude to list the tables in your database. If connected correctly, it will query the information_schema and return results.

MySQL Examples

Client configuration

Claude Desktop config with read-only access to a local MySQL database. Write operations remain disabled by default.

{
  "mcpServers": {
    "mcp_server_mysql": {
      "command": "npx",
      "args": ["-y", "@benborla29/mcp-server-mysql"],
      "env": {
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "readonly_user",
        "MYSQL_PASS": "your_password",
        "MYSQL_DB": "your_database",
        "ALLOW_INSERT_OPERATION": "false",
        "ALLOW_UPDATE_OPERATION": "false",
        "ALLOW_DELETE_OPERATION": "false",
        "MYSQL_RATE_LIMIT": "100"
      }
    }
  }
}

Prompts to try

Example prompts that use the mysql_query tool to explore schema, query data, and analyze database structure.

- "List all tables in the database and describe their columns"
- "Show me the 10 most recent orders from the orders table"
- "How many users signed up in the last 30 days?"
- "What are the foreign key relationships between the users and orders tables?"
- "Find all customers who have placed more than 5 orders"

Troubleshooting MySQL

Connection refused or ECONNREFUSED error

Verify MYSQL_HOST and MYSQL_PORT are correct and that the MySQL server is running. For Docker-based MySQL, use the container's actual IP or host.docker.internal instead of 127.0.0.1.

Access denied for user error from MySQL

Check that MYSQL_USER and MYSQL_PASS are correct and that the user has been granted appropriate privileges on MYSQL_DB. Run `GRANT SELECT ON your_database.* TO 'your_user'@'%';` in MySQL if needed.

Write queries fail even after setting ALLOW_INSERT_OPERATION=true

Ensure the env variable is the string 'true' not a boolean. Also verify the MySQL user account has INSERT/UPDATE/DELETE privileges on the target tables — the server respects both server-side controls and database-level permissions.

Frequently Asked Questions about MySQL

What is MySQL?

MySQL is a Model Context Protocol (MCP) server that provides access to mysql databases with fine-grained access control, supporting multiple databases simultaneously with configurable access modes (readonly, readwrite, full) and table-level permissions using whitelists, blacklists, wildcards, and rege It connects AI assistants to external tools and data sources through a standardized interface.

How do I install MySQL?

Follow the installation instructions on the MySQL GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with MySQL?

MySQL works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is MySQL free to use?

Yes, MySQL is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Databases MCP Servers

Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "mcp-server-for-mysql": { "command": "npx", "args": ["-y", "mcp-server-for-mysql"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use MySQL?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides