mysql-mcp
Provides MySQL database access over MCP, enabling AI agents to list tables, describe schemas, run queries (read-only or write), and execute DML/DDL statements on allowed databases, with audit logging and security restrictions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mysql-mcplist all tables in the sales database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mysql-mcp
Reusable MySQL MCP server for local stdio clients such as Codex and Claude Code.
Features
MySQL access over stdio MCP
MYSQL_CONFIG_FILEsupportdirect environment override support
allowed database enforcement
readonlyandwritemodessanitized audit logging
Related MCP server: mysql-mcp
Tools
list_tablesdescribe_tablequeryexecute
Requirements
Node.js 20+
a built server entrypoint at
dist/index.jsa MySQL user with access only to the databases you intentionally allow
Install and build
npm install
npm run buildRequired environment
MYSQL_HOSTMYSQL_USERMYSQL_PASSWORDMYSQL_DATABASEMYSQL_ALLOWED_DATABASES
Optional environment
MYSQL_PORTDefault:3306MYSQL_MODEDefault:readonlyMYSQL_MAX_ROWSDefault:200MYSQL_QUERY_TIMEOUT_MSDefault:10000MYSQL_AUDIT_LOG_FILE
Configuration loading
The server can load values from MYSQL_CONFIG_FILE, then apply direct environment variable overrides on top.
Precedence:
direct environment variables
values inside
MYSQL_CONFIG_FILEbuilt-in defaults for optional settings
Example env file:
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USER=demo_user
MYSQL_PASSWORD=secret
MYSQL_DATABASE=demo_test_a
MYSQL_ALLOWED_DATABASES=demo_test_a,demo_test_b
MYSQL_MODE=readonly
MYSQL_MAX_ROWS=200
MYSQL_QUERY_TIMEOUT_MS=10000
MYSQL_AUDIT_LOG_FILE=/Users/your-user/.codex/logs/mysql-mcp-audit.jsonlExample override:
MYSQL_MODE=write node dist/index.jsMode behavior
readonlyquery,list_tables, anddescribe_tableare available for read-only SQL use. Write statements, server-scopedSHOWstatements, and directinformation_schemareads are rejected.writeexecuteis allowed only for database-scoped DML plus table/view DDL, subject to the configured database allowlist. Procedures, triggers, functions, events, server-scoped admin statements, andinformation_schemareferences are rejected.
Safety notes
Keep
MYSQL_ALLOWED_DATABASESlimited to explicitly approved databases.If
MYSQL_MODE=write, use only test or disposable databases.Do not point write mode at production, staging, UAT, or any shared non-test database.
The guard layer blocks table and view references outside the configured allowlist, rejects direct
information_schemareads fromquery, rejects anyinformation_schemareference fromexecute, and rejects server-scopedSHOWandUSERadmin statements.The
executetool supportsINSERT,UPDATE,DELETE,TRUNCATE,RENAME TABLE, andCREATE/ALTER/DROPfor tables and views only.Audit logs store sanitized statement summaries by default instead of raw SQL text or literals.
Codex example
[mcp_servers.mysql_local_dev]
command = "node"
args = ["/Users/your-user/Documents/development/iclaw-workspace/tools/mcp/mysql-mcp/dist/index.js"]
env = { MYSQL_CONFIG_FILE = "/Users/your-user/.codex/mysql-local-dev.env" }
default_tools_approval_mode = "prompt"Claude Code example
claude mcp add --transport stdio mysql_local_dev \
--env MYSQL_CONFIG_FILE=/Users/your-user/.codex/mysql-local-dev.env \
-- node /Users/your-user/Documents/development/iclaw-workspace/tools/mcp/mysql-mcp/dist/index.jsDevelopment
npm test
npm run buildThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides read-only access to MySQL databases.454469MIT
- Alicense-qualityDmaintenanceA lightweight MCP server providing safe, read-only access to MySQL databases. It enables users to query multiple MySQL instances securely while preventing write operations.848MIT
- Alicense-qualityCmaintenanceA production-ready MCP server for MySQL database operations, providing secure HTTP endpoints for read-only queries, performance analysis, and server monitoring.609MIT
- FlicenseCqualityCmaintenanceA MySQL MCP server providing tools to query and explore MySQL databases via stdio transport.7
Related MCP Connectors
MCP server for managing Prisma Postgres.
Read-only MCP server for ClassQuill, a tutoring-business-management platform.
GibsonAI MCP server: manage your databases with natural language
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/eastgatedev/mysql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server