Skip to main content
Glama

Suggest a MongoDB index

suggest_mongo_index
Read-only

Generates MongoDB createIndex commands for unindexed fields plus compound and text indexes, with an explain query to verify. Use when a collection scan is flagged or filtering on an unindexed field.

Instructions

Generates the exact db.collection.createIndex() command for a MongoDB field, plus compound and text index variants and an explain query to verify. Call this when a collection scan is flagged by the analyzer or when writing a query that filters on an unindexed field. Does not check whether the index already exists.

Input Schema

NameRequiredDescriptionDefault
fieldYesField name to index
collectionYesMongoDB collection name

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, so safety is covered. The description adds real behavioral context beyond that: what the output contains (createIndex command, compound/text variants, verification explain query) and the limitation that it will not detect an existing index. It stops short of saying the output is advisory only or how duplicates would manifest.

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?

Three sentences, each earning its place: output scope first, invocation triggers second, limitation last. No filler or restatement of the tool name.

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

Completeness5/5

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

No output schema exists, and the description compensates by describing what is produced and why (verification via explain). With annotations covering safety, triggers covered, and the duplicate-index caveat stated, an agent has everything needed to invoke it correctly.

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% with only two parameters (field, collection), both self-describing, so the schema carries the semantics. The description adds no format, naming, or dot-notation guidance for nested fields that would go beyond the schema. Baseline 3 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?

States a precise verb+resource ('Generates the exact db.collection.createIndex() command for a MongoDB field') and enumerates the deliverables (compound and text variants, explain query). This clearly separates it from the sibling index tools suggest_gsi, postgres_index_suggestions, and mysql_index_suggestions.

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?

Gives two concrete triggers ('when a collection scan is flagged by the analyzer' or 'when writing a query that filters on an unindexed field') and adds a boundary condition ('Does not check whether the index already exists'). The only minor gap is not naming a sibling as the alternative, but the invocation conditions are fully explicit.

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