mcp_get_document_by_id
Retrieve a specific document from an Azure CosmosDB container using its ID and partition key for precise data access and analysis.
Instructions
Get a specific document by its ID and partition key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| container_id | Yes | The ID of the container | |
| document_id | Yes | The ID of the document to retrieve | |
| partition_key | Yes | The partition key value for the document |
Implementation Reference
- src/tools/dataOperations.ts:100-117 (handler)The main execution function (handler) for the mcp_get_document_by_id tool. It retrieves a specific document from a CosmosDB container using the provided container_id, document_id, and partition_key.export const mcp_get_document_by_id = async (args: { container_id: string; document_id: string; partition_key: string; }): Promise<ToolResult<DocumentInfo>> => { const { container_id, document_id, partition_key } = args; console.log('Executing mcp_get_document_by_id with:', args); try { const container = getContainer(container_id); const { resource: document } = await container.item(document_id, partition_key).read(); return { success: true, data: document }; } catch (error: any) { console.error(`Error in mcp_get_document_by_id for document ${document_id}: ${error.message}`); return { success: false, error: error.message }; } };
- src/tools.ts:135-156 (schema)The tool definition including name, description, and inputSchema used for validation and MCP tool listing.{ name: "mcp_get_document_by_id", description: "Get a specific document by its ID and partition key", inputSchema: { type: "object", properties: { container_id: { type: "string", description: "The ID of the container" }, document_id: { type: "string", description: "The ID of the document to retrieve" }, partition_key: { type: "string", description: "The partition key value for the document" } }, required: ["container_id", "document_id", "partition_key"] } },
- src/server.ts:109-111 (registration)The dispatch case in the CallToolRequestSchema handler that specifically routes calls to this tool's handler function.case 'mcp_get_document_by_id': result = await toolHandlers.mcp_get_document_by_id(input as any); break;