This repository contains MCP server projects. It currently includes:
mysql-mcp-server: a Python-based Model Context Protocol server that gives MCP clients controlled access to a MySQL database.
mysql-mcp-server exposes MySQL operations to Claude Desktop or any other MCP-compatible client over stdio. It is designed for practical database work while keeping the server surface constrained and predictable.
It can:
- inspect databases with read tools such as
query,list_tables,describe_table, andserver_info - perform controlled writes with
insert,update, anddelete - inspect and manage schema with
explain,list_indexes,table_stats, andexecute_ddl - run multiple statements atomically with
execute_transaction
- Reads and writes are separated into dedicated tools.
- SQL operations are validated against an allowlist before execution.
- Single-statement tools reject stacked queries and obvious comment-based injection patterns.
- Parameterized execution is supported through
%splaceholders plusparams. UPDATEandDELETEare refused unless they include aWHEREclause.- Bare
SELECTstatements receive an automatic row limit by default. - A connection pool is used for database access, with retry handling for transient MySQL failures.
MYSQL_READ_ONLY=truecan lock the server down for exploratory use.
- Python 3.10+
- A reachable MySQL server
- The database name supplied through
MYSQL_DB
By default, the server uses:
- host:
localhost - port:
3306 - user:
root - password:
root
Those defaults can be changed with environment variables.
From the repository root:
pip install -e .\mysql-mcp-server$env:MYSQL_DB = "your_database"
python -m mysql_mcp.serverThe server stays in the foreground and communicates through MCP over stdio.
{
"mcpServers": {
"mysql": {
"command": "python",
"args": ["-m", "mysql_mcp.server"],
"cwd": "C:\\path\\to\\MCP-Server\\mysql-mcp-server",
"env": {
"MYSQL_DB": "your_database"
}
}
}
}| Variable | Default | Purpose |
|---|---|---|
MYSQL_DB |
required | Database name to connect to |
MYSQL_HOST |
localhost |
MySQL host |
MYSQL_PORT |
3306 |
MySQL port |
MYSQL_USER |
root |
MySQL user |
MYSQL_PASSWORD |
root |
MySQL password |
MYSQL_POOL_SIZE |
5 |
Connection pool size |
MYSQL_TIMEOUT |
10 |
Connection timeout in seconds |
MYSQL_MAX_ROWS |
1000 |
Auto-limit for bare SELECT queries; 0 disables it |
MYSQL_READ_ONLY |
false |
Blocks write operations when enabled |
ALLOWED_OPERATIONS |
common MySQL verbs | Comma-separated SQL operation allowlist |
query(sql, params?)list_tables()describe_table(table)server_info()
insert(sql, params?)update(sql, params?)delete(sql, params?)
explain(sql)list_indexes(table)table_stats(table)execute_ddl(sql)
execute_transaction(statements)
This project adds guardrails, but it is still a database-access server. Use a least-privilege MySQL account in real environments, narrow ALLOWED_OPERATIONS to the actions you actually need, and enable read-only mode whenever writes are unnecessary.
For the full package-specific documentation, see mysql-mcp-server/README.md.