zerogon1203/db-mcp-server
If you are the rightful owner of db-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project is a Model Context Protocol (MCP) Stdio server compatible with Cursor IDE, designed to return the table structure and relationships of MySQL or MariaDB databases.
ποΈ MCP Database Server
λ€μ€ λ°μ΄ν°λ² μ΄μ€ μ§μ MCP μλ² - Cursor IDE λ° Claudeμ μ°λ κ°λ₯ν Model Context Protocol μλ²
MySQL, PostgreSQLμ μ§μνλ κ°λ ₯ν λ°μ΄ν°λ² μ΄μ€ λΆμ λ° μκ°ν λꡬμ λλ€.
β¨ μ£Όμ κΈ°λ₯
π― λ€μ€ λ°μ΄ν°λ² μ΄μ€ μ§μ
- MySQL/MariaDB - μμ μ§μ
- PostgreSQL - μμ μ§μ
- SQLite - κΈ°λ³Έ μ§μ (μ€λΉ μ€)
π μκ°ν λꡬ
- Mermaid ERD μμ± - λ°μ΄ν°λ² μ΄μ€ μ€ν€λ§λ₯Ό Mermaid λ€μ΄μ΄κ·Έλ¨μΌλ‘
- λ§ν¬λ€μ΄ ν μ΄λΈ μμ½ - ν μ΄λΈ μ 보λ₯Ό κΉλν νλ‘ μ 리
- ASCII μ±λ₯ μ°¨νΈ - ν μ΄λΈ ν¬κΈ°μ μΈλ±μ€ ν¨μ¨μ±μ μκ°μ μΌλ‘
π λΆμ κΈ°λ₯
- μ€ν€λ§ λΆμ λ° μ‘°ν
- ν μ΄λΈλ³ ν΅κ³ μ 보
- μ±λ₯ λ³λͺ© μ§μ νμ§
- μΈλ±μ€ μ΅μ ν μ μ
- 쿼리 μ€ν κ³ν λΆμ
π¦ μ€μΉ
git clone <this-repo-url>
cd db-mcp-server
python -m venv venv
source venv/bin/activate # λλ venv\Scripts\activate (Windows)
pip install -r requirements.txt
βοΈ μ€μ
νκ²½λ³μ μ€μ
.env
νμΌμ μμ±νκ³ λ°μ΄ν°λ² μ΄μ€ μ 보λ₯Ό μ€μ νμΈμ:
cp .env.example .env
MySQL/MariaDB μ€μ
DB_TYPE=mysql
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=your_database
DB_CHARSET=utf8mb4
DB_PORT=3306
PostgreSQL μ€μ
DB_TYPE=postgresql
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=your_database
DB_PORT=5432
DB_SCHEMA=public
SQLite μ€μ
DB_TYPE=sqlite
DB_PATH=./database.sqlite
π μ¬μ©λ²
Cursor IDE μ°λ
MCP Server
μΆκ° β Transport: stdio
β Command: python main.py
νκ²½λ³μ κ°λ³ μ€μ :
{
"mcpServers": {
"db-mcp-server": {
"transport": "stdio",
"command": "/path/to/venv/bin/python",
"args": ["/path/to/db-mcp-server/main.py"],
"env": {
"DB_TYPE": "postgresql",
"DB_NAME": "your_db_name",
"DB_HOST": "localhost"
}
}
}
}
π οΈ μ¬μ© κ°λ₯ν λꡬλ€
π μ€ν€λ§ λꡬ
get_schema
- μ 체 λ°μ΄ν°λ² μ΄μ€ μ€ν€λ§ μ‘°νget_table_stats
- ν μ΄λΈλ³ ν΅κ³ μ 보get_sample_data
- μν λ°μ΄ν° μ‘°νget_column_stats
- 컬λΌλ³ μμΈ ν΅κ³
π λΆμ λꡬ
execute_query
- μμ ν μ½κΈ° μ μ© μΏΌλ¦¬ μ€νexplain_query
- 쿼리 μ€ν κ³ν λΆμoptimize_query
- 쿼리 μ΅μ ν μ μget_db_status
- λ°μ΄ν°λ² μ΄μ€ μν μ 보get_table_size
- ν μ΄λΈλ³ ν¬κΈ° μ 보get_index_usage
- μΈλ±μ€ μ¬μ© ν΅κ³analyze_performance
- μ±λ₯ λ³λͺ© μ§μ λΆμsuggest_indexes
- μΈλ±μ€ μμ± μ μoptimize_tables
- ν μ΄λΈ μ΅μ ν μ μ
π¨ μκ°ν λꡬ
generate_schema_mermaid
- Mermaid ERD λ€μ΄μ΄κ·Έλ¨ μμ±generate_tables_summary
- λ§ν¬λ€μ΄ ν μ΄λΈ μμ½generate_performance_report
- μ±λ₯ λΆμ 리ν¬νΈ (ASCII μ°¨νΈ ν¬ν¨)
π μ¬μ© μμ
μ€ν€λ§ μκ°ν
π μ¬μ©μ: "λ°μ΄ν°λ² μ΄μ€ μ€ν€λ§λ₯Ό ERDλ‘ λ³΄μ¬μ€"
π€ AI: generate_schema_mermaid() μ€ν β Mermaid λ€μ΄μ΄κ·Έλ¨ μ 곡
μ±λ₯ λΆμ
π μ¬μ©μ: "μ±λ₯ λ¬Έμ κ° μλμ§ λΆμν΄μ€"
π€ AI: analyze_performance() β generate_performance_report() μ€ν
β ASCII μ°¨νΈμ ν¨κ» μμΈν μ±λ₯ 리ν¬νΈ μ 곡
ν μ΄λΈ νν© μμ½
π μ¬μ©μ: "ν
μ΄λΈλ€ νν©μ μμ½ν΄μ€"
π€ AI: generate_tables_summary() μ€ν β λ§ν¬λ€μ΄ ν
μ΄λΈ μμ½ μ 곡
ποΈ νλ‘μ νΈ κ΅¬μ‘°
db-mcp-server/
βββ main.py # MCP μλ² λ©μΈ νμΌ
βββ .env.example # νκ²½λ³μ μμ νμΌ
βββ requirements.txt # Python μμ‘΄μ±
βββ adapters/ # λ°μ΄ν°λ² μ΄μ€ μ΄λν°
β βββ __init__.py
β βββ base.py # λ² μ΄μ€ μ΄λν° ν΄λμ€
β βββ mysql.py # MySQL/MariaDB μ΄λν°
β βββ postgresql.py # PostgreSQL μ΄λν°
βββ tools/ # MCP λꡬ λͺ¨λ
βββ __init__.py
βββ schema_tools.py # μ€ν€λ§ κ΄λ ¨ λꡬ
βββ analysis_tools.py # λΆμ κ΄λ ¨ λꡬ
βββ visualization_tools.py # μκ°ν κ΄λ ¨ λꡬ
π νμ₯μ±
μλ‘μ΄ λ°μ΄ν°λ² μ΄μ€ μΆκ°
adapters/
ν΄λμ μ μ΄λν° ν΄λμ€ μμ±DatabaseAdapter
λ² μ΄μ€ ν΄λμ€ μμ- νμν λ©μλλ€ κ΅¬ν
adapters/__init__.py
μ ν©ν 리 ν¨μμ μΆκ°
μλ‘μ΄ λꡬ μΆκ°
- ν΄λΉ μΉ΄ν
κ³ λ¦¬μ
tools/
λͺ¨λμ ν¨μ μΆκ° @mcp.tool()
λ°μ½λ μ΄ν°λ‘ λ±λ‘- μ΄λν°μ λ©μλλ₯Ό νμ©νμ¬ κ΅¬ν
π μꡬμ¬ν
- Python 3.8+
- λ°μ΄ν°λ² μ΄μ€:
- MySQL/MariaDB 5.7+
- PostgreSQL 12+
- SQLite 3.x
π€ κΈ°μ¬νκΈ°
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
π λΌμ΄μΌμ€
μ΄ νλ‘μ νΈλ MIT λΌμ΄μΌμ€ νμ μμ΅λλ€. μμΈν λ΄μ©μ LICENSE
νμΌμ μ°Έμ‘°νμΈμ.