Skip to main content
Glama

MCP MongoDB サーバー


NPMバージョンNPMダウンロードNPMライセンス

LLMがMongoDBデータベースとやり取りできるようにするモデルコンテキストプロトコルサーバー。このサーバーは、標準化されたインターフェースを介してコレクションスキーマを検査し、MongoDB操作を実行する機能を提供します。

デモ

主な特徴

スマートなオブジェクトID処理

  • 文字列IDとMongoDB ObjectId間のインテリジェントな変換
  • objectIdModeパラメータで設定可能:
    • "auto" : フィールド名に基づいて変換します(デフォルト)
    • "none" : 変換なし
    • "force" : すべての文字列IDフィールドをObjectIdに強制する

柔軟な構成

  • 環境変数:
    • MCP_MONGODB_URI : MongoDB 接続 URI
    • MCP_MONGODB_READONLY : 「true」に設定すると読み取り専用モードが有効になります
  • コマンドラインオプション:
    • --read-onlyまたは-r : 読み取り専用モードで接続する

読み取り専用モード

  • 書き込み操作(更新、挿入、インデックス作成)に対する保護
  • 最適なパフォーマンスを得るために MongoDB のセカンダリ読み取り設定を使用します
  • 実稼働データベースに安全に接続するのに最適

MongoDB 操作

  • 読み取り操作:
    • オプションの実行プラン分析によるドキュメントのクエリ
    • 集計パイプラインを実行する
    • 条件に一致するドキュメントをカウントする
    • コレクションスキーマ情報を取得する
  • 書き込み操作(読み取り専用モードではない場合):
    • ドキュメントの更新
    • 新しいドキュメントを挿入する
    • インデックスを作成する

LLM統合

  • LLMインタラクション強化のためのコレクション完了
  • コンテキスト理解を向上させるスキーマ推論
  • データの洞察を得るための収集分析

インストール

グローバルインストール

npm install -g mcp-mongo-server

開発のために

# Clone repository git clone https://github.com/kiliczsh/mcp-mongo-server.git cd mcp-mongo-server # Install dependencies npm install # Build npm run build # Development with auto-rebuild npm run watch

使用法

基本的な使い方

# Start server with MongoDB URI npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database # Connect in read-only mode npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database --read-only

環境変数

環境変数を使用してサーバーを構成できます。これは、CI/CD パイプライン、Docker コンテナ、またはコマンド引数で接続の詳細を公開したくない場合に特に便利です。

# Set MongoDB connection URI export MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database" # Enable read-only mode export MCP_MONGODB_READONLY="true" # Run server (will use environment variables if no URI is provided) npx -y mcp-mongo-server

Claude Desktop 構成で環境変数を使用する:

{ "mcpServers": { "mongodb-env": { "command": "npx", "args": [ "-y", "mcp-mongo-server" ], "env": { "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database", "MCP_MONGODB_READONLY": "true" } } } }

Docker で環境変数を使用する:

# Build docker build -t mcp-mongo-server . # Run docker run -it -d -e MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database" -e MCP_MONGODB_READONLY="true" mcp-mongo-server # or edit docker-compose.yml and run docker-compose up -d

Claude Desktopとの統合

手動設定

Claude Desktop の設定ファイルにサーバー設定を追加します。

MacOS : ~/Library/Application Support/Claude/claude_desktop_config.json Windows : %APPDATA%/Claude/claude_desktop_config.json

コマンドライン引数のアプローチ:
{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] }, "mongodb-readonly": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database", "--read-only" ] } } }
環境変数アプローチ:
{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server" ], "env": { "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database" } }, "mongodb-readonly": { "command": "npx", "args": [ "-y", "mcp-mongo-server" ], "env": { "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database", "MCP_MONGODB_READONLY": "true" } } } }

GitHub パッケージの使用法:

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "github:kiliczsh/mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] }, "mongodb-readonly": { "command": "npx", "args": [ "-y", "github:kiliczsh/mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database", "--read-only" ] } } }

WindsurfとCursorとの統合

MCP MongoDB サーバーは、Claude Desktop と同様に Windsurf および Cursor で使用できます。

ウィンドサーフィンの構成

Windsurf 構成にサーバーを追加します。

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] } } }

カーソルの設定

カーソルの場合は、設定にサーバー構成を追加します。

