easy-mysql-mcp
Enables AI assistants to inspect and query a MySQL database through safe, structured tools, including schema discovery and read-only queries.
README
easy-mysql-mcp
A lightweight Model Context Protocol (MCP) server that lets AI assistants inspect and query a MySQL database through a safe, structured tool interface.
This project uses Node.js, TypeScript, the official MCP SDK, and mysql2/promise. It runs over stdio, so it can be used directly by MCP clients such as Claude Desktop.
Features
- MySQL connection pooling powered by
mysql2/promise - Read-only query tool for data retrieval
- Execute tool for data modification statements
- Schema discovery tools for tables, views, indexes, and triggers
- Query plan inspection with
EXPLAIN - Current user and privilege inspection
- stdout protection to prevent non-MCP logs from polluting the stdio protocol
Requirements
- Node.js 18 or newer
- npm
- A reachable MySQL-compatible database
Installation
Run the server directly with npx:
npx -y easy-mysql-mcp
For local development after cloning the repository:
cd easy-mysql-mcp
npm install
npm run build
Configuration
Configure the server with environment variables. You can provide them through your MCP client configuration or by creating a local .env file.
| Variable | Required | Default | Description |
|---|---|---|---|
MYSQL_HOST |
Yes | - | MySQL host name or IP address |
MYSQL_PORT |
No | 3306 |
MySQL port |
MYSQL_USER |
Yes | - | MySQL user name |
MYSQL_PASSWORD |
Yes | - | MySQL password |
MYSQL_DATABASE |
Yes | - | Default database/schema |
MYSQL_CONNECTION_LIMIT |
No | 10 |
Maximum number of active pool connections |
MYSQL_MAX_IDLE |
No | 10 |
Maximum number of idle pool connections |
MYSQL_IDLE_TIMEOUT |
No | 60000 |
Idle connection timeout in milliseconds |
MYSQL_QUEUE_LIMIT |
No | 0 |
Maximum queued connection requests, where 0 means unlimited |
MYSQL_WAIT_FOR_CONNECTIONS |
No | true |
Whether the pool waits when all connections are busy |
MYSQL_ENABLE_KEEP_ALIVE |
No | true |
Whether TCP keep-alive is enabled |
MYSQL_KEEP_ALIVE_INITIAL_DELAY |
No | 0 |
Initial TCP keep-alive delay in milliseconds |
Example .env:
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database
Usage
Configure your MCP client to launch the package through npx.
For local development, build the TypeScript source first:
npm run build
Start the MCP server:
npm start
The server communicates over stdio and is normally launched by an MCP client rather than run manually.
Claude Desktop Example
Add the server to your claude_desktop_config.json:
{
"mcpServers": {
"easy-mysql-mcp": {
"command": "npx",
"args": ["-y", "easy-mysql-mcp"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}
Restart Claude Desktop after updating the configuration.
Available Tools
| Tool | Description |
|---|---|
mysql_query |
Execute a SQL query intended for data retrieval, such as SELECT |
mysql_execute |
Execute a data modification statement, such as INSERT, UPDATE, or DELETE |
explain_query |
Run EXPLAIN for a SQL query and return the execution plan |
list_tables |
List base tables in the current database, including approximate row counts and comments |
list_views |
List views in the current database |
describe_table |
Show column information for one or more tables |
describe_index |
Show indexes for a table |
list_triggers |
List triggers in the current database |
get_current_privileges |
Show the current MySQL user and grants |
Security Notes
- Use a dedicated MySQL user with the minimum permissions your assistant needs.
- Prefer read-only database credentials if you only need inspection and reporting.
- Be careful with
mysql_execute, because it can modify data. - Do not commit
.envfiles or real database credentials to GitHub. - Review generated SQL before running it against production data.
Development
npm run dev
This runs TypeScript in watch mode.
To create a production build:
npm run build
Project Structure
src/
db.ts MySQL pool and query helpers
index.ts MCP server and tool registration
proxy.ts stdout protection for stdio-based MCP transport
License
ISC
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。