UNPKG

@syncfusion/mongodb-mcp-server

Version:

A Model Context Protocol server for MongoDB connections

98 lines (73 loc) 2.65 kB
# MCP MongoDB Server A Model Context Protocol server that provides access to MongoDB databases. This server enables LLMs to inspect collection schemas and execute MongoDB operations. ## Features ### Resources - List and access collections via `mongodb://` URIs - Each collection has a name, description and schema - JSON mime type for schema access ### Tools - **query** - Execute MongoDB queries with optional execution plan analysis - Input: Collection name, filter, projection, limit, explain options - Returns query results or execution plan - **aggregate** - Execute MongoDB aggregation pipelines with optional execution plan analysis - Input: Collection name, pipeline stages, explain options - Returns aggregation results or execution plan - **update** - Update documents in a collection - Input: Collection name, filter, update operations, upsert/multi options - Returns update operation results - **serverInfo** - Get MongoDB server information and status - Input: Optional debug info flag - Returns version, storage engine, and server details - **insert** - Insert documents into a collection - Input: Collection name, documents array, write options - Returns insert operation results - **createIndex** - Create indexes on a collection - Input: Collection name, index specifications, write options - Returns index creation results - **count** - Count documents matching a query - Input: Collection name, query filter, count options - Returns document count ### Prompts - `analyze_collection` - Analyze collection structure and contents - Input: Collection name - Output: Insights about schema, data types, and statistics ## Development Install dependencies: ```bash npm install ``` ## Configuration for Development ### Using Syncfusion Code Studio To use with Syncfusion Code Studio, add the server config: ```json { "experimental": { "modelContextProtocolServers": [ { "transport": { "type": "stdio", "command": "node", "args": [ "<path-to-mcp-mongo-server>/build/index.js", "mongodb://<username>:<password>@<cluster-url>/<databasename>?retryWrites=true&w=majority" ] } } ] } } ``` ## Components ### Resources The server provides schema information for each collection in the database: - **Collection Schemas** (`mongodb://<host>/<collection>/schema`) - JSON schema information for each collection - Includes field names and data types - Automatically inferred from collection documents