Skip to main content
Glama
sourabhshegane

MongoDB That Works - MCP Server

MongoDB MCP That Works

npm version npm downloads npm weekly downloads CI GitHub release license GitHub stars node

A reliable MongoDB MCP (Model Context Protocol) server with built-in schema discovery and field validation. It's a standard MCP server over stdio, so it connects to any MCP client โ€” Claude Desktop, Claude Code, OpenAI Codex, Cursor, VS Code / GitHub Copilot, Zed, and more.

Published on npm: @sourabhshegane/mongodb-mcp-that-works ยท Install with npx -y @sourabhshegane/mongodb-mcp-that-works

CAUTION

This server connects to your MongoDB withfull read/write access to whatever user and database you supply via MONGODB_URI, and it exposes write tools (insertOne, updateOne, deleteOne) to any connected client. Only register it with MCP clients you trust. For high-risk environments, use a read-only MongoDB user or a dedicated database.

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

Related MCP server: Mongo-MCP

Installation

Install from npm

npm install -g @sourabhshegane/mongodb-mcp-that-works

Configuration

This is a standard stdio MCP server. Any MCP client launches it with npx and passes two environment variables:

Variable

Required

Description

MONGODB_URI

Yes

MongoDB connection string, e.g. mongodb+srv://user:pass@cluster.mongodb.net/database

MONGODB_DATABASE

No

Default database name (falls back to the URI's database)

Every client below uses the same launch command:

npx -y @sourabhshegane/mongodb-mcp-that-works@latest

The -y flag auto-confirms the install so the client never hangs on an interactive prompt.

Security: never commit a real connection string. The examples use placeholders, or reference environment variables (${env:...}, env_vars, ${input:...}) so credentials stay out of version control.

Claude Desktop

Edit your Claude Desktop config:

  • 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://<user>:<password>@cluster.mongodb.net/<database>",
        "MONGODB_DATABASE": "your_database_name"
      }
    }
  }
}

Claude Code

Add it with the CLI (anything after -- is the server command):

claude mcp add mongodb --scope user \
  --env MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/<database> \
  -- npx -y @sourabhshegane/mongodb-mcp-that-works@latest

Or commit a project-scoped .mcp.json (secrets referenced with ${VAR}):

{
  "mcpServers": {
    "mongodb": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@sourabhshegane/mongodb-mcp-that-works@latest"],
      "env": {
        "MONGODB_URI": "${MONGODB_URI}",
        "MONGODB_DATABASE": "${MONGODB_DATABASE:-your_database_name}"
      }
    }
  }
}

Scopes: local โ†’ ~/.claude.json, project โ†’ .mcp.json, user โ†’ ~/.claude.json. Verify with claude mcp list.

OpenAI Codex

Codex uses TOML (not JSON). Add to ~/.codex/config.toml (or project-scoped .codex/config.toml):

[mcp_servers.mongodb]
command = "npx"
args = ["-y", "@sourabhshegane/mongodb-mcp-that-works@latest"]
env = { MONGODB_URI = "mongodb+srv://<user>:<password>@cluster.mongodb.net/<database>", MONGODB_DATABASE = "your_database_name" }
startup_timeout_sec = 30

Or forward variables from your shell instead of inlining them:

[mcp_servers.mongodb]
command = "npx"
args = ["-y", "@sourabhshegane/mongodb-mcp-that-works@latest"]
env_vars = ["MONGODB_URI", "MONGODB_DATABASE"]

Or add it with the CLI: codex mcp add mongodb -- npx -y @sourabhshegane/mongodb-mcp-that-works@latest. Verify with codex mcp list.

Cursor

Project scope โ€” .cursor/mcp.json (commit it to share with your team). Global scope โ€” ~/.cursor/mcp.json.

{
  "mcpServers": {
    "mongodb": {
      "command": "npx",
      "args": ["-y", "@sourabhshegane/mongodb-mcp-that-works@latest"],
      "env": {
        "MONGODB_URI": "${env:MONGODB_URI}",
        "MONGODB_DATABASE": "${env:MONGODB_DATABASE}"
      }
    }
  }
}

VS Code / GitHub Copilot

For quick installation, click the buttons below. After install, replace the placeholder connection string in your config:

Install with NPX in VS Code Install with NPX in VS Code Insiders

Note: VS Code's root key is servers (other clients use mcpServers), and type is required. .vscode/mcp.json:

{
  "servers": {
    "mongodb": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@sourabhshegane/mongodb-mcp-that-works@latest"],
      "env": {
        "MONGODB_URI": "${input:mongodb-uri}"
      }
    }
  },
  "inputs": [
    {
      "id": "mongodb-uri",
      "type": "promptString",
      "description": "MongoDB connection string",
      "password": true
    }
  ]
}

