mysql-mcp
A MySQL MCP server for local stdio clients, enabling database queries and management with read-only/write modes, audit logging, and configurable security.
README
mysql-mcp
Reusable MySQL MCP server for local stdio clients such as Codex and Claude Code.
Features
- MySQL access over stdio MCP
MYSQL_CONFIG_FILEsupport- direct environment override support
- allowed database enforcement
readonlyandwritemodes- sanitized audit logging
Tools
list_tablesdescribe_tablequeryexecute
Requirements
- Node.js 20+
- a built server entrypoint at
dist/index.js - a MySQL user with access only to the databases you intentionally allow
Install and build
npm install
npm run build
Required 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_FILE - built-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.jsonl
Example override:
MYSQL_MODE=write node dist/index.js
Mode 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.js
Development
npm test
npm run build
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.