Read-only MySQL access, with the database and server switchable mid-conversation.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent โ or use 1-click editor setup below.
One-click editor setup isnโt available for this listing yet โ we donโt have a confirmed install command, and weโd rather show nothing than point your editor at the wrong package or host. Follow the projectโs own setup instructions, linked above.
An MCP server that gives an AI assistant read-only access to MySQL, and lets it change database, server and credentials mid-conversation without restarting the client.
Most MySQL MCP servers read their connection from environment variables once at startup. Pointing one at a different database means editing a config file and restarting the assistant, which loses your conversation. This server keeps the connection as runtime state, so switching is just another tool call.
Runs from npm with npx, or entirely in Docker with nothing installed on your machine.
The server lives for the whole session, so the active connection is just state inside it. Switching selects a different pool rather than reconnecting, and switching back reuses a warm one.
Two ways to run it. npm is the shorter setup; Docker keeps the server inside a container.
Requires Node 22 or newer. There is no container in the way, so 127.0.0.1 means what you expect.
Use host.docker.internal to reach a MySQL running on the same machine as Docker. Inside the container, localhost means the container itself.
The container is the more isolated of the two: the server runs with only what the image and the environment give it. Over npm it runs directly on your machine with your user's access. Both enforce the same read-only guarantee.
Add to claude_desktop_config.json:
Or the same server in Docker:
Same shape, in .mcp.json at your project root:
Either form from the Claude Desktop section works here too.
Restart the client once. After that you never need to restart it to change database.
Credentials in these files sit on disk in plain text. Prefer a MySQL account with only
SELECTgrants, and keep the file out of version control. See Security.
Just ask. These map onto the connection tools:
"switch to the staging database" "what tables are in
analytics?" "connect to MySQL on 10.0.0.5 as reporting_user"
| Want | Restart? |
|---|---|
| Another database on the same server | No |
| Another named profile | No |
| A different server or credentials | No |
A new permanent profile in MYSQL_PROFILES | Yes, once |
A switch that fails verification is never committed, so the previous connection stays active and the session keeps working:
Define several connections up front with MYSQL_PROFILES, a JSON object:
Passed as a single environment variable:
host defaults to host.docker.internal, port to 3306, password to empty. user and database are required; a profile missing either is skipped with a warning rather than taking the server down.
The connect tool takes a host, user, password and database at runtime and keeps it for the rest of the session under an alias. Nothing is written to disk, and no restart is involved, so you never have to edit MYSQL_PROFILES just to look at one database once.
| Tool | Purpose |
|---|---|
current_connection | Which server and database is active |
list_connections | Available profiles, * marks the active one |
list_databases | Databases on the connected server |
use_database | Switch schema on the current server |
use_connection | Switch to a named profile, optional database override |
connect | Open any server with explicit credentials, optional alias |
| Tool | Purpose |
|---|---|
list_tables | Tables in the active database |
describe_table | Columns and types for one table |
get_table_indexes | Indexes for one table |
get_foreign_keys | Foreign key relationships for one table |
get_table_sample | Up to 50 sample rows |
run_query | One read-only statement |
Every reading tool also accepts an optional database, applied to that call only, leaving the active connection alone. Useful for comparing two databases without switching back and forth.
use_database, use_connection and connect each open the connection and run SELECT 1 before committing the switch, so a bad database name or unreachable host fails immediately. A failed switch leaves the previous connection active.
| Variable | Default | Purpose |
|---|---|---|
MYSQL_PROFILES | none | JSON object of named profiles |
MYSQL_DEFAULT_PROFILE | none | Which profile starts active |
MYSQL_HOST | host.docker.internal | Single-connection fallback |
MYSQL_PORT | 3306 | " |
MYSQL_USER | none | " |
MYSQL_PASSWORD | empty | " |
MYSQL_DATABASE | none | " |
MYSQL_QUERY_TIMEOUT_MS | 30000 | Statement timeout |
MYSQL_CONNECT_TIMEOUT_MS | 10000 | Connection timeout |
MYSQL_USER plus MYSQL_DATABASE register a profile named default. None of these are required: with no configuration at all the server still starts, and the tools tell you to call connect.
Starting profile: MYSQL_DEFAULT_PROFILE if it names a real profile, else default, else the first one defined.
Two independent layers keep this read-only, so a hole in one is not automatically a write.
No reviews yet โ be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/mysql-read-only-switchable)<a href="https://allmcps.com/mcp/mysql-read-only-switchable"><img src="https://allmcps.com/api/badge/mysql-read-only-switchable?style=directory" alt="MySQL (read Only, switchable) on AllMCPs" /></a>