Zed

Add to settings.json (~/.config/zed/settings.json or .zed/settings.json):

{
  "mcp": {
    "mongodb": {
      "command": "npx",
      "args": ["-y", "@sourabhshegane/mongodb-mcp-that-works@latest"],
      "env": {
        "MONGODB_URI": "mongodb+srv://<user>:<password>@cluster.mongodb.net/<database>"
      }
    }
  }
}

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
    }
  }
}

Tool annotations (MCP hints)

Tools are annotated with MCP ToolAnnotations so clients can distinguish read-only tools from write-capable tools and flag operations that are destructive:

Tool

readOnlyHint

idempotentHint

destructiveHint

Notes

listCollections

true

โ€“

โ€“

Pure read

find

true

โ€“

โ€“

Pure read

findOne

true

โ€“

โ€“

Pure read

aggregate

true

โ€“

โ€“

Pure read (may also run write stages)

count

true

โ€“

โ€“

Pure read

distinct

true

โ€“

โ€“

Pure read

getSchema

true

โ€“

โ€“

Pure read

insertOne

false

false

false

Additive; retrying inserts a new document

updateOne

false

false

true

Modifies existing docs; $inc/$push are non-idempotent

deleteOne

false

true

true

Deleting an already-absent document is a no-op

Note: aggregate is annotated read-only, but it can contain write stages (e.g. $out, $merge) โ€” inspect pipelines before running.

Best Practices

  1. Use Schema Discovery First: Before querying, run getSchema to understand field names

  2. Handle ObjectIds: The server automatically converts string IDs to ObjectIds

  3. Use Projections: Limit returned fields to improve performance

  4. 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 } }
  ]
});

Debugging

You can use the MCP Inspector to debug the server, inspect tool schemas, and call tools interactively:

npx @modelcontextprotocol/inspector npx -y @sourabhshegane/mongodb-mcp-that-works@latest

Set MONGODB_URI (and optionally MONGODB_DATABASE) in your environment before launching the inspector.

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 getSchema to discover correct field names

  • Remember 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 limit parameter

  • Use projections to return only needed fields

Testing

The repo ships an automated test suite (node:test, no extra framework):

npm test

This first builds, then runs:

  • Unit tests (tests/unit.test.mjs) โ€” MCP protocol: negotiated version, the 10 tool schemas, ToolAnnotations, and error handling. No database required.

  • End-to-end tests (tests/e2e.test.mjs) โ€” full CRUD tour against a real MongoDB (insertOne โ†’ find/findOne/count/distinct/aggregate โ†’ updateOne โ†’ getSchema โ†’ deleteOne), plus ObjectId auto-conversion and idempotency checks. Auto-skips with a note when no MongoDB is reachable.

