MySQL MCP Server
Enables interaction with a MySQL database via JSON commands, supporting read-only queries, test execution of write queries, and table information retrieval through Docker.
xiangma9712
Tools
query
読み取り専用のSQLクエリを実行します。
test_execute
SQLが実行可能か確認し、最後にロールバックします。
list_tables
データベース内のテーブル一覧を取得します。
describe_table
テーブルのカラム情報を取得します。
README
MySQL MCP Server
An MCP server for interacting with MySQL databases.
This server supports executing read-only queries (query) and write queries that are ultimately rolled back (test_execute).
<a href="https://glama.ai/mcp/servers/kucglstegf"> <img width="380" height="200" src="https://glama.ai/mcp/servers/kucglstegf/badge" alt="MySQL Server MCP server" /> </a>
Setup
Environment Variables
Add the following environment variables to ~/.mcp/.env
:
MYSQL_HOST=host.docker.internal # Hostname to access host services from Docker container
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=your_password
Note:
host.docker.internal
is a special DNS name for accessing host machine services from Docker containers. Use this setting when connecting to a MySQL server running on your host machine. If connecting to a different MySQL server, change to the appropriate hostname.
mcp.json Configuration
{
"mcpServers": {
"mysql": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--add-host=host.docker.internal:host-gateway",
"--env-file",
"/Users/username/.mcp/.env",
"ghcr.io/xiangma9712/mcp/mysql"
]
}
}
}
Usage
Starting the Server
docker run -i --rm --add-host=host.docker.internal:host-gateway --env-file ~/.mcp/.env ghcr.io/xiangma9712/mcp/mysql
Note: If you're using OrbStack,
host.docker.internal
is automatically supported, so the--add-host
option can be omitted. While Docker Desktop also typically supports this automatically, adding the--add-host
option is recommended for better reliability.
Available Commands
1. Execute Read-only Query
{
"type": "query",
"payload": {
"sql": "SELECT * FROM your_table"
}
}
Response:
{
"success": true,
"data": [
{
"id": 1,
"name": "example"
}
]
}
2. Test Query Execution
{
"type": "test_execute",
"payload": {
"sql": "UPDATE your_table SET name = 'updated' WHERE id = 1"
}
}
Response:
{
"success": true,
"data": "The UPDATE SQL query can be executed."
}
3. List Tables
{
"type": "list_tables"
}
Response:
{
"success": true,
"data": ["table1", "table2", "table3"]
}
4. Describe Table
{
"type": "describe_table",
"payload": {
"table": "your_table"
}
}
Response:
{
"success": true,
"data": [
{
"Field": "id",
"Type": "int(11)",
"Null": "NO",
"Key": "PRI",
"Default": null,
"Extra": ""
},
{
"Field": "name",
"Type": "varchar(255)",
"Null": "YES",
"Key": "",
"Default": null,
"Extra": ""
}
]
}
Implementation Details
- Implemented in TypeScript
- Uses mysql2 package
- Runs as a Docker container
- Accepts JSON commands through standard input
- Returns JSON responses through standard output
- Uses
host.docker.internal
to connect to host MySQL (compatible with both OrbStack and Docker Desktop)
Security Considerations
- Uses environment variables for sensitive information management
- SQL injection prevention is the implementer's responsibility
- Proper network configuration required for production use
- Appropriate firewall settings needed when connecting to host machine services
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.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Supabase MCP Server
A Model Context Protocol (MCP) server that provides programmatic access to the Supabase Management API. This server allows AI models and other clients to manage Supabase projects and organizations through a standardized interface.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor
MCP DuckDB Knowledge Graph Memory Server
A memory server for Claude that stores and retrieves knowledge graph data in DuckDB, enhancing performance and query capabilities for conversations with persistent user information.