MySQL MCP Server
Provides structured MySQL database operations for Claude Desktop, converting natural language requests into safe, parameterized queries.
README
MySQL MCP Server
A Model Context Protocol (MCP) server that provides structured MySQL database operations for Claude Desktop. Converts natural language database requests into safe, parameterized queries.
Features
- 7 tools:
list_tables,describe_table,fetch,update,delete,truncate,modify_bulk - Safety first: No raw SQL, parameterized queries, identifier sanitization
- Guard rails: UPDATE/DELETE require filters, TRUNCATE requires confirmation
- Preview mode: Bulk operations show impact before executing
- Stdio transport: Designed for Claude Desktop integration
Project Structure
mysql-mcp/
├── package.json
└── src/
├── index.js # MCP server entry point (stdio transport)
├── db.js # MySQL connection pool
├── tools.js # Tool definitions (JSON Schema)
└── handlers.js # Tool execution logic + safety checks
Setup
1. Install dependencies
cd mysql-mcp
npm install
2. Configure Claude Desktop
Open your Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
Add this to the mcpServers section:
{
"mcpServers": {
"mysql": {
"command": "node",
"args": ["D:/100xDev/mysql-mcp/src/index.js"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "3306",
"DB_USER": "root",
"DB_PASSWORD": "your_password_here",
"DB_NAME": "your_database_name"
}
}
}
}
Important: Use the full absolute path to
index.jsin theargsarray. Update theenvvalues to match your MySQL setup.
3. Restart Claude Desktop
Close and reopen Claude Desktop. You should see the MySQL tools available in the tools menu.
Available Tools
| Tool | Description |
|---|---|
list_tables |
Show all tables in the database |
describe_table |
Show column structure of a table |
fetch |
SELECT with filters, sorting, pagination |
update |
UPDATE with required filters |
delete |
DELETE with required filters |
truncate |
Drop all rows (requires confirm: true) |
modify_bulk |
Deduplicate, normalize, or cleanup data |
Safety Rules
- No raw SQL — All queries are built from structured input
- Identifier sanitization — Table/column names are validated against
[a-zA-Z_][a-zA-Z0-9_]* - Parameterized queries — All values use
?placeholders (no SQL injection) - UPDATE requires filters — Cannot update all rows accidentally
- DELETE requires filters — Cannot delete all rows accidentally
- TRUNCATE requires confirmation — Must pass
confirm: true - Bulk operations preview first — Shows impact before executing
- Row limit cap — Fetch is capped at 1000 rows max
Example Prompts
Once connected in Claude Desktop, you can use natural language:
- "Show me all tables"
- "What columns does the users table have?"
- "Get all users where status is active"
- "Update the name to 'Zoher' where id is 5"
- "Delete all orders where status is cancelled"
- "Find duplicate entries in users by email"
- "Normalize status values: replace 'actve' with 'active' in users"
Environment Variables
| Variable | Default | Description |
|---|---|---|
DB_HOST |
localhost |
MySQL host |
DB_PORT |
3306 |
MySQL port |
DB_USER |
root |
MySQL username |
DB_PASSWORD |
password |
MySQL password |
DB_NAME |
test_db |
Database name |
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.