The suite connects to MongoDB at MONGODB_URI (default mongodb://127.0.0.1:27017) and uses a throwaway database it deletes afterward, so it's safe against any existing data. CI runs both suites against a real MongoDB (Docker mongo:7) on every push/PR.

Contributing

Contributions are welcome โ€” new tools, bug fixes, examples, and documentation improvements. Pull requests and issues are appreciated. See CHANGELOG.md for release history. For examples of other MCP servers, see the reference implementations.

License

MIT License - see LICENSE file for details

Changelog

See CHANGELOG.md for the full history.

Version

npm

GitHub Release

Highlights

0.1.8

npm

v0.1.8

Automated unit + e2e MongoDB test suite

0.1.7

npm

v0.1.7

ToolAnnotations, SDK 1.30, repo-standard docs

0.1.6

npm

v0.1.6

CI/CD, changelog, and repo badges

0.1.5

npm

v0.1.5

Post-migration metadata & ownership fixes

0.1.3

npm

v0.1.3

Published with @latest install docs

0.1.2

npm

v0.1.2

Repo URLs updated to mongodb-mcp-that-works

0.1.0

npm

v0.1.0

Initial release

Releases

All versions published to npm also have tagged GitHub Releases with build checks. The repo uses GitHub Actions for continuous integration and automated publishing:

  • Tag pushes (v*) trigger lint/build checks and, once checks pass, an automated npm publish

  • Every published version has a matching GitHub Release


Made out of pain since the official MongoDB MCP didn't work for me

Available Tools

10 tools
aggregateB
Read-onlyIdempotent

Run an aggregation pipeline on a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum documents to return
pipelineYesMongoDB aggregation pipeline
collectionYesCollection name

TDQS

B3.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate read-only, idempotent, and non-destructive behavior, and the description is consistent with these. However, the description adds no extra behavioral context such as return type, potential performance implications, or pipeline limitations, which would be useful beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no filler, directly stating the core functionality. It is front-loaded with the action and resource, making it immediately clear what the tool does.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool and the presence of annotations and complete schema, the description is adequate but not rich. It does not mention return values or explain pipeline structure, but for an aggregation tool this is not a critical omission.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides descriptions for all three parameters (collection, pipeline, limit) with 100% coverage, so the description adds no additional meaning. The baseline is 3, and no extra semantic detail is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (run) and the resource (an aggregation pipeline on a MongoDB collection). It distinguishes from siblings like find by focusing on the pipeline execution, though it doesn't explicitly contrast with find or other read tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given on when to use aggregation versus alternatives such as find, distinct, or count. The description does not specify scenarios where an aggregation pipeline is preferred or mention any exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

countA
Read-onlyIdempotent

Count documents in a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
filterNoMongoDB filter query
collectionYesCollection name

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, so the safety profile is covered. The description adds little about behavior beyond the count semantics (e.g., it does not state that an omitted filter counts all documents), but it does not contradict the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single 8-word sentence with the key action and resource front-loaded. There is no filler or redundant restatement of the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple count tool with a 100%-described schema and read-only annotations, the description is nearly sufficient. It does not explicitly state the return value, but 'Count' strongly implies a numeric result, making the omission minor.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both 'collection' and 'filter'. The description references collection but adds no parameter detail beyond what the schema provides, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific verb ('Count'), a resource ('documents in a MongoDB collection'), and the operation is immediately distinguishable from sibling read tools like find, findOne, distinct, and aggregate. The word 'Count' makes the tool's role unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description makes it clear this is for counting documents in a collection, which is the relevant context for selecting it over find/aggregate. It does not explicitly name alternatives or state when not to use it, but the operation itself provides enough contextual guidance for a simple count.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

deleteOneA
DestructiveIdempotent

Delete a single document from a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
filterYesFilter to find document
collectionYesCollection name

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already convey destructive and non-read-only behavior. The description adds only the 'single document' scope and does not disclose additional behavioral traits such as irreversibility, behavior when multiple documents match, or response contents.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no filler. Every word contributes to identifying the operation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a basic two-parameter CRUD tool this is minimally adequate, but there is no output schema and the description does not mention what happens if the filter matches multiple documents or what result the caller receives.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema coverage is 100%, so both parameters are already documented. The description adds no extra meaning about how the filter should be formed or how collection name semantics behave.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear action ('Delete') and resource ('a single document from a MongoDB collection'). It is distinct from the sibling read/update tools, though it mostly expands the tool name without adding a differentiating scope condition.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies this tool is used when exactly one document should be removed, but it gives no explicit guidance about when to prefer it over alternatives such as updateOne or findOne. There are no stated exclusions or conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

distinctB
Read-onlyIdempotent

Get distinct values for a field in a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
fieldYesField to get distinct values for
filterNoMongoDB filter query
collectionYesCollection name

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, covering the safety profile. The description adds no additional behavioral context, such as the return format (an array of distinct values) or how the optional filter interacts with the query. With annotations present, the bar is lower, but the description still fails to enrich the agent's understanding of what happens at runtime.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, focused sentence with zero filler. It front-loads the core purpose and is appropriately sized for a simple tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description should specify what the tool returns. It only says 'Get distinct values', which does not clarify that the result is an array, nor does it mention that the optional filter parameter can be used to restrict the query. The filter object is described in the schema but the description never hints at its role. This leaves the agent uncertain about output structure and usage nuances, making the definition incomplete for a tool with a nested object parameter and no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all three parameters (field, filter, collection) are individually described in the schema. The description adds no extra meaning beyond what the schema already provides; it merely restates the purpose. The baseline of 3 applies because the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Get'), a clear resource ('distinct values for a field in a MongoDB collection'), and the operation is unambiguous. It distinguishes from siblings like find/findOne (which return documents) and aggregate (which handles complex pipelines) by focusing on unique values.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus alternatives such as aggregate or find. The description does not mention any exclusions, prerequisites, or conditions that would help an agent choose between distinct and other query tools. This is a single declarative sentence with no comparative context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

findA
Read-onlyIdempotent

