🗄️ LLMS 向け MongoDB MCP サーバー
LLMがMongoDBデータベースと直接やり取りできるようにするモデルコンテキストプロトコル(MCP)サーバー。コレクションのクエリ、スキーマの検査、そして自然言語によるシームレスなデータ管理を実現します。
✨ 特徴
🔍 コレクションスキーマ検査
📊 ドキュメントのクエリとフィルタリング
📈 インデックス管理
📝 ドキュメント操作(挿入、更新、削除)
Related MCP server: MongoDB MCP Server for LLMs
デモビデオ
https://github.com/user-attachments/assets/2389bf23-a10d-49f9-bca9-2b39a1ebe654
🚀 クイックスタート
開始するには、mongodb 接続 URL を見つけて、次の構成を Claude Desktop 構成ファイルに追加します。
MacOS : ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows : %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": [
"mongo-mcp",
"mongodb://<username>:<password>@<host>:<port>/<database>?authSource=admin"
]
}
}
}Smithery経由でインストール
Smithery経由で Claude Desktop 用の MongoDB MCP Server を自動的にインストールするには:
npx -y @smithery/cli install mongo-mcp --client claude前提条件
Node.js 18歳以上
npx
Docker および Docker Compose (ローカル サンドボックス テストのみ)
MCP クライアント (例: Claude デスクトップ アプリ)
テストサンドボックスのセットアップ
接続するmongo dbサーバーがなく、サンプルサンドボックスを作成したい場合は、次の手順に従ってください。
Docker Compose を使用して MongoDB を起動します。
docker-compose up -dデータベースにテストデータを入力します。
npm run seedClaudeデスクトップの設定
この構成を Claude Desktop 構成ファイルに追加します。
MacOS : ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows : %APPDATA%/Claude/claude_desktop_config.json
ローカル開発モード:
{
"mcpServers": {
"mongodb": {
"command": "node",
"args": [
"dist/index.js",
"mongodb://root:example@localhost:27017/test?authSource=admin"
]
}
}
}テストサンドボックスのデータ構造
シード スクリプトは、サンプル データを含む 3 つのコレクションを作成します。
ユーザー
個人情報(名前、メールアドレス、年齢)
座標を含むネストされた住所
さまざまな興味
会員期間
製品
製品の詳細(名前、SKU、カテゴリ)
ネストされた仕様
価格と在庫情報
タグと評価
注文
注文の詳細と商品
ユーザーリファレンス
配送と支払い情報
ステータス追跡
🎯 プロンプトの例
機能を確認するには、Claude と一緒に次のプロンプトを試してください。
基本操作
"What collections are available in the database?"
"Show me the schema for the users collection"
"Find all users in San Francisco"高度なクエリ
"Find all electronics products that are in stock and cost less than $1000"
"Show me all orders from the user john@example.com"
"List the products with ratings above 4.5"インデックス管理
"What indexes exist on the users collection?"
"Create an index on the products collection for the 'category' field"
"List all indexes across all collections"ドキュメント操作
"Insert a new product with name 'Gaming Laptop' in the products collection"
"Update the status of order with ID X to 'shipped'"
"Find and delete all products that are out of stock"📝 利用可能なツール
サーバーは、データベースとの対話用に次のツールを提供します。
クエリツール
find: フィルタリングと投影によるドキュメントのクエリlistCollections: 利用可能なコレクションを一覧表示するinsertOne: 単一のドキュメントを挿入するupdateOne: 単一のドキュメントを更新するdeleteOne: 1つのドキュメントを削除する
インデックスツール
createIndex: 新しいインデックスを作成するdropIndex: インデックスを削除するindexes: コレクションのインデックスを一覧表示する
📜 ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。