Skip to main content
Glama
zhusinian
by zhusinian

execute_mongodb

Execute MongoDB commands using JSON syntax for find, aggregate, and more. Supports Extended JSON for BSON values like ObjectId and date.

Instructions

Execute a MongoDB command query. Use MongoDB command syntax, not Mongo shell JavaScript. Do not generate db.collection.find(...) or db.users.aggregate(...). Instead generate command JSON such as {"find":"users","filter":{"active":true},"limit":10}. For aggregate, include "cursor": {}, for example {"aggregate":"orders","pipeline":[{"$match":{"status":"paid"}}],"cursor":{}}. Use query when providing a string; it must be valid Extended JSON. Use $oid/$date Extended JSON for BSON values. In --readOnly mode, write/unknown commands are rejected, and aggregate with $out/$merge is treated as write.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoMongoDB command as an Extended JSON string. Prefer this when the AI is asked to provide a query string. Do not use Mongo shell JavaScript. Example: {"find":"users","filter":{"_id":{"$oid":"66f000000000000000000001"}},"limit":1}.
commandNoMongoDB command document object. Example find: { find: 'users', filter: { active: true }, limit: 10 }. Example aggregate: { aggregate: 'orders', pipeline: [{ $match: { status: 'paid' } }], cursor: {} }.
databaseNoDatabase name. Defaults to the database from connect, or MongoDB driver's default.
commandJsonNoAlias of query for Extended JSON command strings. Prefer query for new calls.
connectionIdNoConnection id. Defaults to the latest connection.
Behavior4/5

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

No annotations provided, so description covers behavioral traits: readOnly mode rejects writes, aggregate with $out/$merge treated as write, and requires Extended JSON. Missing details about return value or errors but sufficient.

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?

Concise, front-loaded with purpose, every sentence adds value, examples are clear, no redundancy.

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?

Given complexity and no output schema, description covers usage well. Could add output format or error behavior, but overall complete enough for agent to use correctly.

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

Parameters4/5

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

Schema coverage is 100% so baseline 3, but description adds meaning: explains difference between query and commandJson, gives examples for command object, and notes defaults for database and connectionId.

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 it executes a MongoDB command query, distinguishes from sibling tools like execute_sql by specifying MongoDB syntax, and contrasts with transaction tools.

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

Usage Guidelines5/5

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

Provides explicit guidelines: use MongoDB command syntax not Mongo shell JS, gives examples, warns about readOnly mode restrictions, and implies when to use this vs other tools.

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

Install Server

Other Tools

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/zhusinian/db-mcp'

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