Find documents in a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
skipNoNumber of documents to skip
sortNoSort specification
limitNoMaximum documents to return
filterNoMongoDB filter query
collectionYesCollection name
projectionNoFields to include/exclude

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint false, so the safety profile is known. The description adds no behavioral detail such as return format or pagination, but it does not contradict annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no waste. It is front-loaded with the core purpose and does not repeat schema details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is minimal but adequate for a simple read operation given that the schema covers all parameters. However, it does not mention that it returns multiple documents or that it supports filtering/sorting, which could be relevant given the number of parameters and siblings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% for all six parameters, so the schema documents their purpose. The description adds no extra parameter context beyond what is already in the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool finds documents in a MongoDB collection, specifying the verb and resource. It distinguishes from siblings like findOne (single document) and aggregate (pipeline) by the generic 'find' action.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like findOne, aggregate, or count. The description does not mention exclusions or conditions for choosing it over siblings, leaving the agent to infer.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

findOneB
Read-onlyIdempotent

Find a single document in a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
filterNoMongoDB filter query
collectionYesCollection name
projectionNoFields to include/exclude

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The annotations already cover the safety profile (readOnlyHint, idempotentHint, destructiveHint), but the description adds no additional behavioral context. There is no mention of what happens if multiple documents match, whether a null result is returned when no document is found, or any error semantics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no redundant filler. It is appropriately sized for a simple read tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The complete schema and annotations make the tool minimally usable, but the description leaves unspecified the return contract and behavior for non-matches or multiple matches. Since there is no output schema, a brief note about the returned document or null would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage for all three parameters (filter, collection, projection), so the schema itself documents the parameters. The description adds no further parameter-specific meaning, so the baseline score applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the specific verb 'Find' and specifies the resource as 'a single document in a MongoDB collection.' The word 'single' clearly distinguishes it from the sibling tool find, making the tool's scope immediately obvious.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use findOne versus the sibling find, aggregate, or count tools, and no exclusions or conditions are provided. The intended use-case is only implied by the word 'single.'

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

getSchemaA
Read-onlyIdempotent

Analyze collection structure and return field names with types

ParametersJSON Schema
NameRequiredDescriptionDefault
collectionYesCollection name
sampleSizeNoNumber of documents to sample

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the safety profile is fully covered. The description adds that it returns field names with types, which is part of its behavior, but doesn't disclose that it samples documents (implied by sampleSize param) or that results are approximate. No contradiction, but no additional behavioral context beyond the purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, compact sentence that front-loads the main action ('Analyze collection structure') and the outcome ('return field names with types'). No redundant words, and it is immediately scannable by an agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only analysis tool with two well-documented parameters, the description is sufficient. It states the return content (field names with types) and the tool's purpose. It could mention that results are based on sampling (given the sampleSize parameter), but that is inferable. No output schema exists, so the description covers the essential return information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage: both 'collection' and 'sampleSize' have descriptive text. The description does not add any parameter-specific details beyond what the schema provides. Since the schema already documents the parameters adequately, the baseline of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: analyze collection structure and return field names with types. This distinguishes it from siblings like find (returns documents), aggregate (returns computed results), and listCollections (lists collections). The verb 'analyze' is specific and the resource 'collection structure' is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the tool is for schema introspection rather than data retrieval. While it doesn't explicitly name alternatives or state when not to use it, the contrast with sibling tools is clear enough for an agent to select it appropriately. A mention of 'use this instead of find when you need structure' would make it a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

insertOneB

Insert a single document into a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
documentYesDocument to insert
collectionYesCollection name

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already communicate readOnlyHint=false, idempotentHint=false, and destructiveHint=false, and the description adds no behavior beyond restating the insert operation. It does not disclose return value behavior, duplicate-insert consequences, or any required permissions, so it provides little value beyond the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, concise sentence that is front-loaded and contains no filler. Every word contributes to the core meaning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter tool with full schema coverage and annotations present, the description is minimally adequate. However, there is no mention of the return value or what happens on repeated insertions, and since there is no output schema, the description could usefully provide more context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both parameters are already documented. The description mentions 'collection' and 'document' only as part of the sentence and adds no extra semantic detail beyond what the schema provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('insert') and a specific resource ('a single document into a MongoDB collection'), making the core operation clear. It is distinguishable from siblings like updateOne and deleteOne, though it does not explicitly name or contrast them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The word 'insert' implies this tool is for adding new documents rather than updating or deleting them, so usage is indirectly conveyed. However, there is no explicit guidance about when to prefer this over updateOne/deleteOne or any prerequisites such as needing an existing collection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

listCollectionsA
Read-onlyIdempotent

List all collections in the database

