Skip to main content
Glama
hendrickcastro

MCP CosmosDB

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';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves a document but doesn't mention error handling (e.g., if the document doesn't exist), performance characteristics, or authentication requirements. This leaves significant gaps for a tool that likely interacts with a database or storage system.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to understand at a glance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., document content, metadata), error conditions, or how it differs from sibling tools. Given the complexity of document retrieval in a database context, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting all three required parameters. The description adds minimal value by mentioning 'ID and partition key' but doesn't explain the relationship between parameters or provide usage examples beyond what the schema already states.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('a specific document'), specifying retrieval by ID and partition key. It distinguishes from the sibling tool 'mcp_get_documents' by focusing on a single document rather than multiple, though it doesn't explicitly name this distinction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'mcp_get_documents' for multiple documents or 'mcp_execute_query' for more complex retrieval. It lacks context about prerequisites or typical use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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