mcp_get_container_definition
Retrieve comprehensive configuration details of an Azure CosmosDB container, including partition key, indexing policy, and throughput settings. Use this to understand container structure before writing queries.
Instructions
Get detailed configuration of a specific container including partition key, indexing policy, and throughput settings. Use this to understand the container structure before writing queries. Example: mcp_get_container_definition({container_id: 'users', connection_id: 'athlete'})
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| container_id | Yes | The ID/name of the container (e.g., 'users', 'orders', 'products') | |
| connection_id | No | ID of the connection to use. Use mcp_list_connections to see available connections. If not specified, uses the default connection. |
Implementation Reference
- src/tools/containerAnalysis.ts:83-124 (handler)Main handler function for mcp_get_container_definition. Reads container definition (partition key, indexing policy, etag, timestamp) and throughput settings via CosmosDB SDK's container.read() and container.readOffer(). Returns ContainerInfo with throughput data.
export const mcp_get_container_definition = async (args: { container_id: string; connection_id?: string }): Promise<ToolResult<ContainerInfo & { throughputInfo?: any }>> => { const { container_id, connection_id } = args; log(`Executing mcp_get_container_definition with: ${JSON.stringify(args)}`); try { const container = getContainer(container_id, connection_id); // Read container definition const { resource: containerDef } = await container.read(); // Try to read throughput settings let throughputInfo; try { const offerResponse = await container.readOffer(); throughputInfo = offerResponse.resource; } catch (offerError) { // Throughput might not be defined for shared throughput containers log('Could not read container throughput (might use shared database throughput)'); } if (!containerDef) { throw new Error(`Container ${container_id} not found`); } const containerInfo: ContainerInfo & { throughputInfo?: any } = { id: containerDef.id, partitionKey: containerDef.partitionKey ? { paths: containerDef.partitionKey.paths || [], kind: containerDef.partitionKey.kind } : undefined, indexingPolicy: containerDef.indexingPolicy, etag: containerDef._etag, timestamp: containerDef._ts ? new Date(containerDef._ts * 1000) : undefined, throughputInfo }; return { success: true, data: containerInfo }; } catch (error: any) { log(`Error in mcp_get_container_definition for container ${container_id}: ${error.message}`); return { success: false, error: error.message }; } }; - src/tools.ts:47-62 (schema)Input schema definition for mcp_get_container_definition. Declares the tool name, description, and inputSchema requiring container_id (string) and optional connection_id.
// 3. Container Information { name: "mcp_get_container_definition", description: "Get detailed configuration of a specific container including partition key, indexing policy, and throughput settings. Use this to understand the container structure before writing queries. Example: mcp_get_container_definition({container_id: 'users', connection_id: 'athlete'})", inputSchema: { type: "object", properties: { container_id: { type: "string", description: "The ID/name of the container (e.g., 'users', 'orders', 'products')" }, ...connectionIdProperty }, required: ["container_id"] } }, - src/server.ts:126-129 (registration)Registration in the server's CallToolRequestHandler. Routes the 'mcp_get_container_definition' tool name to the handler function via toolHandlers.mcp_get_container_definition().
// Container information case 'mcp_get_container_definition': result = await toolHandlers.mcp_get_container_definition(input as any); break; - src/tools/index.ts:4-9 (registration)Re-exports mcp_get_container_definition from containerAnalysis.ts in the central tools index barrel file.
export { mcp_list_databases, mcp_list_containers, mcp_get_container_definition, mcp_get_container_stats } from './containerAnalysis.js'; - src/tools/types.ts:14-24 (helper)ContainerInfo interface used as the shape of the returned data. Includes id, partitionKey (paths and kind), indexingPolicy, etag, and timestamp fields.
export interface ContainerInfo { id: string; partitionKey?: { paths: string[]; kind?: string; }; throughput?: number; indexingPolicy?: any; etag?: string; timestamp?: Date; }