mcp_list_databases
Retrieve a list of all databases in your Azure CosmosDB account to manage and analyze your document storage resources.
Instructions
List all databases in the CosmosDB account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| random_string | Yes | Dummy parameter for no-parameter tools |
Implementation Reference
- src/tools/containerAnalysis.ts:7-27 (handler)The handler function that executes the logic to list all databases in the CosmosDB account using the client API.export const mcp_list_databases = async (): Promise<ToolResult<DatabaseInfo[]>> => { console.log('Executing mcp_list_databases'); try { const database = getDatabase(); const client = database.client; const { resources: databases } = await client.databases.readAll().fetchAll(); const databasesInfo: DatabaseInfo[] = databases.map(db => ({ id: db.id, etag: db._etag, timestamp: new Date(db._ts * 1000) })); return { success: true, data: databasesInfo }; } catch (error: any) { console.error(`Error in mcp_list_databases: ${error.message}`); return { success: false, error: error.message }; } };
- src/tools.ts:4-16 (registration)Tool registration in MCP_COSMOSDB_TOOLS array, defining name, description, and input schema for the MCP ListTools request.name: "mcp_list_databases", description: "List all databases in the CosmosDB account", inputSchema: { type: "object", properties: { random_string: { type: "string", description: "Dummy parameter for no-parameter tools" } }, required: ["random_string"] } },
- src/tools/types.ts:7-12 (schema)TypeScript interface defining the structure of DatabaseInfo returned by the tool.export interface DatabaseInfo { id: string; throughput?: number; etag: string; timestamp: Date; }
- src/tools/types.ts:2-4 (schema)Type definitions for tool results, used as return type for the handler.export type ToolSuccessResult<T> = { success: true; data: T; }; export type ToolErrorResult = { success: false; error: string; }; export type ToolResult<T> = ToolSuccessResult<T> | ToolErrorResult;
- src/server.ts:91-92 (registration)Dispatch/registration in the CallTool handler switch statement that invokes the tool handler.case 'mcp_list_databases': result = await toolHandlers.mcp_list_databases();