Repository navigation
MySQL Router
Value Proposition Maintain database reliability with advanced MySQL Router integrations. Gain real-time observability into InnoDB clusters, connection pools, and traffic routing to dynamically optimize performance and ensure high availability. Read the full value proposition.
- A recent version of MySQL Router with REST API enabled.
- Router REST API credentials (username/password)
- Network access to Router REST API endpoint (default: HTTPS on port 8443)
- For InnoDB Cluster mode: The cluster must be running for REST API authentication
Important
Router REST API typically authenticates against the InnoDB Cluster. Authentication fails with 401 errors if the cluster is down.
Empower your agents with intelligent traffic management. The server provides a robust suite of enterprise-grade tools for seamless MySQL Router orchestration. Direct users to the native MCP discovery mechanism or use the mysql_tool_index prompt to dump the complete tool catalog and identify the available tools within your context.
Prominent Examples:
-
mysql_router_status: Get Router process status and version.⚠️ -
mysql_router_routes: List all configured routes.⚠️ -
mysql_router_pool_status: Connection pool statistics. (Note:poolNamedefaults to "main". Ensureconnection_sharing=1is configured on your route definitions as a prerequisite. This ensures high availability and transparent failover during agent execution.)
Note
mysql_router_pool_status tool requires no cluster and operates independently only when using standalone file-based authentication.
Tip
Use the mysql_setup_router prompt to securely configure and test MySQL Router REST API integrations.
Note: All Router tools operate safely under the read OAuth scope and benefit from strict Zod schema validation (e.g., safeParse, z.infer) to ensure payload safety.
Bootstrapping Router against an InnoDB Cluster uses metadata_cache authentication. This authenticates API users against the metadata database.
1. Create REST API user in the cluster:
-- Connect to any cluster node
-- The user will be stored in mysql_innodb_cluster_metadata.router_rest_accounts# Use mysqlrouter_passwd to generate the password hash
mysqlrouter_passwd set /tmp/router_admin.pwd router_admin
# Manually read the generated hash from /tmp/router_admin.pwd and replace <hash_from_mysqlrouter_passwd> below
# Insert into cluster metadata (on PRIMARY node)
# Note: The -P 3307 port example assumes a specific high-availability cluster topology
mysql -h localhost -P 3307 -u cluster_admin -p -e "INSERT INTO mysql_innodb_cluster_metadata.router_rest_accounts(cluster_id, user, authentication_method, authentication_string, description) SELECT cluster_id, 'router_admin', 'modular_crypt_format', '<hash_from_mysqlrouter_passwd>', 'REST API user' FROM mysql_innodb_cluster_metadata.clusters LIMIT 1;"2. Router config uses metadata_cache backend:
[http_auth_backend:default_auth_backend]
backend=metadata_cacheFor standalone Router deployments without InnoDB Cluster:
[http_server]
port=8443
ssl=1
ssl_cert=/path/to/router-cert.pem
ssl_key=/path/to/router-key.pem
[http_auth_realm:default_auth_realm]
backend=default_auth_backend
method=basic
name=default_realm
[http_auth_backend:default_auth_backend]
backend=file
filename=/path/to/mysqlrouter.pwd
[rest_router]
require_realm=default_auth_realm
[rest_routing]
require_realm=default_auth_realm# Generate password hash (prompts for password)
mysqlrouter_passwd set /path/to/mysqlrouter.pwd router_adminSecure MySQL Router operations using OAuth validation. See the Authorization & Identity Management page for setup instructions.
| Variable | Default | Description |
|---|---|---|
MYSQL_ROUTER_URL |
https://localhost:8443 |
Router REST API base URL |
MYSQL_ROUTER_USER |
- | Router API username |
MYSQL_ROUTER_PASSWORD |
- | Router API password |
MYSQL_ROUTER_API_VERSION |
/api/20190715 |
API version path (represents standard REST API version) |
MYSQL_ROUTER_INSECURE |
false |
Skip TLS verification (for self-signed certs) |
Warning
Never commit Router credentials to version control. Use environment variables or secure secrets management.
{
"mcpServers": {
"mysql-mcp": {
"command": "npx",
"args": [
"-y",
"@neverinfamous/mysql-mcp",
"--transport",
"stdio",
"--allowed-io-roots",
"/data",
"--mysql",
"mysql://user:password@localhost:3306/database"
],
"env": {
"MYSQL_ROUTER_URL": "https://localhost:8443",
"MYSQL_ROUTER_USER": "router_admin",
"MYSQL_ROUTER_PASSWORD": "<YOUR_ROUTER_PASSWORD>",
"MYSQL_ROUTER_INSECURE": "true"
}
}
}
}Note
Global install users can replace "command": "npx" with "command": "mysql-mcp" and remove the npx-related arguments ("-y", "@neverinfamous/mysql-mcp") from the "args" array.
Warning
If plaintext credentials (like MYSQL_ROUTER_PASSWORD) are kept in the mcp.json config file, that file MUST be strictly excluded from version control.
For environments requiring workload isolation:
{
"mcpServers": {
"mysql-mcp": {
"command": "npx",
"args": [
"-y",
"@neverinfamous/mysql-mcp",
"--transport",
"stdio",
"--allowed-io-roots",
"/data",
"--mysql",
"mysql://user:password@localhost:3306/database",
"--tool-filter",
"router,-codemode"
]
}
}
}This exposes only the Router management tools.
Note
OAuth requires the http transport. Desktop clients (such as Claude Desktop and Cursor) using mcp.json and stdio cannot natively use OAuth. See Authorization & Identity Management for details.
Cause: Router REST API is unreachable or TLS handshake failed.
Solutions:
- Verify Router is running:
docker ps --filter "name=router" - Check Router logs:
docker logs mysql-router - Test API manually:
curl -k -u router_admin:router_password https://localhost:8443/api/<api-version>/router/status - Ensure
MYSQL_ROUTER_INSECURE=trueis set for self-signed certificates
Cause: Authentication failed. This usually means the InnoDB Cluster is not running.
Solutions:
- Start the InnoDB Cluster:
docker compose -f innodb-cluster.yml up -d - Reboot cluster from outage if needed:
dba.rebootClusterFromCompleteOutage() - Restart Router to reconnect:
docker restart mysql-router - Verify credentials match the
router_rest_accountstable
Cause: Cluster nodes are running but Group Replication is not active.
Solution: Reboot cluster from complete outage using MySQL Shell:
mysqlsh --uri cluster_admin:password@localhost:3307 --js \
-e "dba.rebootClusterFromCompleteOutage('clusterName', {force: true})"Cause: The connection pool name doesn't exist or connection pooling is disabled.
Solution: This is expected if Router lacks connection pooling configuration. The tool works correctly.
- Tools - Curated overview of available tools
- Tool Filtering - Custom tool filtering
- Configuration - General configuration
- Authorization & Identity Management - OAuth configuration
- MySQL Shell - Manage InnoDB Clusters with MySQL Shell
Unlock autonomous database orchestration with an enterprise-grade MySQL MCP server. Featuring blazing-fast sandboxed Code Mode, uncompromising schema enforcement, and seamless ecosystem integrations to power secure, intelligent AI workflows.
- Installation
- Configuration
- Architecture
- HTTP Transport
- Tool Filtering
- Code Mode
- Tools
- Prompts
- Resources
- Observability & Telemetry