loading…
Search for a command to run...
loading…
Enables AI assistants to inspect and query a MySQL database through safe, structured tools, including schema discovery and read-only queries.
Enables AI assistants to inspect and query a MySQL database through safe, structured tools, including schema discovery and read-only queries.
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.
mysql2/promiseEXPLAINRun 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
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
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.
{
"mcpServers": {
"easy-mysql-mcp": {
"command": "npx",
"args": ["-y", "easy-mysql-mcp"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "YOUR USERNAME",
"MYSQL_PASSWORD": "YOUR PASSWORD",
"MYSQL_DATABASE": "YOUR DB NAME"
}
}
}
}
Restart Claude Desktop after updating the configuration.
[mcp_servers.easy-mysql-mcp]
args = ["-y", "easy-mysql-mcp"]
command = "npx"
enabled = true
[mcp_servers.easy-mysql-mcp.env]
MYSQL_HOST = "localhost"
MYSQL_PORT = "3306"
MYSQL_USER = "YOUR USERNAME"
MYSQL_PASSWORD = "YOUR PASSWORD"
MYSQL_DATABASE = "YOUR DB NAME"
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"easy-mysql-mcp": {
"type": "local",
"command": ["npx", "-y", "easy-mysql-mcp"],
"enabled": true,
"environment": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "YOUR USERNAME",
"MYSQL_PASSWORD": "YOUR PASSWORD",
"MYSQL_DATABASE": "YOUR DB NAME",
},
},
},
}
| 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 |
mysql_execute, because it can modify data..env files or real database credentials to GitHub.npm run dev
This runs TypeScript in watch mode.
To create a production build:
npm run build
src/
db.ts MySQL pool and query helpers
index.ts MCP server and tool registration
proxy.ts stdout protection for stdio-based MCP transport
ISC
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"easy-mysql-mcp": {
"command": "npx",
"args": []
}
}
}Query your database in natural language
автор: AnthropicRead-only database access with schema inspection.
автор: modelcontextprotocolInteract with Redis key-value stores.
автор: modelcontextprotocolDatabase interaction and business intelligence capabilities.
автор: modelcontextprotocolНе уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории data