MongoDB MCP Server
MongoDB MCPサーバー
MongoDBデータベースとのシームレスな対話を標準化されたプロトコルとして提供する強力なModel Context Protocol(MCP)サーバー実装。
作者
Rastalion
Related MCP server: MongoDB
概要
この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 --helpUVX経由で実行
# UVX가 설치된 경우
uvx mongo-mcp-server
# SSE 트랜스포트 모드
uvx mongo-mcp-server --transport=ssePython 直接実行
# 저장소 복제
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 3000Dockerを使う
# 저장소 복제
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-mcpUVXの使用
UVXは、さまざまな環境でサービスを簡単に管理できるツールです。
# 등록 스크립트에 실행 권한 부여
chmod +x uvx-register.sh
# UVX에 서비스 등록
./uvx-register.sh
# 서비스 시작
uvx start mongo-mcp
# 상태 확인
uvx status mongo-mcp
# 로그 확인
uvx logs mongo-mcp詳細については、UVXガイドを参照してください。
環境変数
サーバーを実行する前に、次の環境変数を設定してください。
# 필수
MONGODB_URL="mongodb://username:password@hostname:port/dbname?authSource=admin"
# 선택 - 기본값 표시
PORT=3000
MCP_TRANSPORT=http # 'http' 또는 'sse'API エンドポイント
ヘルスチェック:
GET /healthMCP API :
GET /mcp- FastMCP エンドポイント (OpenAPI ドキュメント)SSE接続:
GET /sse- Server-Sent Eventsエンドポイントメッセージ処理:
POST /messagesmessages - メッセージ処理エンドポイント
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"
}
}
}
}利用可能なツール
ツール名 | 説明 |
| データベース内のすべての利用可能なコレクションのリストを検索する |
| MongoDBクエリ構文を使用したコレクションのドキュメントの参照 |
| コレクションに単一文書を挿入する |
| コレクションから単一文書を更新する |
| コレクションから単一文書を削除する |
| コレクション内のすべてのインデックスリストを検索する |
| コレクションに新しいインデックスを作成する |
| コレクションから既存のインデックスを削除する |
高度な使い方
カスタムツールの追加
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]:
# 도구 실행 로직 구현
passapp/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 基本イメージ
アジア/ソウルタイムゾーン
MongoDB 4.4インスタンス
データベースストレージ用の永続ボリューム
両方のサービスのヘルスチェック
自動化されたネットワーク構成
ライセンス
このプロジェクトはMITライセンスの下で展開されます - 詳細についてはLICENSEファイルを参照してください。
This server cannot be deployed
Maintenance
Related MCP Connectors
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for InsForge BaaS — database, storage, edge functions, and deployments
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that enables LLMs to interact directly with MongoDB databases. Query collections, inspect schemas, and manage data seamlessly through natural language.28 npm175MIT
- AlicenseBqualityAmaintenanceA Model Context Protocol server that provides access to MongoDB databases. This server enables LLMs to inspect collection schemas and execute read-only queries.8201 npm281MIT
- AlicenseNot gradedqualityFmaintenanceA modular server that enables management of MongoDB databases, collections, documents, indexes, and bulk operations through the Model Context Protocol (MCP) interface.MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server for MongoDB operations, enabling AI assistants to interact with MongoDB databases through a standardized interface.13 npm4MIT