
How to add MySQL MCP Server to Claude Desktop
Secure, structured access to MySQL databases for AI clients — query, sample, and inspect schemas via MCP. Paste the config into ~/Library/Application Support/Claude/claude_desktop_config.json and restart Claude Desktop.
Last updated June 14, 2026 · 1.3k★ · stdio · no auth
Claude Desktop config for MySQL MCP Server
pip install mysql-mcp-server{
"mcpServers": {
"mysql-mcp-server": {
"command": "uv",
"args": [
"--directory",
"path/to/mysql_mcp_server",
"run",
"mysql_mcp_server"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "your_username",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}Setup steps
- 1Open Claude Desktop → Settings → Developer → Edit Config (this opens ~/Library/Application Support/Claude/claude_desktop_config.json).
- 2Paste the MySQL MCP Server config below under the top-level "mcpServers" key.
- 3Fill in any placeholder secrets (API keys, paths) in the snippet.
- 4Save the file, then fully quit and reopen Claude Desktop.
- 5Open a chat and confirm MySQL MCP Server's tools appear under the 🔌 tools menu.
Before you start
- Python with pip (or uv/uvx) to install and run the server
- A running MySQL database with reachable host/port
- MySQL credentials supplied via MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD (and optionally MYSQL_DATABASE) environment variables
- uv installed when using the uv/uvx-based config
What MySQL MCP Server can do in Claude Desktop
execute_sqlExecutes any standard SQL query. Argument: query (string). Supports SELECT, SHOW, DESCRIBE, and DML (INSERT, UPDATE, DELETE); DML operations are marked with a destructive hint. Single statements only — multi-statement queries are not supported. Use database.table notation to query any database regardless of the MYSQL_DATABASE setting.
get_schema_infoProvides detailed metadata about database structures. Argument: table_name (optional string). Outputs column names, types, nullability, default values, and comments. Pass database.table for cross-database lookups; bare names use the configured database. Identifiers must contain only alphanumeric characters, underscores, and $ (a dot is allowed as a database/table separator).
get_table_sampleFetches a representative sample of data. Arguments: table_name (string), limit (optional integer, max 20). Useful for quickly understanding data formats and content without fetching large result sets. Pass database.table for cross-database sampling; bare names use the configured database. Same identifier validation rules as get_schema_info.
Security
Requires database access to function. Table/database identifiers passed to get_schema_info and get_table_sample are validated against a strict whitelist (alphanumeric, underscore, and $; a single dot allowed as database.table separator) to prevent SQL injection. Supports SSL/TLS and SSH tunneling for encrypted remote connections. Passwords and SSH private keys are masked in logs. Use a dedicated MySQL user with minimal permissions; never use root or administrative credentials. See SECURITY.md for hardening guidance.
MySQL MCP Server + Claude Desktop FAQ
Where is the Claude Desktop config file?
Claude Desktop reads MCP servers from ~/Library/Application Support/Claude/claude_desktop_config.json. Paste the MySQL MCP Server config there under the "mcpServers" key and restart the client.
Is MySQL MCP Server safe to use with Claude Desktop?
Requires database access to function. Table/database identifiers passed to get_schema_info and get_table_sample are validated against a strict whitelist (alphanumeric, underscore, and $; a single dot allowed as database.table separator) to prevent SQL injection. Supports SSL/TLS and SSH tunneling for encrypted remote connections. Passwords and SSH private keys are masked in logs. Use a dedicated MySQL user with minimal permissions; never use root or administrative credentials. See SECURITY.md for hardening guidance.
Which transports are supported?
Both standard input/output (STDIO) and Streamable HTTP (SSE). SSE mode (MCP_TRANSPORT=sse) is recommended for remote/self-hosted deployments.
Why do I see 'Missing required database configuration' in Claude Desktop/Code?
Those hosts launch the server from their own working directory, so a project .env file is not found. Put your MYSQL_* values in the env block of the MCP config instead of relying on .env.
Can I query more than one database?
Yes. Omit MYSQL_DATABASE to enable multi-database mode; list_resources then returns all user databases and you use fully qualified database.table names in queries. Only single SQL statements are supported.