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
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | Database 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";
- src/tools/mongodb/tools.ts:22-43 (registration)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); } }