MCP server for MySQL with read-only guardrails, row caps, and statement timeouts
Project description
database-mcp-mysql
MCP server giving AI clients safe, structured access to a MySQL database. Two tools, guardrails on by default.
Quick start (Claude Desktop / Claude Code / Cursor)
{
"mcpServers": {
"mysql": {
"command": "uvx",
"args": ["database-mcp-mysql"],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_USER": "youruser",
"MYSQL_PASSWORD": "yourpassword",
"MYSQL_DATABASE": "yourdb"
}
}
}
}
Configuration
Sources, highest precedence first: flags, --config YAML, environment
variables, defaults.
Environment variables
MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE,
or a full MYSQL_DSN (mysql://user:pass@host:3306/db, inline credentials
discouraged).
Password without plaintext
MYSQL_PASSWORD_FILE=/run/secrets/mysql_password(Docker/Kubernetes secrets convention)- In YAML:
connection.password: ${MYSQL_PASSWORD}(env expansion, never a literal)
The password is held in a non-printable type and redacted from all output.
Config file
--config /absolute/path/to/database-mcp.yaml:
connection:
host: 127.0.0.1
port: 3306
user: mcpuser
password: ${MYSQL_PASSWORD}
database: yourdb
guardrails:
readOnly: true
maxRows: 1000
queryTimeoutMs: 30000
Tools
execute_sql: run a single SQL statement. Returns a summary line and compact JSON{columns, rows}.search_objects: list tables with estimated row counts, or describe one table (columns, indexes, foreign keys).
Guardrails
- Read-only by default, enforced twice: a SQL guard plus
SET SESSION TRANSACTION READ ONLYat the server. Pass--allow-writeto enable writes. - Results capped at
maxRows(default 1000,MAX_ROWS). - Statements exceeding
queryTimeoutMs(default 30000,QUERY_TIMEOUT_MS) are aborted.
Full contract: docs/tool-contract.md
mcp-name: io.github.arifulislamat/database-mcp-mysql
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file database_mcp_mysql-0.1.0.tar.gz.
File metadata
- Download URL: database_mcp_mysql-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4f36189d0b745eb54ce04ddffd34bf97125cd9f65edf30fa587eb241d7c3137
|
|
| MD5 |
3cc7ce6d548cde902a8239cf77b0baec
|
|
| BLAKE2b-256 |
3cb4d12c65375a5d8a25a9f8da4a80322ee24ce3f45bbc233294bed186ea8860
|
File details
Details for the file database_mcp_mysql-0.1.0-py3-none-any.whl.
File metadata
- Download URL: database_mcp_mysql-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28871ca03ee8065752b235265edb24e7faca712094384890e0c617dfd44ed9d5
|
|
| MD5 |
6c66941922f410279733f00c2d888487
|
|
| BLAKE2b-256 |
dd56e61b7530fae264f0e73bddb6cfccc48be6d03a6fad905f6907543322dad1
|