ParametersJSON Schema
NameRequiredDescriptionDefault
filterNoOptional filter for collections

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare the operation read-only, idempotent, and non-destructive. The description adds that it enumerates collections, but does not clarify behavior such as whether system collections are included or how the optional filter affects results. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence with no filler, front-loading the action and resource. It is as concise as possible while stating the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only tool with a single optional parameter, the description is mostly adequate. However, the filter parameter's semantics remain vague, and with no output schema the agent gets little detail about what a successful result looks like.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the filter parameter is documented as 'Optional filter for collections.' The description adds no additional meaning about the filter's shape, allowed keys, or filtering behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('List'), the resource ('collections'), and the scope ('all in the database'). It distinguishes from document-level siblings like find and count, though it does not explicitly name an alternative.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The intended use is implied: enumerate collections rather than documents. However, there is no explicit when-to-use guidance, no exclusion of document-level tools, and no mention of how this relates to getSchema.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

updateOneC
Destructive

Update a single document in a MongoDB collection

ParametersJSON Schema
NameRequiredDescriptionDefault
filterYesFilter to find document
updateYesUpdate operations
upsertNoCreate if not exists
collectionYesCollection name

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare destructiveHint=true and readOnlyHint=false, so the destructive nature is known. However, the description adds no extra behavioral contextโ€”no mention of return value, error behavior if no document matches, or consequences of the upsert option. It contributes nothing beyond the schema and annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single, clear sentence with no redundant words. It is appropriately sized for a simple tool and front-loads the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with destructiveHint, this is under-specified. There is no output schema, so the description should explain what the tool returns (e.g., modified count, updated document) and how it handles non-matching filters or upsert behavior. The tool also has nested objects, but the schema covers those. Overall, the description leaves important operational details unstated.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all four parameters (collection, filter, update, upsert) are documented in the schema. The description adds no parameter details, but the baseline of 3 applies because the schema carries the full load.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (Update) and resource (a single document in a MongoDB collection). It clearly differentiates from read siblings (find, findOne) and delete (deleteOne) by its action, though it doesn't explicitly contrast with insertOne or mention that it targets exactly one document.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. It doesn't mention when to prefer updateOne over insertOne (if document may not exist), or over bulk update operations. The sibling list implies context, but the description provides no explicit routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 8 tool updatesv0.1.8
    • Addedaggregate
    • Addedcount
    • Addeddistinct
    • Addedfind
    • AddedfindOne
    • AddedinsertOne
    • AddedlistCollections
    • AddedupdateOne
  2. 2 tool updatesv0.1.3
    • First observeddeleteOne
    • First observedgetSchema

TDQS

A3.7/5.0
Disambiguation5/5

Each tool targets a distinct MongoDB operation: find vs findOne are clearly differentiated (multiple vs single document), and aggregate, count, distinct, listCollections, insertOne, updateOne, deleteOne, and getSchema have no overlapping responsibilities. The descriptions clarify the purpose of each, leaving no ambiguity for an agent.

Naming Consistency5/5

All tool names follow a consistent lowerCamelCase convention with a verb-first pattern (find, findOne, aggregate, count, distinct, listCollections, insertOne, updateOne, deleteOne, getSchema). The style is uniform and predictable, making it easy to infer tool behavior from the name.

Tool Count5/5

With 10 tools, the server is well-scoped for a MongoDB interface. It covers querying, aggregation, schema inspection, and basic CRUD operations without unnecessary bloat. Each tool serves a clear purpose, and the count is ideal for an MCP server of this domain.

Completeness4/5

The tool surface covers the core CRUD operations (insertOne, updateOne, deleteOne, find, findOne) and includes useful extras like aggregate, count, distinct, and getSchema. However, it lacks bulk operations (insertMany, updateMany, deleteMany) and collection management (createCollection, dropCollection), which are common in MongoDB workflows. These are minor gaps that an agent can work around by composing single-document calls, but they are noticeable.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with MongoDB databases through complete CRUD operations including connecting, creating, reading, updating, and deleting documents with support for filtering, pagination, and automatic ObjectId serialization.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables LLMs to interact with MongoDB databases through a complete suite of CRUD operations, administrative tasks, and index management tools. It supports database and collection handling, aggregation pipelines, and comprehensive server monitoring via the Model Context Protocol.
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with MongoDB databases and MongoDB Atlas for querying data and managing clusters via the Model Context Protocol. It supports both local and cloud-based deployments using connection strings or Atlas API credentials.
    78,836
    Apache 2.0
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables interaction with MongoDB databases through the Model Context Protocol, supporting CRUD operations, secure connections, and easy IDE integration.
    14
    3
    MIT

Latest Blog Posts

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/sourabhshegane/mongodb-mcp-that-works'

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