MCP Database Server
Provides secure read-only access to MariaDB databases, including schema inspection, table statistics, sample data retrieval, index analysis, and performance recommendations.
Integrates with MySQL databases for safe read-only queries, schema visualization via Mermaid ERD, performance bottleneck detection, and query optimization suggestions.
Connects to PostgreSQL databases with enforced read-only mode, offering schema analysis, explain plans, index usage statistics, and markdown table summaries.
Supports SQLite databases with basic read-only capabilities for schema browsing and data retrieval (currently in preparation).
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Database Servergenerate ERD diagram for the database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ποΈ MCP Database Server
보μ κ°νλ λ€μ€ λ°μ΄ν°λ² μ΄μ€ μ§μ MCP μλ² - Cursor IDE λ° Claudeμ μ°λ κ°λ₯ν Model Context Protocol μλ²
MySQL, PostgreSQLμ μ§μνλ μ격ν 보μ μ μ± μ μ μ©ν λ°μ΄ν°λ² μ΄μ€ λΆμ λ° μκ°ν λꡬμ λλ€.
β¨ μ£Όμ κΈ°λ₯
π 보μ κΈ°λ₯ (NEW!)
μ½κΈ° μ μ© λͺ¨λ κ°μ - SELECT μΏΌλ¦¬λ§ νμ©
SQL Injection λ°©μ§ - λ€μ€ λ¬Έμ₯ μ€ν λ° κΈμ§ λμ¬ μ°¨λ¨
μλ³μ νμ΄νΈλ¦¬μ€νΈ - ν μ΄λΈ/컬λΌλͺ κ²μ¦
νλΌλ―Έν° λ°μΈλ© κ°μ - μμ ν 쿼리 μ€ν
MySQL/PostgreSQL μν κΈ°λ₯ μ°¨λ¨ - INTO OUTFILE, COPY λ±
π― λ€μ€ λ°μ΄ν°λ² μ΄μ€ μ§μ
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βοΈ μ€μ
π 보μ μ€μ (μ€μ!)
νλ‘λμ νκ²½μμλ λ°λμ λ€μ μ€μ μ μ μ©νμΈμ:
# μ½κΈ° μ μ© λͺ¨λ κ°μ
READ_ONLY=true
STRICT_READONLY=true
# 보μ κ°νλ λ°μ΄ν°λ² μ΄μ€ κ³μ μ¬μ©
DB_USER=readonly_user
DB_PASSWORD=secure_passwordνκ²½λ³μ μ€μ
.env νμΌμ μμ±νκ³ λ°μ΄ν°λ² μ΄μ€ μ 보λ₯Ό μ€μ νμΈμ:
cp .env.example .envMySQL/MariaDB μ€μ (보μ κ°ν)
DB_TYPE=mysql
DB_HOST=localhost
DB_USER=readonly_user # μ½κΈ° μ μ© κ³μ μ¬μ©
DB_PASSWORD=your_password
DB_NAME=your_database
DB_CHARSET=utf8mb4
DB_PORT=3306PostgreSQL μ€μ
DB_TYPE=postgresql
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=your_database
DB_PORT=5432
DB_SCHEMA=publicSQLite μ€μ
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"
}
}
}
}π 보μ
보μ μ μ±
μ΄ μλ²λ μ격ν 보μ μ μ± μ μ μ©ν©λλ€:
μ½κΈ° μ μ© λͺ¨λ: SELECT μΏΌλ¦¬λ§ νμ©
SQL Injection λ°©μ§: λ€μ€ λ¬Έμ₯ μ€ν λ° κΈμ§ λμ¬ μ°¨λ¨
μλ³μ κ²μ¦: ν μ΄λΈ/컬λΌλͺ νμ΄νΈλ¦¬μ€νΈ κ²μ¦
νλΌλ―Έν° λ°μΈλ©: λͺ¨λ μ¬μ©μ μ λ ₯μ μμ ν λ°©μμΌλ‘ μ²λ¦¬
보μ μ€μ
μμΈν 보μ μ€μ μ SECURITY.mdλ₯Ό μ°Έμ‘°νμΈμ.
λ°μ΄ν°λ² μ΄μ€ κ³μ κΆν
μ€μ: νλ‘λμ νκ²½μμλ λ°λμ μ½κΈ° μ μ© κ³μ μ μ¬μ©νμΈμ:
-- MySQL μμ
CREATE USER 'mcp_readonly'@'%' IDENTIFIED BY 'secure_password';
GRANT SELECT ON your_database.* TO 'mcp_readonly'@'%';
-- PostgreSQL μμ
CREATE USER mcp_readonly WITH PASSWORD 'secure_password';
GRANT CONNECT ON DATABASE your_database TO mcp_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_readonly;π οΈ μ¬μ© κ°λ₯ν λꡬλ€
π μ€ν€λ§ λꡬ
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 νμΌμ μ°Έμ‘°νμΈμ.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/zerogon1203/db-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server