{ "mcpServers": { "mongodb": { "command": "npx", "args": [ "-y", "mcp-mongo-server", "mongodb://muhammed:kilic@localhost:27017/database" ] } } }

Claude Desktop 構成に示されているのと同じパターンに従って、Windsurf と Cursor の両方で環境変数アプローチを使用することもできます。

自動インストール

Smitheryの使用:

npx -y @smithery/cli install mcp-mongo-server --client claude

mcp-get の使用:

npx @michaellatman/mcp-get@latest install mcp-mongo-server

利用可能なツール

クエリ操作

  • query : MongoDBクエリを実行する
    { collection: "users", filter: { age: { $gt: 30 } }, projection: { name: 1, email: 1 }, limit: 20, explain: "executionStats" // Optional }
  • 集計: 集計パイプラインを実行する
    { collection: "orders", pipeline: [ { $match: { status: "completed" } }, { $group: { _id: "$customerId", total: { $sum: "$amount" } } } ], explain: "queryPlanner" // Optional }
  • count : 一致する文書を数える
    { collection: "products", query: { category: "electronics" } }

書き込み操作

  • 更新: ドキュメントを変更する
    { collection: "posts", filter: { _id: "60d21b4667d0d8992e610c85" }, update: { $set: { title: "Updated Title" } }, upsert: false, multi: false }
  • 挿入: 新しいドキュメントを追加する
    { collection: "comments", documents: [ { author: "user123", text: "Great post!" }, { author: "user456", text: "Thanks for sharing" } ] }
  • createIndex : コレクションのインデックスを作成する
    { collection: "users", indexes: [ { key: { email: 1 }, unique: true, name: "email_unique_idx" } ] }

システム操作

  • serverInfo : MongoDB サーバーの詳細を取得する
    { includeDebugInfo: true // Optional }

デバッグ

MCPサーバーはstdio経由で通信するため、デバッグが困難になる場合があります。MCPインスペクターを使用すると、より詳細な情報を得ることができます。

npm run inspector

これにより、ブラウザでデバッグ ツールにアクセスするための URL が提供されます。

ライセンス

このMCPサーバーはMITライセンスに基づいてライセンスされています。つまり、MITライセンスの条件に従って、ソフトウェアを自由に使用、改変、配布することができます。詳細については、プロジェクトリポジトリのLICENSEファイルをご覧ください。

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

LLMがMongoDBデータベースとやり取りできるようにするモデルコンテキストプロトコルサーバー。このサーバーは、標準化されたインターフェースを介してコレクションスキーマを検査し、MongoDB操作を実行する機能を提供します。

  1. デモ
    1. 主な特徴
      1. スマートなオブジェクトID処理
      2. 柔軟な構成
      3. 読み取り専用モード
      4. MongoDB 操作
      5. LLM統合
    2. インストール
      1. グローバルインストール
      2. 開発のために
    3. 使用法
      1. 基本的な使い方
      2. 環境変数
    4. Claude Desktopとの統合
      1. 手動設定
      2. GitHub パッケージの使用法:
    5. WindsurfとCursorとの統合
      1. ウィンドサーフィンの構成
      2. カーソルの設定
      3. 自動インストール
    6. 利用可能なツール
      1. クエリ操作
      2. 書き込み操作
      3. システム操作
    7. デバッグ
      1. ライセンス

        Related MCP Servers

        • -
          security
          A
          license
          -
          quality
          A 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.
          Last updated -
          340
          75
          TypeScript
          MIT License
          • Apple
        • A
          security
          A
          license
          A
          quality
          A Model Context Protocol server that provides read-only access to MongoDB databases, enabling AI assistants to directly query and analyze MongoDB data while maintaining data safety.
          Last updated -
          14
          9
          2
          JavaScript
          MIT License
          • Apple
        • -
          security
          A
          license
          -
          quality
          A Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.
          Last updated -
          340
          TypeScript
          MIT License
          • Apple
        • -
          security
          A
          license
          -
          quality
          A Model Context Protocol server that enables LLMs to interact directly with MongoDB databases, allowing users to query collections, inspect schemas, and manage data through natural language.
          Last updated -
          340
          MIT License
          • Apple

        View all related MCP servers

        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/kiliczsh/mcp-mongo-server'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server