Skip to main content
Glama
hendrickcastro

MCP CosmosDB

mcp_get_documents

Retrieve documents from Azure CosmosDB containers using optional filters, partition keys, and result limits for targeted data queries.

Instructions

Get documents from a container with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
container_idYesThe ID of the container to query
limitNoMaximum number of documents to return
partition_keyNoOptional partition key to filter by
filter_conditionsNoOptional filter conditions as key-value pairs

Implementation Reference

  • The handler function implementing mcp_get_documents tool logic. Retrieves documents from CosmosDB container using SQL query with optional filters, partition key, and limit.
    export const mcp_get_documents = async (args: { 
      container_id: string; 
      limit?: number;
      partition_key?: string;
      filter_conditions?: Record<string, any>;
    }): Promise<ToolResult<DocumentInfo[]>> => {
      const { container_id, limit = 100, partition_key, filter_conditions } = args;
      console.log('Executing mcp_get_documents with:', args);
    
      try {
        const container = getContainer(container_id);
    
        // Build query
        let query = `SELECT * FROM c`;
        const parameters: Array<{ name: string; value: any }> = [];
    
        // Add filter conditions
        if (filter_conditions && Object.keys(filter_conditions).length > 0) {
          const whereClauses = Object.entries(filter_conditions).map(([key, value], index) => {
            const paramName = `@param${index}`;
            parameters.push({ name: paramName, value });
            return `c.${key} = ${paramName}`;
          });
          query += ` WHERE ${whereClauses.join(' AND ')}`;
        }
    
        // Add limit
        query = `SELECT TOP ${limit} * FROM (${query})`;
    
        const querySpec = { query, parameters };
    
        // Query options
        const options: any = { maxItemCount: limit };
        if (partition_key) {
          options.partitionKey = partition_key;
        }
    
        const { resources: documents } = await container.items.query(querySpec, options).fetchAll();
    
        return { success: true, data: documents };
      } catch (error: any) {
        console.error(`Error in mcp_get_documents for container ${container_id}: ${error.message}`);
        return { success: false, error: error.message };
      }
    };
  • Schema definition for mcp_get_documents tool, including input schema used in ListTools response.
    {
      name: "mcp_get_documents",
      description: "Get documents from a container with optional filters",
      inputSchema: {
        type: "object",
        properties: {
          container_id: {
            type: "string",
            description: "The ID of the container to query"
          },
          limit: {
            type: "number",
            description: "Maximum number of documents to return",
            default: 100
          },
          partition_key: {
            type: "string",
            description: "Optional partition key to filter by"
          },
          filter_conditions: {
            type: "object",
            description: "Optional filter conditions as key-value pairs"
          }
        },
        required: ["container_id"]
      }
    },
  • Re-exports the mcp_get_documents handler from dataOperations.ts, enabling its import via tools/index.ts.
    export {
      mcp_execute_query,
      mcp_get_documents,
      mcp_get_document_by_id,
      mcp_analyze_schema
    } from './dataOperations.js';
  • src/server.ts:106-108 (registration)
    Registers the handler dispatch for mcp_get_documents in the main server tool call switch statement.
    case 'mcp_get_documents':
        result = await toolHandlers.mcp_get_documents(input as any);
        break;
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 it 'gets documents' but doesn't describe what 'get' means operationally - whether this is a read-only operation, what permissions are required, whether results are paginated, what happens when limit is exceeded, or how filter_conditions are applied. For a tool with 4 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 extremely concise at just 7 words, front-loading the core purpose without unnecessary elaboration. Every word serves a purpose: 'Get documents' (action), 'from a container' (source), 'with optional filters' (capability). There's zero waste or redundancy in this minimal description.

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 4 parameters, no annotations, no output schema, and nested objects in parameters, the description is insufficiently complete. It doesn't address what the tool returns (document structure, metadata), how errors are handled, performance characteristics, or relationship to sibling tools. The minimal description leaves too many contextual questions unanswered for effective tool selection and invocation.

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?

Schema description coverage is 100%, so all parameters are documented in the schema. The description adds minimal value beyond the schema by mentioning 'optional filters' which corresponds to partition_key and filter_conditions parameters. However, it doesn't provide additional context about how these filters work together or practical examples of filter usage. Baseline 3 is appropriate when schema does the documentation work.

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 verb 'Get' and resource 'documents from a container', making the purpose understandable. It distinguishes from siblings like mcp_get_document_by_id (single document) and mcp_execute_query (general querying), but doesn't explicitly differentiate from mcp_list_containers or mcp_container_info. The purpose is specific enough for basic understanding.

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. It mentions 'optional filters' but doesn't explain when filtering is appropriate or how this differs from mcp_execute_query for querying documents. There's no mention of prerequisites, performance considerations, or typical use cases for this retrieval method.

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