TeiNam/mongo-mcp-server
If you are the rightful owner of mongo-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 is a powerful Model Context Protocol (MCP) server implementation that provides a standardized protocol for seamless interaction with MongoDB databases.
MongoDB MCP ์๋ฒ
MongoDB ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ์ํํ ์ํธ์์ฉ์ ํ์คํ๋ ํ๋กํ ์ฝ๋ก ์ ๊ณตํ๋ ๊ฐ๋ ฅํ Model Context Protocol(MCP) ์๋ฒ ๊ตฌํ์ฒด์ ๋๋ค.
์์ฑ์
Rastalion
๊ฐ์
์ด MCP ์๋ฒ ๊ตฌํ์ฒด๋ Model Context Protocol์ ํตํด MongoDB ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ํธ์์ฉํ ์ ์๋ ๊ฐ๋ ฅํ ์ธํฐํ์ด์ค๋ฅผ ์ ๊ณตํฉ๋๋ค. ๋ฐ์ดํฐ๋ฒ ์ด์ค, ์ปฌ๋ ์ ๋ฐ ๋ฌธ์์ ๋ํ ์์ ์ async/await ํจํด๊ณผ ์ค๋ฅ ์ฒ๋ฆฌ๋ฅผ ํตํด ์์ ์ ์ผ๋ก ์ง์ํฉ๋๋ค.
ํน์ง
- MongoDB CRUD ์์ ์๋ฒฝ ์ง์
- MongoDB์์ ์์ ํ ์ฐ๊ฒฐ ์ฒ๋ฆฌ
- ์ต์ ์ ์ฑ๋ฅ์ ์ํ ๋น๋๊ธฐ(async/await) ํจํด
- ํฌ๊ด์ ์ธ ์ค๋ฅ ์ฒ๋ฆฌ
- ์ฌ์ด ๋ฐฐํฌ๋ฅผ ์ํ Docker ์ง์
- ํ์ ํํธ๋ฅผ ๊ฐ์ถ ์ฟผ๋ฆฌ ์คํ
- ์ค์๊ฐ ์ ๋ฐ์ดํธ๋ฅผ ์ํ SSE(Server-Sent Events) ์ง์
๋น ๋ฅธ ์์
CLI ๋๊ตฌ๋ก ์ฌ์ฉ
# ์ ์ฅ์ ๋ณต์
git clone https://github.com/yourusername/mongo-mcp-server.git
cd mongo-mcp-server
# ๊ฐ๋ฐ ๋ชจ๋๋ก ์ค์น
pip install -e .
# ๋ก์ปฌ์์ CLI ๋ช
๋ น์ผ๋ก ์คํ
mongo-mcp-server
# SSE ํธ๋์คํฌํธ๋ก ์คํ
mongo-mcp-server --transport=sse
# MongoDB URL ์ง์
mongo-mcp-server --mongodb-url="mongodb://username:password@hostname:port/dbname"
# ๋์๋ง ๋ณด๊ธฐ
mongo-mcp-server --help
UVX๋ฅผ ํตํด ์คํ
# UVX๊ฐ ์ค์น๋ ๊ฒฝ์ฐ
uvx mongo-mcp-server
# SSE ํธ๋์คํฌํธ ๋ชจ๋
uvx mongo-mcp-server --transport=sse
Python ์ง์ ์คํ
# ์ ์ฅ์ ๋ณต์
git clone https://github.com/yourusername/mongo-mcp-server.git
cd mongo-mcp-server
# ์์กด์ฑ ์ค์น
pip install -r requirements.txt
# ํ๊ฒฝ ๋ณ์ ์ค์
export MONGODB_URL="mongodb://username:password@hostname:port/dbname?authSource=admin"
# ์๋ฒ ์คํ
uvicorn app.main:app --host 0.0.0.0 --port 3000
Docker ์ฌ์ฉ
# ์ ์ฅ์ ๋ณต์
git clone https://github.com/yourusername/mongo-mcp-server.git
cd mongo-mcp-server
# Docker Compose๋ก ๋น๋ ๋ฐ ์คํ
docker-compose up -d
# ๋ก๊ทธ ํ์ธ
docker-compose logs -f mongo-mcp
UVX ์ฌ์ฉ
UVX๋ ๋ค์ํ ํ๊ฒฝ์์ ์๋น์ค๋ฅผ ์ฝ๊ฒ ๊ด๋ฆฌํ ์ ์๋ ๋๊ตฌ์ ๋๋ค.
# ๋ฑ๋ก ์คํฌ๋ฆฝํธ์ ์คํ ๊ถํ ๋ถ์ฌ
chmod +x uvx-register.sh
# UVX์ ์๋น์ค ๋ฑ๋ก
./uvx-register.sh
# ์๋น์ค ์์
uvx start mongo-mcp
# ์ํ ํ์ธ
uvx status mongo-mcp
# ๋ก๊ทธ ํ์ธ
uvx logs mongo-mcp
๋ ์์ธํ ๋ด์ฉ์ ๋ฅผ ์ฐธ์กฐํ์ธ์.
ํ๊ฒฝ ๋ณ์
์๋ฒ ์คํ ์ ์ ๋ค์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํ์ธ์:
# ํ์
MONGODB_URL="mongodb://username:password@hostname:port/dbname?authSource=admin"
# ์ ํ - ๊ธฐ๋ณธ๊ฐ ํ์
PORT=3000
MCP_TRANSPORT=http # 'http' ๋๋ 'sse'
API ์๋ํฌ์ธํธ
- ์ํ ํ์ธ:
GET /health
- MCP API:
GET /mcp
- FastMCP ์๋ํฌ์ธํธ (OpenAPI ๋ฌธ์) - SSE ์ฐ๊ฒฐ:
GET /sse
- Server-Sent Events ์๋ํฌ์ธํธ - ๋ฉ์์ง ์ฒ๋ฆฌ:
POST /messages
- ๋ฉ์์ง ์ฒ๋ฆฌ ์๋ํฌ์ธํธ
IDE ํตํฉ
VS Code ์ค์
VS Code settings.json์ ๋ค์์ ์ถ๊ฐํ์ธ์:
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "mongodbUri",
"description": "MongoDB ์ฐ๊ฒฐ URI"
}
],
"servers": {
"mongodb": {
"command": "mongo-mcp-server",
"args": [
"--mongodb-url",
"$(mongodbUri)"
],
"env": {}
}
}
}
}
Claude ๋๋ ๋ค๋ฅธ AI ์ด์์คํดํธ
Claude ๋๋ ๋ค๋ฅธ AI ์ด์์คํดํธ๋ฅผ ์ํด MCP ์๋ฒ๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ตฌ์ฑํ์ธ์:
{
"mcp": {
"servers": {
"mongodb": {
"url": "http://localhost:3000/mcp"
}
}
}
}
์ฌ์ฉ ๊ฐ๋ฅํ ๋๊ตฌ
๋๊ตฌ ์ด๋ฆ | ์ค๋ช |
---|---|
listCollections | ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๋ชจ๋ ์ฌ์ฉ ๊ฐ๋ฅํ ์ปฌ๋ ์ ๋ชฉ๋ก ์กฐํ |
find | MongoDB ์ฟผ๋ฆฌ ๊ตฌ๋ฌธ์ ์ฌ์ฉํ์ฌ ์ปฌ๋ ์ ์ ๋ฌธ์ ์กฐํ |
insertOne | ์ปฌ๋ ์ ์ ๋จ์ผ ๋ฌธ์ ์ฝ์ |
updateOne | ์ปฌ๋ ์ ์์ ๋จ์ผ ๋ฌธ์ ์ ๋ฐ์ดํธ |
deleteOne | ์ปฌ๋ ์ ์์ ๋จ์ผ ๋ฌธ์ ์ญ์ |
indexes | ์ปฌ๋ ์ ์ ๋ชจ๋ ์ธ๋ฑ์ค ๋ชฉ๋ก ์กฐํ |
createIndex | ์ปฌ๋ ์ ์ ์๋ก์ด ์ธ๋ฑ์ค ์์ฑ |
dropIndex | ์ปฌ๋ ์ ์์ ๊ธฐ์กด ์ธ๋ฑ์ค ์ญ์ |
๊ณ ๊ธ ์ฌ์ฉ๋ฒ
์ฌ์ฉ์ ์ ์ ๋๊ตฌ ์ถ๊ฐ
app/tools/documents/
๋๋app/tools/collection/
์ ์ ๋๊ตฌ ์์ฑ:
from ..base.tool import BaseTool
class MyNewTool(BaseTool):
@property
def name(self) -> str:
return "my_new_tool"
@property
def description(self) -> str:
return "์ ๋๊ตฌ์ ๋ํ ์ค๋ช
"
@property
def input_schema(self) -> Dict[str, Any]:
return {
"type": "object",
"properties": {
# ๋๊ตฌ ์
๋ ฅ ์คํค๋ง ์ ์
}
}
async def execute(self, params: Dict[str, Any]) -> Dict[str, Any]:
# ๋๊ตฌ ์คํ ๋ก์ง ๊ตฌํ
pass
app/tools/registry.py
์ ๋๊ตฌ ๋ฑ๋ก:
from .documents.my_new_tool import MyNewTool
# ToolRegistry.__init__ ๋ฉ์๋ ๋ด์์
self.register_tool(MyNewTool())
CLI ๋๊ตฌ ์ค์น ๋ฐ ๋ฐฐํฌ
PyPI์ ํจํค์ง๋ก ๋ฑ๋กํ์ฌ ์ ์ญ์ ์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค:
# setup.py ํ์ธ ํ ๋น๋
python setup.py sdist bdist_wheel
# ํจํค์ง ์
๋ก๋ (PyPI ๊ณ์ ํ์)
twine upload dist/*
# ์ ์ญ ์ค์น
pip install mongodb-mcp-bridge
# ์ด๋์๋ ์คํ ๊ฐ๋ฅ
mongodb-mcp-bridge
๋ฌธ์ ํด๊ฒฐ
- ์๋ฒ๊ฐ ์์๋์ง ์๋ ๊ฒฝ์ฐ:
mongo-mcp-server --help
๋ก ๋์๋ง ํ์ธ - MongoDB ์ฐ๊ฒฐ ๋ฌธ์ :
--mongodb-url
ํ๋ผ๋ฏธํฐ๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธ - ๋๊ตฌ ์คํ ์ค๋ฅ: ๋๊ตฌ ๊ตฌํ๊ณผ ์ ๋ ฅ ๋งค๊ฐ๋ณ์ ํ์ธ
- Docker ๋ฌธ์ :
docker-compose logs mongo-mcp
๋ก ๋ก๊ทธ ํ์ธ
Docker ๊ตฌ์ฑ
Docker ์ค์ ์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค:
- Python 3.12 ๊ธฐ๋ณธ ์ด๋ฏธ์ง
- Asia/Seoul ํ์์กด
- MongoDB 4.4 ์ธ์คํด์ค
- ๋ฐ์ดํฐ๋ฒ ์ด์ค ์คํ ๋ฆฌ์ง๋ฅผ ์ํ ์๊ตฌ ๋ณผ๋ฅจ
- ์์ชฝ ์๋น์ค์ ๋ํ ํฌ์ค ์ฒดํฌ
- ์๋ํ๋ ๋คํธ์ํฌ ๊ตฌ์ฑ
๋ผ์ด์ ์ค
์ด ํ๋ก์ ํธ๋ MIT ๋ผ์ด์ ์ค ํ์ ๋ฐฐํฌ๋ฉ๋๋ค - ์์ธํ ๋ด์ฉ์ ํ์ผ์ ์ฐธ์กฐํ์ธ์.