database-mcp-mysql
MCP server by arifulislamat Community
Database-mcp-mysql is an MCP server that gives AI clients structured, guarded access to MySQL databases. It is published for npm, PyPI and Rust, and suits developers who want read-only SQL access by default.
Install database-mcp-mysql
Built from the published package, never by AI.
claude mcp add database-mcp-mysql -e MYSQL_HOST=YOUR_MYSQL_HOST -e MYSQL_USER=YOUR_MYSQL_USER -e MYSQL_DATABASE=YOUR_MYSQL_DATABASE -- npx -y @database-mcp/mysqlRun in your terminal. Add --scope user to use it in every project.
{
"mcpServers": {
"database-mcp-mysql": {
"env": {
"MYSQL_HOST": "YOUR_MYSQL_HOST",
"MYSQL_USER": "YOUR_MYSQL_USER",
"MYSQL_DATABASE": "YOUR_MYSQL_DATABASE"
},
"args": [
"-y",
"@database-mcp/mysql"
],
"command": "npx"
}
}
}Settings, Developer, Edit config. Paste into claude_desktop_config.json and restart.
{
"mcpServers": {
"database-mcp-mysql": {
"env": {
"MYSQL_HOST": "YOUR_MYSQL_HOST",
"MYSQL_USER": "YOUR_MYSQL_USER",
"MYSQL_DATABASE": "YOUR_MYSQL_DATABASE"
},
"args": [
"-y",
"@database-mcp/mysql"
],
"command": "npx"
}
}
}Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project).
{
"servers": {
"database-mcp-mysql": {
"env": {
"MYSQL_HOST": "YOUR_MYSQL_HOST",
"MYSQL_USER": "YOUR_MYSQL_USER",
"MYSQL_DATABASE": "YOUR_MYSQL_DATABASE"
},
"args": [
"-y",
"@database-mcp/mysql"
],
"command": "npx"
}
}
}Add to .vscode/mcp.json. VS Code uses "servers", not "mcpServers".
codex mcp add database-mcp-mysql --env MYSQL_HOST=YOUR_MYSQL_HOST --env MYSQL_USER=YOUR_MYSQL_USER --env MYSQL_DATABASE=YOUR_MYSQL_DATABASE -- npx -y @database-mcp/mysql{
"mcpServers": {
"database-mcp-mysql": {
"env": {
"MYSQL_HOST": "YOUR_MYSQL_HOST",
"MYSQL_USER": "YOUR_MYSQL_USER",
"MYSQL_DATABASE": "YOUR_MYSQL_DATABASE"
},
"args": [
"-y",
"@database-mcp/mysql"
],
"command": "npx"
}
}
}Add to ~/.gemini/config/mcp_config.json (all projects) or .agents/mcp_config.json (this project).
gemini mcp add database-mcp-mysql npx -y @database-mcp/mysqlGemini CLI was replaced by Antigravity CLI in June 2026 and remains only for enterprise licences and paid API keys.
MCP servers run with your permissions and can read what you give them access to. Some need an API key: check the README and add it under env in the database-mcp-mysql block.
About
database-mcp-mysql is the MySQL package in the database-mcp project by arifulislamat. It is an MCP server with two tools, execute_sql and search_objects. Called with no arguments, search_objects lists tables. Called with a table name, it returns columns, indexes and foreign keys. Connection details come from flags, a YAML config file or environment variables such as MYSQL_*.
Guardrails are on by default. Read-only mode is enforced by a conservative SQL guard and a session-level read-only setting. Rows are capped at 1000 and statements time out after 30 seconds. Passwords are kept in non-printable secret types, and DSNs are sanitized before logging. Credentials are never accepted through a tool call. The package is aimed at developers who want safe, structured SQL access for AI assistants.
Written from the project's README and checked against it.
Tools it gives your assistant
execute_sqlRuns SQL against the MySQL database with read-only mode, row caps and statement timeouts on by default.search_objectsLists tables when called with no arguments, or returns columns, indexes and foreign keys for a named table.
What you need
- Node.js for the npm package
- Python with uvx for the PyPI package
- Rust and cargo for the native binary
- A MySQL database with connection details in MYSQL_* environment variables
| Setting | Needed | What it is |
|---|---|---|
MYSQL_Environment variable | Required | Database host |
MYSQL_Environment variable | Required | Database user (a read-only user is recommended) |
MYSQL_Environment variable | Required | Database name |
MYSQL_Environment variable, secret | Optional | Database password (or use MYSQL_PASSWORD_FILE) |
From the publisher's entry in the official MCP Registry. Required settings are already in the install config below as placeholders.
Try asking
- List the tables in my MySQL database
- Show the columns and foreign keys for the orders table
- Run a read-only query that counts rows in the users table
Good to know
- Read-only mode is on by default.
- Results are capped at 1000 rows and statements time out after 30 seconds by default.
- Go support is planned but not yet available.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: README.md, package.json. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to database-mcp-mysql
All alternatives →Connects Supabase projects to AI assistants such as Cursor, Claude and Windsurf over the Model Context Protocol. It lets assistants manage tables, fetch config and query data in a Supabase project.
ArcadeDB MCP Server is the built-in Model Context Protocol server of the ArcadeDB multi-model database. It lets AI assistants and LLMs work with ArcadeDB's graph, document, time-series, vector and other data models. It suits people who already run ArcadeDB and want assistant access to it.
Connects MCP clients such as Claude Desktop, Cursor and VS Code to PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, ClickHouse and SQLite. It exposes two tools by default, with read-only mode and query timeouts available as guardrails.
MCP Toolbox for Databases is an open source MCP server that connects AI agents, IDEs and applications to enterprise databases. It provides prebuilt tools for exploring schemas and running queries, plus a framework for custom tools. It is aimed at developers building agents that need database access.
Connects AI agents, IDEs and applications to enterprise databases through the Model Context Protocol. Offers prebuilt database tools for MCP clients and a framework for building custom tools for production agents.
MongoDB MCP Server lets AI assistants interact with MongoDB databases and MongoDB Atlas. It is an official server from mongodb-js, run locally with npx or Docker. It works with self-managed deployments and Atlas clusters.
Compare with Supabase, ArcadeDB MCP Server or DBHub
database-mcp-mysql: common questions
Is it safe to let an AI run queries on MySQL?
Read-only mode is on by default, enforced by a SQL guard and a session-level read-only setting. Rows are capped at 1000 and statements time out after 30 seconds by default.
How are MySQL credentials handled?
Credentials come from flags, a YAML file, environment variables or mounted secret files, never from a chat prompt. Passwords use non-printable secret types and DSNs are sanitized before logging.
Is it available outside npm?
Yes. The same server is published on PyPI as database-mcp-mysql and on crates.io as database-mcp-rs-mysql.
How do I install database-mcp-mysql?
In Claude Code run claude mcp add database-mcp-mysql -e MYSQL_HOST=YOUR_MYSQL_HOST -e MYSQL_USER=YOUR_MYSQL_USER -e MYSQL_DATABASE=YOUR_MYSQL_DATABASE -- npx -y @database-mcp/mysql. For Claude Desktop, Cursor and VS Code, paste the config shown above and restart. See the install guides.
Is database-mcp-mysql the official server?
database-mcp-mysql is a community project by arifulislamat, not verified by a company domain.
Is database-mcp-mysql free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is database-mcp-mysql safe to use?
It scores 75 of 100. Grades: maintenance A, licence A, quality C. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to database-mcp-mysql?
Similar MCP servers: Supabase, ArcadeDB MCP Server, DBHub, MCP Toolbox for Databases.
Does database-mcp-mysql work with ChatGPT?
Not directly. It runs locally, and ChatGPT only connects to remote servers with a URL. Use it in Claude Code, Claude Desktop, Cursor, VS Code or Codex.
