Skip to main content
Glama
robinong79

Azure Cosmos DB MCP Server

by robinong79

query_container

Executes SQL-like queries on an Azure Cosmos DB container to retrieve, filter, or manipulate data, enabling efficient interaction with database systems through structured inputs.

Instructions

Queries a Azure Cosmos DB container using SQL-like syntax

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerNameYesName of the container
parametersNoQuery parameters
queryYesSQL query string

Implementation Reference

  • The handler function that performs the actual query on the Cosmos DB container using the provided SQL query and parameters.
    async function queryContainer(params: any) {
      try {
        const { query, parameters } = params;
        const { resources } = await container.items.query({ query, parameters }).fetchAll();
    
        return {
          success: true,
          message: `Query executed successfully`,
          items: resources,
        };
      } catch (error) {
        console.error("Error querying container:", error);
        return {
          success: false,
          message: `Failed to query container: ${error}`,
        };
      }
    }
  • The Tool object defining the input schema and metadata for the query_container tool.
    const QUERY_CONTAINER_TOOL: Tool = {
      name: "query_container",
      description: "Queries a Azure Cosmos DB container using SQL-like syntax",
      inputSchema: {
        type: "object",
        properties: {
          containerName: { type: "string", description: "Name of the container" },
          query: { type: "string", description: "SQL query string" },
          parameters: { type: "array", description: "Query parameters" },
        },
        required: ["containerName", "query"],
      },
    };
  • src/index.ts:177-179 (registration)
    Registration of the query_container tool (QUERY_CONTAINER_TOOL) in the list of tools provided by ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [PUT_ITEM_TOOL, GET_ITEM_TOOL, QUERY_CONTAINER_TOOL, UPDATE_ITEM_TOOL],
    }));
  • src/index.ts:193-195 (registration)
    The switch case in CallToolRequestHandler that routes calls to the query_container tool to its handler function.
    case "query_container":
      result = await queryContainer(args);
      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 the tool queries a container but doesn't describe what happens on execution—such as whether it's read-only, if it affects data, potential rate limits, error conditions, or the format of results. For a query tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence contributes essential information, earning its place.

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?

Given the complexity of querying a database, lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., result sets, error formats), behavioral aspects like safety or performance, or how to interpret parameters effectively. For a tool with three parameters and no structured behavioral hints, 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?

Schema description coverage is 100%, so the schema already documents all three parameters (containerName, parameters, query) with basic descriptions. The description adds marginal value by implying the query uses SQL-like syntax, but it doesn't provide additional details like syntax examples, parameter usage, or constraints beyond what the schema offers. Baseline 3 is appropriate when the schema handles most documentation.

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 ('queries') and target resource ('Azure Cosmos DB container'), and specifies the method ('using SQL-like syntax'). It distinguishes from siblings like get_item, put_item, and update_item by focusing on querying rather than direct item operations. However, it doesn't explicitly contrast with siblings beyond the general verb difference.

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 doesn't mention scenarios where query_container is preferred over get_item (e.g., for complex filtering or multiple items), nor does it specify prerequisites like container existence or permissions. Usage is implied by the action but not explicitly defined.

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

Related 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/robinong79/mcp-cosmos'

If you have feedback or need assistance with the MCP directory API, please join our Discord server