MCP Server MySQL
Enables LLMs to interact with MySQL databases through standardized protocol, supporting database management, table operations, data queries, and modifications with configurable permission controls.
README
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 build
Configuration
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 # optional
Permission 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 DELETE
Or use the connect tool at runtime to specify connection parameters.
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 |
Connect to a MySQL database |
query |
Execute SELECT queries |
execute |
Execute INSERT/UPDATE/DELETE queries |
list_databases |
List all databases |
list_tables |
List tables in a database |
describe_table |
Get table structure |
create_table |
Create a new table |
alter_table |
Modify table structure |
drop_table |
Drop a table |
create_database |
Create a new database |
drop_database |
Drop a database |
use_database |
Switch to a database |
create_index |
Create an index |
drop_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
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.
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.
Neon Database
MCP server for interacting with Neon Management API and databases