
MySQL MCP Server
from aqaranewbiz
A MySQL server that connects to a database using environment variables for configuration.
MySQL MCP μλ²
μ΄ νλ‘μ νΈλ Smitheryμ Model Context Protocol (MCP)μ μ¬μ©νμ¬ MySQL λ°μ΄ν°λ² μ΄μ€μ μνΈμμ©νλ μλ²μ
λλ€.
Available Tools
1. connect_db
Establish connection to MySQL database using provided credentials.
use_mcp_tool({
server_name: "mysql",
tool_name: "connect_db",
arguments: {
host: "localhost",
user: "your_user",
password: "your_password",
database: "your_database"
}
});2. query
Execute SELECT queries with optional prepared statement parameters.
use_mcp_tool({
server_name: "mysql",
tool_name: "query",
arguments: {
sql: "SELECT * FROM users WHERE id = ?",
params: [1]
}
});3. execute
Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.
use_mcp_tool({
server_name: "mysql",
tool_name: "execute",
arguments: {
sql: "INSERT INTO users (name, email) VALUES (?, ?)",
params: ["John Doe", "john@example.com"]
}
});4. list_tables
List all tables in the connected database.
use_mcp_tool({
server_name: "mysql",
tool_name: "list_tables",
arguments: {}
});5. describe_table
Get the structure of a specific table.
use_mcp_tool({
server_name: "mysql",
tool_name: "describe_table",
arguments: {
table: "users"
}
});μ£Όμ κΈ°λ₯
- MySQL λ°μ΄ν°λ² μ΄μ€ μ°κ²° λ° μΏΌλ¦¬ μ€ν
- MCP νλ‘ν μ½μ ν΅ν νμ€νλ API μ 곡
- FastAPI κΈ°λ°μ RESTful API μλν¬μΈνΈ
- νκ²½ λ³μλ₯Ό ν΅ν μ€μ κ΄λ¦¬
μμνκΈ°
νμ μꡬμ¬ν
- Python 3.11 μ΄μ
- MySQL μλ²
- Docker (μ νμ¬ν)
νκ²½ μ€μ
.envνμΌ μμ±:
MYSQL_HOST=your_mysql_host
MYSQL_USER=your_mysql_user
MYSQL_PASSWORD=your_mysql_password
MYSQL_DATABASE=your_database_nameμ€μΉ λ°©λ²
λ‘컬 μ€μΉ (κΆμ₯)
- Python κ°μνκ²½ μμ± λ° νμ±ν:
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activate- μμ‘΄μ± μ€μΉ:
pip install -r requirements.txt- μλ² μ€ν:
python mcp_server.pyDocker μ€μΉ
- Docker μ΄λ―Έμ§ λΉλ:
docker build -t mysql-mcp-server .- 컨ν μ΄λ μ€ν:
docker run -e MYSQL_HOST=host -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db mysql-mcp-serverλ‘컬 κ°λ° μ€μ
- κ°λ° νκ²½ μ€μ :
# κ°λ°μ© μμ‘΄μ± μ€μΉ
pip install -r requirements-dev.txt # νμν κ²½μ° μμ±
# μ½λ ν¬λ§·ν
λ° λ¦°ν
μ€μ
pip install black flake8- μ½λ μ€ν:
# κ°λ° λͺ¨λλ‘ μ€ν
python mcp_server.py --dev- ν μ€νΈ μ€ν:
# ν
μ€νΈ μ€ν
python -m pytest tests/API μλν¬μΈνΈ
μλ² μ 보 μ‘°ν
GET /statusμλ²μ μνμ μ¬μ© κ°λ₯ν λꡬ λͺ©λ‘μ λ°νν©λλ€.
쿼리 μ€ν
POST /executeMySQL 쿼리λ₯Ό μ€ννκ³ κ²°κ³Όλ₯Ό λ°νν©λλ€.
κ°λ° κ°μ΄λ
νλ‘μ νΈ κ΅¬μ‘°
@MCP-Server-for-Smithery/
βββ mcp_server.py # λ©μΈ μλ² μ½λ
βββ requirements.txt # Python μμ‘΄μ±
βββ Dockerfile # Docker μ€μ
βββ .env # νκ²½ λ³μ (ν
νλ¦Ώ)
βββ tests/ # ν
μ€νΈ μ½λμλ‘μ΄ κΈ°λ₯ μΆκ°
mcp_server.pyμ μλ‘μ΄ λꡬ μΆκ°- νμν μμ‘΄μ±
requirements.txtμ μΆκ° - ν μ€νΈ μ½λ μμ±
- Docker μ΄λ―Έμ§ μ¬λΉλ (Docker μ¬μ© μ)
λ¬Έμ ν΄κ²°
μΌλ°μ μΈ λ¬Έμ
-
μ°κ²° μ€λ₯:
- MySQL μλ²κ° μ€ν μ€μΈμ§ νμΈ
- νκ²½ λ³μκ° μ¬λ°λ₯΄κ² μ€μ λμλμ§ νμΈ
- λ‘컬 μ€μΉ μ MySQL ν΄λΌμ΄μΈνΈ λΌμ΄λΈλ¬λ¦¬κ° μ€μΉλμ΄ μλμ§ νμΈ
-
쿼리 μ€ν μ€λ₯:
- SQL ꡬ문 κ²μ¬
- λ°μ΄ν°λ² μ΄μ€ κΆν νμΈ
- λ‘컬 μ€μΉ μ MySQL 컀λ₯ν° λ²μ νμΈ
λ‘κΉ
μλ²λ κΈ°λ³Έμ μΌλ‘ λ‘κ·Έλ₯Ό νμ€ μΆλ ₯μ κΈ°λ‘ν©λλ€. λ‘컬 μ€μΉ μ λ‘κ·Έ λ 벨μ μ‘°μ νλ €λ©΄:
python mcp_server.py --log-level DEBUGDockerλ₯Ό μ¬μ©νλ κ²½μ° λ‘κ·Έλ₯Ό νμΈνλ €λ©΄:
docker logs [container-id]κΈ°μ¬νκΈ°
- μ΄μ μμ±
- λΈλμΉ μμ± (
git checkout -b feature/AmazingFeature) - λ³κ²½μ¬ν μ»€λ° (
git commit -m 'Add some AmazingFeature') - λΈλμΉ νΈμ (
git push origin feature/AmazingFeature) - Pull Request μμ±
λΌμ΄μ μ€
μ΄ νλ‘μ νΈλ MIT λΌμ΄μ μ€ νμ λ°°ν¬λ©λλ€. μμΈν λ΄μ©μ LICENSE νμΌμ μ°Έμ‘°νμΈμ.
μ°λ½μ²
λ¬Έμμ¬νμ΄ μμΌμλ©΄ μ΄μλ₯Ό μμ±ν΄μ£ΌμΈμ.
npx -y @smithery/cli install @aqaranewbiz/mysql-aqaranewbiz --client claudeBefore it works, you'll need: MYSQL_HOSTMYSQL_USERMYSQL_PASSWORDMYSQL_DATABASE
Installation
Installing via Smithery
To install MySQL Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @aqaranewbiz/mysql-aqaranewbiz --client claudeManual Installation
npx @aqaranewbiz/mysql-aqaranewbizConfiguration
The server requires the following environment variables to be set in your MCP settings configuration file:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@aqaranewbiz/mysql-aqaranewbiz"],
"env": {
"MYSQL_HOST": "your_host",
"MYSQL_USER": "your_user",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}No common issues documented yet. If you hit a problem, the repository's GitHub Issues page is the best place to look.