Provides comprehensive MySQL database operations including database and table management, data querying and modification (SELECT, INSERT, UPDATE, DELETE), index management, and schema operations with configurable permission controls for write operations.
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., "@MCP Server MySQLshow me the first 10 rows from the users table"
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.
MCP Server MySQL
A Model Context Protocol (MCP) server that provides MySQL database operations. This server enables LLMs to interact with MySQL databases through a standardized protocol.
Features
Database Management: Create, drop, list, and switch databases
Table Operations: Create, alter, drop, describe, and list tables
Data Queries: Execute SELECT queries and retrieve results
Data Modification: Execute INSERT, UPDATE, DELETE statements
Index Management: Create and drop indexes
Installation
npm install
npm run buildConfiguration
Set environment variables for database connection:
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=your-password
export MYSQL_DATABASE=your-database # optionalPermission Controls
Control which write operations are allowed (all default to true):
export MYSQL_ALLOW_INSERT=true # Set to "false" to disable INSERT
export MYSQL_ALLOW_UPDATE=true # Set to "false" to disable UPDATE
export MYSQL_ALLOW_DELETE=false # Set to "false" to disable DELETEOr use the connect tool at runtime to specify connection parameters.
Supported AI Applications
This MCP server can be used with any application that supports the Model Context Protocol (MCP):
Claude Desktop - Anthropic's official desktop application
Claude Code - Anthropic's official CLI tool for developers
Cline - AI coding assistant VS Code extension
Zed - High-performance code editor with built-in AI
Any MCP-compatible application - MCP is an open protocol developed by Anthropic
Usage with Claude Desktop
Using npx (Recommended)
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@nilsir/mcp-server-mysql"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "your-database",
"MYSQL_ALLOW_INSERT": "true",
"MYSQL_ALLOW_UPDATE": "true",
"MYSQL_ALLOW_DELETE": "false"
}
}
}
}Using Local Installation
{
"mcpServers": {
"mysql": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-mysql/dist/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your-password",
"MYSQL_DATABASE": "your-database",
"MYSQL_ALLOW_INSERT": "true",
"MYSQL_ALLOW_UPDATE": "true",
"MYSQL_ALLOW_DELETE": "false"
}
}
}
}Available Tools
Tool | Description |
| Connect to a MySQL database |
| Execute SELECT queries |
| Execute INSERT/UPDATE/DELETE queries |
| List all databases |
| List tables in a database |
| Get table structure |
| Create a new table |
| Modify table structure |
| Drop a table |
| Create a new database |
| Drop a database |
| Switch to a database |
| Create an index |
| Drop an index |
Examples
Query data
Use the query tool with sql: "SELECT * FROM users WHERE active = ?"
and params: [true]Create a table
Use the create_table tool with:
- table: "users"
- columns: [
{"name": "id", "type": "INT", "primaryKey": true, "autoIncrement": true},
{"name": "email", "type": "VARCHAR(255)", "nullable": false},
{"name": "created_at", "type": "TIMESTAMP", "default": "CURRENT_TIMESTAMP"}
]Insert data
Use the execute tool with sql: "INSERT INTO users (email) VALUES (?)"
and params: ["user@example.com"]License
MIT
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.