Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

db-stats

Read-only

Retrieve database usage statistics to monitor storage, collections, and performance metrics for MongoDB databases.

Instructions

Returns statistics that reflect the use state of a single database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesDatabase name

Implementation Reference

  • The main handler function that ensures connection to MongoDB, executes the 'dbStats' command on the specified database with scale:1, formats the result using EJSON and formatUntrustedData, and returns it as tool content.
    protected async execute({ database }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
        const provider = await this.ensureConnected();
        const result = await provider.runCommandWithCheck(database, {
            dbStats: 1,
            scale: 1,
        });
    
        return {
            content: formatUntrustedData(`Statistics for database ${database}`, EJSON.stringify(result)),
        };
    }
  • Zod schema defining the input arguments: requires a 'database' string parameter.
    protected argsShape = {
        database: DbOperationArgs.database,
    };
  • Tool metadata definition including name 'db-stats', description, input schema (argsShape), and static operationType 'metadata' used during class instantiation and MCP server registration via ToolBase.register().
    public name = "db-stats";
    protected description = "Returns statistics that reflect the use state of a single database";
    protected argsShape = {
        database: DbOperationArgs.database,
    };
    
    static operationType: OperationType = "metadata";
  • Barrel export of DbStatsTool making it available for inclusion in the AllTools array in src/tools/index.ts, from which the server instantiates and registers all tools.
    export { DbStatsTool } from "./metadata/dbStats.js";
  • Collects all tool classes (including DbStatsTool via MongoDbTools) into AllTools array, which is used by Server.registerTools() to instantiate each tool with session/config/etc. and call register() to add to MCP server.
    export const AllTools: ToolClass[] = Object.values({
        ...MongoDbTools,
        ...AtlasTools,
        ...AtlasLocalTools,
    });
Behavior3/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false, so the agent knows this is a safe read operation. The description adds value by specifying that it returns 'statistics' and focuses on 'use state', which provides context beyond the annotations. However, it lacks details on rate limits, authentication needs, or error handling, leaving some behavioral aspects unclear.

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, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded with the core action ('Returns statistics'), making it easy to understand at a glance. Every part of the sentence contributes to clarifying the 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?

Given the tool's low complexity (1 parameter, no output schema) and good annotations, the description is somewhat complete but has gaps. It lacks details on what specific statistics are returned (e.g., size, query counts) or how to interpret them, which could be important for users. With no output schema, more elaboration on return values would be beneficial.

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% description coverage, with the 'database' parameter clearly documented. The description does not add any additional meaning beyond the schema, such as explaining what constitutes a valid database name or examples. Since the schema does the heavy lifting, a baseline score of 3 is appropriate.

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 tool's purpose with a specific verb ('Returns') and resource ('statistics'), and specifies the scope ('use state of a single database'). However, it does not explicitly differentiate this tool from potential siblings like 'list-databases' or 'collection-storage-size', which might also provide database-related information, so it falls short of a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It does not mention prerequisites, such as needing an existing database, or compare it to sibling tools like 'list-databases' for broader information. Without such context, users might struggle to select the appropriate tool.

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/mongodb-js/mongodb-mcp-server'

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