Skip to main content
Glama

mcp_list_containers

Retrieve all containers within a CosmosDB database to analyze structure and manage document storage.

Instructions

List all containers in the CosmosDB database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
random_stringYesDummy parameter for no-parameter tools

Implementation Reference

  • The main asynchronous handler function that lists all containers in the current CosmosDB database, maps their info to ContainerInfo type, 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 }; }
  • JSON Schema definition for the tool registration, including input schema (uses dummy param since tool takes no arguments). Used in 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)
    Dispatch case in the CallTool request handler that invokes the mcp_list_containers tool handler.
    case 'mcp_list_containers': result = await toolHandlers.mcp_list_containers();
  • TypeScript interface defining the structure of ContainerInfo returned in the tool's output.
    export interface ContainerInfo { id: string; partitionKey?: { paths: string[]; kind?: string; }; throughput?: number; indexingPolicy?: any; etag?: string; timestamp?: Date; }
  • src/server.ts:64-66 (registration)
    Registration of the ListTools handler which returns the array of tools including mcp_list_containers with its schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: MCP_COSMOSDB_TOOLS }));

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/hendrickcastro/MCPCosmosDB'

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