Skip to main content
Glama
officialpraise

MongoDB MCP Server

db-stats

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

  • Handler function that connects to MongoDB provider, runs dbStats command with scale:1 on the specified database, and returns statistics as formatted text 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: [ { text: `Statistics for database ${database}`, type: "text", }, { text: EJSON.stringify(result), type: "text", }, ], }; }
  • Tool metadata including name, description, input schema (database arg), and operation type.
    protected name = "db-stats"; protected description = "Returns statistics that reflect the use state of a single database"; protected argsShape = { database: DbOperationArgs.database, }; protected operationType: OperationType = "metadata";
  • DbStatsTool is registered in the MongoDbTools array, which collects all MongoDB-related tools.
    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)
    All tools including those from MongoDbTools (DbStatsTool) are instantiated and registered to the MCP server in the registerTools method.
    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