mcp_get_document_by_id
Retrieve a specific document from Azure CosmosDB using its unique ID and partition key to access stored data directly.
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 core handler function that executes the tool logic: retrieves a document by ID and partition key from a CosmosDB container.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)Defines the tool's metadata, description, and input schema for validation in the MCP tools list.{ 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-110 (registration)Registers and dispatches the tool handler in the MCP server's CallTool request handler switch statement.case 'mcp_get_document_by_id': result = await toolHandlers.mcp_get_document_by_id(input as any);
- src/tools/index.ts:13-17 (registration)Exports the handler function for use in toolHandlers via mcp-server.ts re-export.mcp_execute_query, mcp_get_documents, mcp_get_document_by_id, mcp_analyze_schema } from './dataOperations.js';
- src/mcp-server.ts:1-2 (registration)Re-exports all tools from tools/index.ts to be imported as toolHandlers in server.ts.// Import all tools from the modular structure export * from './tools/index.js';