A MySQL MCP server for your coding agent.
To give Claude Code, Cursor, Codex, or Copilot access to MySQL over MCP,
add the database to Valv Desktop and point your client at
http://127.0.0.1:4319/mcp. The agent can list, describe, and
query the tables you allow. It can't write, run raw SQL, or see columns
you hide, and it never receives your MySQL password.
Comparing servers? Jump to the comparison.
Setup
From a connection string to your first answer.
Valv holds the MySQL connection. Your MCP client only knows a local URL.
- 1
Add MySQL in Valv.
Paste a
mysql://connection string to fill host, port, user, password, and database, or type them in. Port defaults to 3306. Set SSL, test the connection, then save. The password goes to your OS keychain, not the workspace folder.mysql://valv_agent:password@host:3306/app - 2
Pick the active databases.
In MySQL a schema is a database. Valv starts with the one in your connection. Open the datasource's Active schemas menu in the sidebar to add others on the same server. System databases like
mysqlandinformation_schemaaren't listed. Only active databases reach the agent. - 3
Hide what the agent shouldn't see.
Open the datasource settings and switch to AI access. Hide columns like
users.emailororders.shipping_address. Hide every column to remove a table. You can still open that data yourself. - 4
Add Valv to your MCP client.
Open Settings, MCP Server, and copy the guide for your client. Port 4319 is the default. If it's taken, Valv uses another port, so copy the URL the app shows. Keep Valv open while you work.
Claude Code
CLIclaude mcp add --transport http valv-desktop http://127.0.0.1:4319/mcp Codex
CLIcodex mcp add valv-desktop --url http://127.0.0.1:4319/mcp GitHub Copilot
CLIcopilot mcp add --transport http valv-desktop http://127.0.0.1:4319/mcp Cursor, VS Code, and other clients
JSON{
"mcpServers": {
"valv-desktop": {
"type": "http",
"url": "http://127.0.0.1:4319/mcp"
}
}
} What the agent can do in your MySQL database.
The agent doesn't send SQL. It sends a structured query that Valv validates, compiles to MySQL SQL, and runs with bound parameters.
It can
- Find and describe the tables in the active databases.
- Filter, group, aggregate, sort, and follow relations between tables in one query.
- Chain several read queries in one step with
run_code, for example to combine two databases. - See real MySQL errors, such as
SELECT command denied, so it can tell you which grant is missing.
It can't
- Run raw SQL, so no
EXPLAIN,SHOW PROCESSLIST, or DDL. - Insert, update, or delete rows. There are no write tools.
- See hidden columns, or databases you didn't activate.
- Run a query for longer than 30 seconds. Valv sets a timeout on every agent query.
One tool set per database.
With one active database, the agent gets plain tool names. With
several, Valv prefixes each tool with the database name, so an
orders table in shop
and one in warehouse never collide. With
more than one datasource in the workspace, the datasource name comes
first.
Tools with shop and warehouse active
Dates come back as stored.
Valv reads DATE, DATETIME,
and TIMESTAMP values as strings, so the
agent sees the value MySQL returns, not one shifted into your
machine's time zone.
Large tables stay fast to open.
When you open a table in Valv's viewer, tables above about a million
rows show the estimate from information_schema
instead of running COUNT(*) on a big InnoDB
table.
MySQL user
Connect with a read-only user.
Valv's agent tools are already read-only. A dedicated user adds a limit that MySQL itself enforces, whatever runs on top of it.
- MySQL has no per-user read-only setting like Postgres's
default_transaction_read_only. The grants are the guard, so give this user nothing beyondSELECTandSHOW VIEW. - A grant on
app.*covers tables added later by migrations. Repeat it for each database you activate in Valv. - The host part is part of the account.
'%'accepts any host. Replace it with your IP to narrow it down, and use that same host in everyGRANT. REQUIRE SSLrejects unencrypted logins. Drop it for a local server with SSL set to Disable.- Valv's table viewer is read-only anyway, so a read-only user changes nothing for you in the app.
-- Run as root or a user with CREATE USER and GRANT OPTION.
CREATE USER 'valv_agent'@'%'
IDENTIFIED BY 'choose-a-strong-password'
REQUIRE SSL;
-- Read every table and view in the app database,
-- including tables created later.
GRANT SELECT, SHOW VIEW ON app.* TO 'valv_agent'@'%';
-- Check what the user can do.
SHOW GRANTS FOR 'valv_agent'@'%'; SSL and hosted MySQL.
Valv connects straight from your machine to the database, so the database has to be reachable from where you sit. There is no SSH tunnel option in the connection form. For a private network, use your VPN or open a tunnel yourself and point Valv at the local port. Valv gives up on a connection after 5 seconds.
The SSL field
| Disable | The default. Local MySQL in Docker or on localhost, or behind a local proxy. |
| Require | Hosted MySQL. Always encrypt, don't verify the certificate. |
| Verify full | Encrypt and check the certificate against your system's trusted CAs. |
SSL starts at Disable for MySQL, so switch it for anything that isn't on your machine.
ssh -N -L 3307:db.internal:3306 you@bastion
Then connect Valv to 127.0.0.1, port 3307.
PlanetScale
PlanetScale only accepts encrypted connections, so set SSL to Require. Instead of running CREATE USER, create a password with the Read-only role for the branch and use its host, username, and password in Valv.
Amazon RDS and Aurora MySQL
The instance must be reachable from your machine: publicly accessible with your IP in the security group, or through your VPN. Choose Require for SSL. Valv's form has no field for a custom CA certificate, so Verify full won't accept the RDS certificate.
Google Cloud SQL for MySQL
Either add your IP to the instance's authorized networks and use Require, or run the Cloud SQL Auth Proxy on your machine and point Valv at 127.0.0.1, port 3306, with SSL set to Disable. The proxy encrypts the connection. Use the proxy if the instance requires client certificates, since Valv has no field for them.
Valv or a standalone MySQL MCP server?
Standalone servers don't need a desktop app and can run on a server, in Docker, or in CI. Most pass SQL straight to MySQL, which gives the agent more power and leaves safety to your grants and their write flags. Valv trades raw SQL for validated queries and column-level hiding.
Valv Desktop
Desktop app, local HTTP endpoint
Read-only structured queries, per-column hiding
You want your agent and yourself looking at the same MySQL database, with a GUI, credentials in the OS keychain, and no raw SQL in the agent's hands.
mcp-server-mysql (benborla)
Node.js via npx, stdio or HTTP
Raw SQL, read-only unless you set ALLOW_INSERT_OPERATION and friends
You want a lightweight server in a project config, and sometimes want the agent to insert, update, or delete rows.
mysql_mcp_server (designcomputer)
Python via pip or uvx, stdio or HTTP
Raw SQL, including INSERT, UPDATE, and DELETE
You're in a Python setup and want the agent to run any statement. Pair it with a MySQL user that only has SELECT.
MCP Toolbox for Databases (Google)
Go binary or Docker, stdio or HTTP
Prebuilt execute_sql, or your own parameterized SQL tools in tools.yaml
You want query plans, lock and active query checks, or hand-written tools for Cloud SQL and self-hosted MySQL.
DBHub (Bytebase)
Node.js via npx or Docker, stdio or HTTP
Raw SQL with a read-only mode, row limits, and timeouts
You use MySQL next to Postgres, SQL Server, or Oracle and want one server for all of them, with an SSH tunnel built in.
@valv/mcp
npx, stdio or HTTP
Read-only structured queries, table filters, policy file
You want Valv's structured queries without the desktop app, for example in a project's .mcp.json with a mysql:// DATABASE_URL.
On PostgreSQL? See the Postgres MCP server guide. For other databases, see the database MCP guide.
MySQL MCP, answered
What is a MySQL MCP server?
A MySQL MCP server is a program that gives an AI agent tools for your MySQL database over the Model Context Protocol, usually table discovery and queries. Claude Code, Cursor, Codex, Copilot, and other MCP clients can then answer questions from your data without you copying results into the chat.
How do I connect Claude Code to MySQL with MCP?
Add the database to Valv Desktop, then run: claude mcp add --transport http valv-desktop http://127.0.0.1:4319/mcp. Keep Valv open. Claude Code can then list, describe, and query the tables in the active workspace. Copy the exact URL from Settings, MCP Server, in case Valv picked a different port.
Can the agent write to my MySQL database through Valv?
No. Valv gives MCP clients discovery tools and a structured, read-only query tool. There are no tools for raw SQL, INSERT, UPDATE, DELETE, or DDL. For a second line of defense, connect Valv with a MySQL user that only has SELECT and SHOW VIEW grants.
Can the agent query more than one MySQL database?
Yes. Valv starts with the database from your connection. Add others from the datasource's Active schemas menu in the sidebar. Each active database gets its own set of tools, prefixed with its name. The MySQL user needs SELECT on each of them.
Does it work with MariaDB, PlanetScale, or Amazon RDS?
Valv's MySQL connection also covers MariaDB. It connects with a host, port, user, password, database, and SSL setting, or a pasted mysql:// connection string, so any hosted MySQL your machine can reach works the same way. Use SSL Require for hosted databases.
Is Valv's MySQL MCP server free?
Valv Desktop is free for personal, non-commercial use, with every feature included. Commercial use needs a seat license, a one-time $99 per user.
Connect your agent to MySQL.
Free for personal use, every feature included. Commercial use needs a seat at beta pricing. See pricing.