mongo_agent_mcp 0.1.0__tar.gz

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.
@@ -0,0 +1,404 @@
1
+ Metadata-Version: 2.4
2
+ Name: mongo_agent_mcp
3
+ Version: 0.1.0
4
+ Summary: A mongo mcp that can be used to automate the database query with llm
5
+ Requires-Python: >=3.13
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: dotenv>=0.9.9
8
+ Requires-Dist: fastmcp>=3.4.2
9
+ Requires-Dist: pymongo>=4.17.0
10
+
11
+ # MongoDB MCP
12
+
13
+ A MongoDB Model Context Protocol (MCP) Server that allows AI agents and MCP clients to interact with MongoDB databases through standardized tools.
14
+
15
+ ## Features
16
+
17
+ * List all collections
18
+ * Discover collection schemas
19
+ * Fetch collection data
20
+ * Query documents
21
+ * Insert documents
22
+ * Update documents
23
+ * Delete documents
24
+ * MongoDB Atlas support
25
+ * Local MongoDB support
26
+ * MCP stdio transport support
27
+
28
+ ---
29
+
30
+ # Installation
31
+
32
+ ## Using pip
33
+
34
+ ```bash
35
+ pip install mongo-mcp
36
+ ```
37
+
38
+ ## Using uv
39
+
40
+ ```bash
41
+ uv add mongo-mcp
42
+ ```
43
+
44
+ ---
45
+
46
+ # Prerequisites
47
+
48
+ * Python 3.10+
49
+ * MongoDB Local Instance or MongoDB Atlas Cluster
50
+
51
+ Examples:
52
+
53
+ ```txt
54
+ mongodb://localhost:27017
55
+ ```
56
+
57
+ or
58
+
59
+ ```txt
60
+ mongodb+srv://username:password@cluster.mongodb.net
61
+ ```
62
+
63
+ ---
64
+
65
+ # Configuration
66
+
67
+ MongoDB MCP uses environment variables to connect to your database.
68
+
69
+ Create a `.env` file:
70
+
71
+ ```env
72
+ MONGODB_URI=mongodb://localhost:27017
73
+ DATABASE_NAME=shipbihar
74
+ ```
75
+
76
+ ## Environment Variables
77
+
78
+ | Variable | Description | Required |
79
+ | ------------- | ------------------------- | -------- |
80
+ | MONGODB_URI | MongoDB connection string | Yes |
81
+ | DATABASE_NAME | Database name | Yes |
82
+
83
+ ---
84
+
85
+ # Running the MCP Server
86
+
87
+ ```bash
88
+ mongo_mcp
89
+ ```
90
+
91
+ or
92
+
93
+ ```bash
94
+ python -m mongo_mcp.main
95
+ ```
96
+
97
+ The MCP server will start using stdio transport.
98
+
99
+ ---
100
+
101
+ # MCP Client Configuration
102
+
103
+ Example MCP configuration:
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "mongodb": {
109
+ "command": "mongo_mcp",
110
+ "env": {
111
+ "MONGODB_URI": "mongodb://localhost:27017",
112
+ "DATABASE_NAME": "shipbihar"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ ---
120
+
121
+ # Available Tools
122
+
123
+ ## all_collections
124
+
125
+ Returns all collections in the configured database.
126
+
127
+ Example Output:
128
+
129
+ ```json
130
+ [
131
+ "users",
132
+ "orders",
133
+ "shipments"
134
+ ]
135
+ ```
136
+
137
+ ---
138
+
139
+ ## fetch_collection_schema
140
+
141
+ Returns an inferred schema from a sample document.
142
+
143
+ Example:
144
+
145
+ ```json
146
+ {
147
+ "_id": "ObjectId",
148
+ "name": "str",
149
+ "email": "str",
150
+ "createdAt": "datetime"
151
+ }
152
+ ```
153
+
154
+ ---
155
+
156
+ ## fetch_collection_data
157
+
158
+ Returns documents from a collection.
159
+
160
+ Parameters:
161
+
162
+ ```json
163
+ {
164
+ "collection_name": "users",
165
+ "limit": 100
166
+ }
167
+ ```
168
+
169
+ ---
170
+
171
+ ## find_document
172
+
173
+ Find a document using a MongoDB query.
174
+
175
+ Example:
176
+
177
+ ```json
178
+ {
179
+ "collection_name": "users",
180
+ "query": {
181
+ "email": "john@example.com"
182
+ }
183
+ }
184
+ ```
185
+
186
+ ---
187
+
188
+ ## insert_document
189
+
190
+ Insert a document.
191
+
192
+ Example:
193
+
194
+ ```json
195
+ {
196
+ "collection_name": "users",
197
+ "document": {
198
+ "name": "John",
199
+ "email": "john@example.com"
200
+ }
201
+ }
202
+ ```
203
+
204
+ ---
205
+
206
+ ## update_document
207
+
208
+ Update matching documents.
209
+
210
+ Example:
211
+
212
+ ```json
213
+ {
214
+ "collection_name": "users",
215
+ "filter_query": {
216
+ "email": "john@example.com"
217
+ },
218
+ "update_data": {
219
+ "role": "admin"
220
+ }
221
+ }
222
+ ```
223
+
224
+ ---
225
+
226
+ ## delete_document
227
+
228
+ Delete matching documents.
229
+
230
+ Example:
231
+
232
+ ```json
233
+ {
234
+ "collection_name": "users",
235
+ "filter_query": {
236
+ "email": "john@example.com"
237
+ }
238
+ }
239
+ ```
240
+
241
+ ---
242
+
243
+ # Common Errors
244
+
245
+ ## Error: DATABASE_NAME is None
246
+
247
+ Error:
248
+
249
+ ```txt
250
+ TypeError: name must be an instance of str, not <class 'NoneType'>
251
+ ```
252
+
253
+ Reason:
254
+
255
+ MongoDB MCP cannot find the `DATABASE_NAME` environment variable.
256
+
257
+ Solution:
258
+
259
+ Create a `.env` file:
260
+
261
+ ```env
262
+ MONGODB_URI=mongodb://localhost:27017
263
+ DATABASE_NAME=your_database_name
264
+ ```
265
+
266
+ or export variables manually.
267
+
268
+ Windows PowerShell:
269
+
270
+ ```powershell
271
+ $env:MONGODB_URI="mongodb://localhost:27017"
272
+ $env:DATABASE_NAME="shipbihar"
273
+ ```
274
+
275
+ Linux/macOS:
276
+
277
+ ```bash
278
+ export MONGODB_URI="mongodb://localhost:27017"
279
+ export DATABASE_NAME="shipbihar"
280
+ ```
281
+
282
+ ---
283
+
284
+ ## Error: Connection Refused
285
+
286
+ Error:
287
+
288
+ ```txt
289
+ ServerSelectionTimeoutError
290
+ ```
291
+
292
+ Reason:
293
+
294
+ MongoDB server is not running.
295
+
296
+ Solution:
297
+
298
+ Start MongoDB:
299
+
300
+ ```bash
301
+ mongod
302
+ ```
303
+
304
+ or verify your Atlas connection string.
305
+
306
+ ---
307
+
308
+ ## Error: Authentication Failed
309
+
310
+ Error:
311
+
312
+ ```txt
313
+ Authentication failed
314
+ ```
315
+
316
+ Reason:
317
+
318
+ Incorrect username or password.
319
+
320
+ Solution:
321
+
322
+ Verify your MongoDB credentials.
323
+
324
+ ---
325
+
326
+ # Security
327
+
328
+ Recommended:
329
+
330
+ * Use dedicated database users
331
+ * Restrict permissions when possible
332
+ * Avoid connecting with admin credentials
333
+ * Store secrets in environment variables
334
+
335
+ Do NOT:
336
+
337
+ * Commit `.env` files to GitHub
338
+ * Hardcode MongoDB passwords in code
339
+
340
+ ---
341
+
342
+ # Development
343
+
344
+ Clone the repository:
345
+
346
+ ```bash
347
+ git clone <repository-url>
348
+ cd mongo-mcp
349
+ ```
350
+
351
+ Create environment:
352
+
353
+ ```bash
354
+ uv venv
355
+ source .venv/bin/activate
356
+ ```
357
+
358
+ Install dependencies:
359
+
360
+ ```bash
361
+ uv sync
362
+ ```
363
+
364
+ Run locally:
365
+
366
+ ```bash
367
+ python -m mongo_mcp.main
368
+ ```
369
+
370
+ ---
371
+
372
+ # Roadmap
373
+
374
+ ## V1
375
+
376
+ * Collection discovery
377
+ * CRUD operations
378
+ * Schema inspection
379
+
380
+ ## V2
381
+
382
+ * Aggregation pipelines
383
+ * Count documents
384
+ * Regex search
385
+
386
+ ## V3
387
+
388
+ * Natural language queries
389
+ * Query optimization
390
+ * Schema caching
391
+
392
+ ---
393
+
394
+ # License
395
+
396
+ MIT License
397
+
398
+ ---
399
+
400
+ # Author
401
+
402
+ Vishnu Bhardwaj
403
+
404
+ Built for AI Agents, MCP Clients, and MongoDB Developers.