mcp_list_containers
List all containers within a CosmosDB database to streamline container discovery and database analysis, using a straightforward input schema for execution.
Instructions
List all containers in the CosmosDB database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| random_string | Yes | Dummy parameter for no-parameter tools |
Implementation Reference
- src/tools/containerAnalysis.ts:32-54 (handler)The main async handler function that executes the logic to list all containers in the CosmosDB database, maps them to ContainerInfo, and returns ToolResult.export const mcp_list_containers = async (): Promise<ToolResult<ContainerInfo[]>> => { console.log('Executing mcp_list_containers'); try { const database = getDatabase(); const { resources: containers } = await database.containers.readAll().fetchAll(); const containersInfo: ContainerInfo[] = containers.map((container: any) => ({ id: container.id, partitionKey: container.partitionKey ? { paths: container.partitionKey.paths || [], kind: container.partitionKey.kind } : undefined, indexingPolicy: container.indexingPolicy, etag: container._etag, timestamp: container._ts ? new Date(container._ts * 1000) : undefined })); return { success: true, data: containersInfo }; } catch (error: any) { console.error(`Error in mcp_list_containers: ${error.message}`); return { success: false, error: error.message }; }
- src/tools.ts:20-31 (schema)Input schema definition for the mcp_list_containers tool, requiring a dummy random_string parameter since it's a no-arg tool.name: "mcp_list_containers", description: "List all containers in the CosmosDB database", inputSchema: { type: "object", properties: { random_string: { type: "string", description: "Dummy parameter for no-parameter tools" } }, required: ["random_string"] }
- src/tools/types.ts:14-24 (schema)Type definition for ContainerInfo, used in the output of mcp_list_containers.export interface ContainerInfo { id: string; partitionKey?: { paths: string[]; kind?: string; }; throughput?: number; indexingPolicy?: any; etag?: string; timestamp?: Date; }
- src/tools.ts:19-32 (registration)The tool is registered in the MCP_COSMOSDB_TOOLS array used for ListTools response.{ name: "mcp_list_containers", description: "List all containers in the CosmosDB database", inputSchema: { type: "object", properties: { random_string: { type: "string", description: "Dummy parameter for no-parameter tools" } }, required: ["random_string"] } },
- src/server.ts:94-95 (registration)Handler invocation/registration in the CallToolRequestHandler switch statement.case 'mcp_list_containers': result = await toolHandlers.mcp_list_containers();