MCP MySQL Server
Enables Claude Desktop to interact with MySQL databases through secure query execution, schema discovery, and multi-database support with configurable read/write permissions and built-in SQL injection protection.
README
MCP MySQL Server
A clean, simple, and well-organized Model Context Protocol (MCP) server for MySQL database interactions with Claude Desktop.
Features
- š Query Execution: Run SQL queries with proper validation and security
- šļø Multi-Database Support: Switch between multiple databases easily
- š Security First: Read-only by default, configurable write permissions
- š Schema Discovery: Automatic database and table schema information
- ā” Connection Pooling: Efficient database connection management
- š”ļø Query Validation: Built-in SQL injection protection
- š Comprehensive Logging: Optional detailed logging for debugging
Quick Start
1. Clone and Install
git clone <your-repo-url>
cd mcp-mysql-server
npm install
2. Configure Environment
cp .env.example .env
# Edit .env with your MySQL credentials
3. Build
npm run build
4. Configure Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"mysql-server": {
"command": "node",
"args": ["/full/path/to/mcp-mysql-server/dist/index.js"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database",
"ENABLE_LOGGING": "true"
}
}
}
}
Configuration Options
Basic Connection
MYSQL_HOST: Database host (default: localhost)MYSQL_PORT: Database port (default: 3306)MYSQL_USER: Database username (default: root)MYSQL_PASSWORD: Database passwordMYSQL_DATABASE: Target database (leave empty for multi-DB mode)MYSQL_SOCKET_PATH: Unix socket path (optional, overrides host/port)
Security & Permissions
ALLOW_WRITE: Enable all write operations (default: false)ALLOW_INSERT: Enable INSERT statements (default: false)ALLOW_UPDATE: Enable UPDATE statements (default: false)ALLOW_DELETE: Enable DELETE statements (default: false)ALLOW_DDL: Enable DDL operations CREATE/ALTER/DROP (default: false)
Performance Settings
POOL_SIZE: Connection pool size (default: 10)QUERY_TIMEOUT: Query timeout in milliseconds (default: 30000)
Logging
ENABLE_LOGGING: Enable detailed logging (default: false)
Multi-Database Mode
Leave MYSQL_DATABASE empty to enable multi-database mode. This allows querying any database the MySQL user has access to.
Example queries in multi-DB mode:
-- Use qualified table names
SELECT * FROM database_name.table_name;
-- Switch databases
USE database_name;
SELECT * FROM table_name;
Security Best Practices
- Use Read-Only by Default: Only enable write operations when necessary
- Create Dedicated MySQL User: Don't use root account
- Limit Database Access: Grant permissions only to required databases
- Backup Before Writes: Always backup data before enabling write operations
- Monitor Query Logs: Enable logging to track database activities
Project Structure
src/
āāā config/ # Configuration management
āāā database/ # Database connection and management
āāā handlers/ # MCP request handlers
āāā types/ # TypeScript type definitions
āāā utils/ # Utility functions (logger, validator)
Development
# Development mode with auto-reload
npm run dev
# Watch mode for building
npm run watch
# Run tests
npm test
# Lint code
npm run lint
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.
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.
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.
E2B
Using MCP to run code via e2b.