Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

mongodb-logs

Read-only

Retrieve recent MongoDB database log events to monitor system activity, troubleshoot issues, or review startup warnings for operational insights.

Instructions

Returns the most recent logged mongod events

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNoThe type of logs to return. Global returns all recent log entries, while startupWarnings returns only warnings and errors from when the process started.global
limitNoThe maximum number of log entries to return.

Implementation Reference

  • The main handler function 'execute' that implements the 'mongodb-logs' tool. It connects to MongoDB, runs the 'getLog' command on the admin database, processes the logs (trims and limits), and formats the output.
    protected async execute({ type, limit }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
        const provider = await this.ensureConnected();
    
        const result = await provider.runCommandWithCheck("admin", {
            getLog: type,
        });
    
        // Trim ending newlines so that when we join the logs we don't insert empty lines
        // between messages.
        const logs = (result.log as string[]).slice(0, limit).map((l) => l.trimEnd());
    
        let message = `Found: ${result.totalLinesWritten} messages`;
        if (result.totalLinesWritten > limit) {
            message += ` (showing only the first ${limit})`;
        }
        return {
            content: formatUntrustedData(message, logs.join("\n")),
        };
    }
  • Zod schema defining the input arguments for the tool: 'type' (global or startupWarnings, default global) and 'limit' (1-1024, default 50).
    protected argsShape = {
        type: z
            .enum(["global", "startupWarnings"])
            .optional()
            .default("global")
            .describe(
                "The type of logs to return. Global returns all recent log entries, while startupWarnings returns only warnings and errors from when the process started."
            ),
        limit: z
            .number()
            .int()
            .max(1024)
            .min(1)
            .optional()
            .default(50)
            .describe("The maximum number of log entries to return."),
    };
  • Export of the LogsTool class, which allows it to be included in the main tools registry via src/tools/index.ts.
    export { LogsTool } from "./metadata/logs.js";
  • The AllTools array that registers all tools, including those from MongoDbTools which encompasses the mongodb-logs tool.
    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 declare readOnlyHint=true and destructiveHint=false, so the agent knows this is a safe read operation. The description adds that it returns 'most recent' events, which hints at recency but doesn't specify time windows or ordering. It lacks details on rate limits, authentication needs, or output format (e.g., structured vs. raw logs). With annotations covering safety, the description adds minimal but not rich behavioral context.

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: 'Returns the most recent logged mongod events.' It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for a simple tool. Every part of the sentence earns its place by specifying action, resource, and a key constraint.

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 (2 parameters, no output schema, simple annotations), the description is somewhat complete but has gaps. It covers the basic purpose but lacks usage guidelines and detailed behavioral context. With annotations handling safety, the description is adequate but not fully helpful for an agent to understand when and how to use it effectively in context with 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%, with clear documentation for both parameters (type and limit), including enums and defaults. The description doesn't add any parameter-specific information beyond what the schema provides. According to the rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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: 'Returns the most recent logged mongod events.' It specifies the verb ('returns') and resource ('logged mongod events'), and the qualifier 'most recent' adds useful context. However, it doesn't explicitly differentiate from sibling tools like 'atlas-list-alerts' or 'atlas-get-performance-advisor', which might also return log-like data, 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 doesn't mention sibling tools, prerequisites, or specific contexts (e.g., debugging vs. monitoring). The agent must infer usage from the tool name and description alone, which is insufficient for clear decision-making.

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