Skip to main content
Glama
officialpraise

MongoDB MCP Server

mongodb-logs

Retrieve recent MongoDB database log events to monitor system activity, troubleshoot issues, or analyze 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 `execute` method is the core handler for the 'mongodb-logs' tool. It connects to MongoDB, executes the 'getLog' command on the admin database with the specified type, limits the results, and formats the log entries into a CallToolResult.
    protected async execute({ type, limit }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> { const provider = await this.ensureConnected(); const result = await provider.runCommandWithCheck("admin", { getLog: type, }); const logs = (result.log as string[]).slice(0, limit); return { content: [ { text: `Found: ${result.totalLinesWritten} messages`, type: "text", }, ...logs.map( (log) => ({ text: log, type: "text", }) as const ), ], }; }
  • Zod-based input schema definition for the tool arguments: optional 'type' (global or startupWarnings, defaults to global) and 'limit' (1-1024, defaults to 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."), };
  • The LogsTool class is registered (included) in the MongoDbTools array, which collects all MongoDB-related tools for server registration.
    export const MongoDbTools = [ ConnectTool, ListCollectionsTool, ListDatabasesTool, CollectionIndexesTool, CreateIndexTool, CollectionSchemaTool, FindTool, InsertManyTool, DeleteManyTool, CollectionStorageSizeTool, CountTool, DbStatsTool, AggregateTool, UpdateManyTool, RenameCollectionTool, DropDatabaseTool, DropCollectionTool, ExplainTool, CreateCollectionTool, LogsTool, ];
  • src/server.ts:141-145 (registration)
    Top-level registration loop in the Server class that instantiates and registers all tools from MongoDbTools (including LogsTool) with the MCP server.
    private registerTools() { for (const tool of [...AtlasTools, ...MongoDbTools]) { new tool(this.session, this.userConfig, this.telemetry).register(this.mcpServer); } }

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/officialpraise/mcp'

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