Skip to main content
Glama

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
NameRequiredDescriptionDefault
container_idYesThe ID of the container
document_idYesThe ID of the document to retrieve
partition_keyYesThe partition key value for the document

Implementation Reference

  • 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 }; } };
  • 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);
  • 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';

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