MongoDB That Works - MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MongoDB That Works - MCP Serverget schema for users collection"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MongoDB That Works - MCP Server
A reliable MongoDB MCP (Model Context Protocol) server that provides seamless MongoDB integration for Claude Desktop with built-in schema discovery and field validation.
Features
🔍 Schema Discovery: Automatically analyze collection structures
✅ Field Validation: Prevent field name mistakes
📊 Full MongoDB Support: Find, aggregate, insert, update, delete operations
🚀 High Performance: Efficient connection pooling and query optimization
🔐 Secure: Support for MongoDB Atlas and authentication
🎯 Type-Safe: Built with TypeScript and Zod validation
Installation
Install from npm
npm install -g @sourabhshegane/mongodb-mcp-that-worksConfiguration
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mongodb": {
"command": "npx",
"args": ["-y", "@sourabhshegane/mongodb-mcp-that-works@latest"],
"env": {
"MONGODB_URI": "mongodb+srv://username:password@cluster.mongodb.net/database",
"MONGODB_DATABASE": "your_database_name"
}
}
}
}Configuration Options
MONGODB_URI: Your MongoDB connection string (required)MONGODB_DATABASE: Default database name (optional)
Available Tools
1. listCollections
List all collections in the database.
// Example
mcp.listCollections({ filter: {} })2. find
Find documents in a collection with filtering, sorting, and pagination.
// Example
mcp.find({
collection: "users",
filter: { status: "active" },
sort: { createdAt: -1 },
limit: 10
})3. findOne
Find a single document.
// Example
mcp.findOne({
collection: "users",
filter: { email: "user@example.com" }
})4. aggregate
Run aggregation pipelines.
// Example
mcp.aggregate({
collection: "orders",
pipeline: [
{ $match: { status: "completed" } },
{ $group: { _id: "$userId", total: { $sum: "$amount" } } }
]
})5. count
Count documents matching a filter.
// Example
mcp.count({
collection: "products",
filter: { inStock: true }
})6. distinct
Get distinct values for a field.
// Example
mcp.distinct({
collection: "orders",
field: "status"
})7. insertOne
Insert a single document.
// Example
mcp.insertOne({
collection: "users",
document: { name: "John Doe", email: "john@example.com" }
})8. updateOne
Update a single document.
// Example
mcp.updateOne({
collection: "users",
filter: { _id: "123" },
update: { $set: { status: "active" } }
})9. deleteOne
Delete a single document.
// Example
mcp.deleteOne({
collection: "users",
filter: { _id: "123" }
})10. getSchema
Analyze collection structure and discover field names.
// Example
mcp.getSchema({
collection: "users",
sampleSize: 100
})
// Returns:
{
"collection": "users",
"sampleSize": 100,
"fields": {
"_id": {
"types": ["ObjectId"],
"examples": ["507f1f77bcf86cd799439011"],
"frequency": "100/100",
"percentage": 100
},
"email": {
"types": ["string"],
"examples": ["user@example.com"],
"frequency": "100/100",
"percentage": 100
}
}
}Best Practices
Use Schema Discovery First: Before querying, run
getSchemato understand field namesHandle ObjectIds: The server automatically converts string IDs to ObjectIds
Use Projections: Limit returned fields to improve performance
Batch Operations: Use aggregation pipelines for complex queries
Examples
Basic Usage
// Get schema first to avoid field name mistakes
const schema = await mcp.getSchema({ collection: "reports" });
// Use correct field names from schema
const reports = await mcp.find({
collection: "reports",
filter: { organization_id: "64ba7374f8b63db2083b2665" },
limit: 10
});Advanced Aggregation
const analytics = await mcp.aggregate({
collection: "orders",
pipeline: [
{ $match: { createdAt: { $gte: new Date("2024-01-01") } } },
{ $group: {
_id: { $dateToString: { format: "%Y-%m", date: "$createdAt" } },
revenue: { $sum: "$amount" },
count: { $sum: 1 }
}},
{ $sort: { _id: 1 } }
]
});Troubleshooting
Connection Issues
Verify your MongoDB URI is correct
Check network connectivity to MongoDB Atlas
Ensure IP whitelist includes your current IP
Field Name Errors
Always use
getSchemato discover correct field namesRemember MongoDB is case-sensitive
Check for typos in nested field paths (e.g., "user.profile.name")
Performance
Use indexes for frequently queried fields
Limit result sets with
limitparameterUse projections to return only needed fields
License
MIT License - see LICENSE file for details
Changelog
v0.1.0
Initial release
Full MongoDB CRUD operations
Schema discovery tool
Automatic ObjectId conversion
TypeScript support
Made out of pain since the official MongoDB MCP didn't work for me
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/sourabhfb/mongodb-mcp-that-works'
If you have feedback or need assistance with the MCP directory API, please join our Discord server