mcp-mongo-server 1.2.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  ![NPM Downloads](https://img.shields.io/npm/dm/mcp-mongo-server)
6
6
  ![NPM License](https://img.shields.io/npm/l/mcp-mongo-server)
7
7
  [![smithery badge](https://smithery.ai/badge/mcp-mongo-server)](https://smithery.ai/server/mcp-mongo-server)
8
+ [![Verified on MseeP](https://mseep.ai/badge.svg)](https://mseep.ai/app/e274a3dd-7fe6-4440-8c43-043bae668251)
8
9
 
9
10
  A Model Context Protocol server that enables LLMs to interact with MongoDB databases. This server provides capabilities for inspecting collection schemas and executing MongoDB operations through a standardized interface.
10
11
 
@@ -14,70 +15,21 @@ A Model Context Protocol server that enables LLMs to interact with MongoDB datab
14
15
 
15
16
  ## Key Features
16
17
 
17
- ### Smart ObjectId Handling
18
- - Intelligent conversion between string IDs and MongoDB ObjectId
19
- - Configurable with `objectIdMode` parameter:
20
- - `"auto"`: Convert based on field names (default)
21
- - `"none"`: No conversion
22
- - `"force"`: Force all string ID fields to ObjectId
23
-
24
- ### Flexible Configuration
25
- - **Environment Variables**:
26
- - `MCP_MONGODB_URI`: MongoDB connection URI
27
- - `MCP_MONGODB_READONLY`: Enable read-only mode when set to "true"
28
- - **Command-line Options**:
29
- - `--read-only` or `-r`: Connect in read-only mode
30
-
31
- ### Read-Only Mode
32
- - Protection against write operations (update, insert, createIndex)
33
- - Uses MongoDB's secondary read preference for optimal performance
34
- - Ideal for safely connecting to production databases
35
-
36
- ### MongoDB Operations
37
- - **Read Operations**:
38
- - Query documents with optional execution plan analysis
39
- - Execute aggregation pipelines
40
- - Count documents matching criteria
41
- - Get collection schema information
42
- - **Write Operations** (when not in read-only mode):
43
- - Update documents
44
- - Insert new documents
45
- - Create indexes
46
-
47
- ### LLM Integration
48
- - Collection completions for enhanced LLM interaction
49
- - Schema inference for improved context understanding
50
- - Collection analysis for data insights
18
+ - **Smart ObjectId Handling** - Configurable auto/none/force modes for string-to-ObjectId conversion
19
+ - **Read-Only Mode** - Protection against write operations, uses secondary read preference
20
+ - **Schema Inference** - Automatic collection schema detection from document samples
21
+ - **Query & Aggregation** - Full MongoDB query and aggregation pipeline support with optional explain plans
22
+ - **Write Operations** - Insert, update, and index creation (when not in read-only mode)
23
+ - **Collection Completions** - Auto-complete collection names for LLM integration
51
24
 
52
25
  ## Installation
53
26
 
54
- ### Global Installation
55
-
56
- ```bash
57
- npm install -g mcp-mongo-server
58
- ```
59
-
60
- ### For Development
61
-
62
27
  ```bash
63
- # Clone repository
64
- git clone https://github.com/kiliczsh/mcp-mongo-server.git
65
- cd mcp-mongo-server
66
-
67
- # Install dependencies
68
- npm install
69
-
70
- # Build
71
- npm run build
72
-
73
- # Development with auto-rebuild
74
- npm run watch
28
+ npx -y mcp-mongo-server mongodb://localhost:27017/database
75
29
  ```
76
30
 
77
31
  ## Usage
78
32
 
79
- ### Basic Usage
80
-
81
33
  ```bash
82
34
  # Start server with MongoDB URI
83
35
  npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database
@@ -88,285 +40,18 @@ npx -y mcp-mongo-server mongodb://muhammed:kilic@localhost:27017/database --read
88
40
 
89
41
  ### Environment Variables
90
42
 
91
- You can configure the server using environment variables, which is particularly useful for CI/CD pipelines, Docker containers, or when you don't want to expose connection details in command arguments:
92
-
93
- ```bash
94
- # Set MongoDB connection URI
95
- export MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database"
96
-
97
- # Enable read-only mode
98
- export MCP_MONGODB_READONLY="true"
99
-
100
- # Run server (will use environment variables if no URI is provided)
101
- npx -y mcp-mongo-server
102
- ```
103
-
104
- Using environment variables in Claude Desktop configuration:
105
-
106
- ```json
107
- {
108
- "mcpServers": {
109
- "mongodb-env": {
110
- "command": "npx",
111
- "args": [
112
- "-y",
113
- "mcp-mongo-server"
114
- ],
115
- "env": {
116
- "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database",
117
- "MCP_MONGODB_READONLY": "true"
118
- }
119
- }
120
- }
121
- }
122
- ```
123
-
124
- Using environment variables with Docker:
125
-
126
- ```bash
127
- docker run -e MCP_MONGODB_URI="mongodb://muhammed:kilic@localhost:27017/database" \
128
- -e MCP_MONGODB_READONLY="true" \
129
- mcp-mongo-server
130
- ```
131
-
132
- ## Integration with Claude Desktop
133
-
134
- ### Manual Configuration
135
-
136
- Add the server configuration to Claude Desktop's config file:
137
-
138
- **MacOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
139
- **Windows**: `%APPDATA%/Claude/claude_desktop_config.json`
140
-
141
- #### Command-line Arguments Approach:
142
-
143
- ```json
144
- {
145
- "mcpServers": {
146
- "mongodb": {
147
- "command": "npx",
148
- "args": [
149
- "-y",
150
- "mcp-mongo-server",
151
- "mongodb://muhammed:kilic@localhost:27017/database"
152
- ]
153
- },
154
- "mongodb-readonly": {
155
- "command": "npx",
156
- "args": [
157
- "-y",
158
- "mcp-mongo-server",
159
- "mongodb://muhammed:kilic@localhost:27017/database",
160
- "--read-only"
161
- ]
162
- }
163
- }
164
- }
165
- ```
166
-
167
- #### Environment Variables Approach:
168
-
169
- ```json
170
- {
171
- "mcpServers": {
172
- "mongodb": {
173
- "command": "npx",
174
- "args": [
175
- "-y",
176
- "mcp-mongo-server"
177
- ],
178
- "env": {
179
- "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database"
180
- }
181
- },
182
- "mongodb-readonly": {
183
- "command": "npx",
184
- "args": [
185
- "-y",
186
- "mcp-mongo-server"
187
- ],
188
- "env": {
189
- "MCP_MONGODB_URI": "mongodb://muhammed:kilic@localhost:27017/database",
190
- "MCP_MONGODB_READONLY": "true"
191
- }
192
- }
193
- }
194
- }
195
-
196
- ### GitHub Package Usage:
43
+ | Variable | Description |
44
+ |----------|-------------|
45
+ | `MCP_MONGODB_URI` | MongoDB connection URI |
46
+ | `MCP_MONGODB_READONLY` | Enable read-only mode (`"true"`) |
197
47
 
198
- ```json
199
- {
200
- "mcpServers": {
201
- "mongodb": {
202
- "command": "npx",
203
- "args": [
204
- "-y",
205
- "github:kiliczsh/mcp-mongo-server",
206
- "mongodb://muhammed:kilic@localhost:27017/database"
207
- ]
208
- },
209
- "mongodb-readonly": {
210
- "command": "npx",
211
- "args": [
212
- "-y",
213
- "github:kiliczsh/mcp-mongo-server",
214
- "mongodb://muhammed:kilic@localhost:27017/database",
215
- "--read-only"
216
- ]
217
- }
218
- }
219
- }
220
- ```
221
-
222
- ## Integration with Windsurf and Cursor
223
-
224
- The MCP MongoDB Server can be used with Windsurf and Cursor in a similar way to Claude Desktop.
225
-
226
- ### Windsurf Configuration
227
-
228
- Add the server to your Windsurf configuration:
229
-
230
- ```json
231
- {
232
- "mcpServers": {
233
- "mongodb": {
234
- "command": "npx",
235
- "args": [
236
- "-y",
237
- "mcp-mongo-server",
238
- "mongodb://muhammed:kilic@localhost:27017/database"
239
- ]
240
- }
241
- }
242
- }
243
- ```
244
-
245
- ### Cursor Configuration
246
-
247
- For Cursor, add the server configuration to your settings:
248
-
249
- ```json
250
- {
251
- "mcpServers": {
252
- "mongodb": {
253
- "command": "npx",
254
- "args": [
255
- "-y",
256
- "mcp-mongo-server",
257
- "mongodb://muhammed:kilic@localhost:27017/database"
258
- ]
259
- }
260
- }
261
- }
262
- ```
263
-
264
- You can also use the environment variables approach with both Windsurf and Cursor, following the same pattern shown in the Claude Desktop configuration.
265
-
266
- ### Automated Installation
267
-
268
- **Using Smithery**:
269
- ```bash
270
- npx -y @smithery/cli install mcp-mongo-server --client claude
271
- ```
272
-
273
- **Using mcp-get**:
274
- ```bash
275
- npx @michaellatman/mcp-get@latest install mcp-mongo-server
276
- ```
277
-
278
- ## Available Tools
279
-
280
- ### Query Operations
281
-
282
- - **query**: Execute MongoDB queries
283
- ```javascript
284
- {
285
- collection: "users",
286
- filter: { age: { $gt: 30 } },
287
- projection: { name: 1, email: 1 },
288
- limit: 20,
289
- explain: "executionStats" // Optional
290
- }
291
- ```
292
-
293
- - **aggregate**: Run aggregation pipelines
294
- ```javascript
295
- {
296
- collection: "orders",
297
- pipeline: [
298
- { $match: { status: "completed" } },
299
- { $group: { _id: "$customerId", total: { $sum: "$amount" } } }
300
- ],
301
- explain: "queryPlanner" // Optional
302
- }
303
- ```
304
-
305
- - **count**: Count matching documents
306
- ```javascript
307
- {
308
- collection: "products",
309
- query: { category: "electronics" }
310
- }
311
- ```
312
-
313
- ### Write Operations
314
-
315
- - **update**: Modify documents
316
- ```javascript
317
- {
318
- collection: "posts",
319
- filter: { _id: "60d21b4667d0d8992e610c85" },
320
- update: { $set: { title: "Updated Title" } },
321
- upsert: false,
322
- multi: false
323
- }
324
- ```
325
-
326
- - **insert**: Add new documents
327
- ```javascript
328
- {
329
- collection: "comments",
330
- documents: [
331
- { author: "user123", text: "Great post!" },
332
- { author: "user456", text: "Thanks for sharing" }
333
- ]
334
- }
335
- ```
336
-
337
- - **createIndex**: Create collection indexes
338
- ```javascript
339
- {
340
- collection: "users",
341
- indexes: [
342
- {
343
- key: { email: 1 },
344
- unique: true,
345
- name: "email_unique_idx"
346
- }
347
- ]
348
- }
349
- ```
350
-
351
- ### System Operations
352
-
353
- - **serverInfo**: Get MongoDB server details
354
- ```javascript
355
- {
356
- includeDebugInfo: true // Optional
357
- }
358
- ```
359
-
360
- ## Debugging
361
-
362
- Since MCP servers communicate over stdio, debugging can be challenging. Use the MCP Inspector for better visibility:
363
-
364
- ```bash
365
- npm run inspector
366
- ```
48
+ ## Documentation
367
49
 
368
- This will provide a URL to access the debugging tools in your browser.
50
+ - [Integration Guide](docs/integration.md) - Claude Desktop, Windsurf, Cursor, Docker
51
+ - [Available Tools](docs/tools.md) - Query, aggregate, update, insert, and more
52
+ - [Development](docs/development.md) - Setup, scripts, and debugging
53
+ - [Contributing](CONTRIBUTING.md)
369
54
 
370
55
  ## License
371
56
 
372
- This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
57
+ MIT - see [LICENSE](LICENSE) for details.