Skip to main content
Glama

cosmosdb_item_query

Query items in a Cosmos DB container using SQL syntax. Specify the container, database, and optional parameters to retrieve targeted data efficiently.

Instructions

Query items in a Cosmos DB container using SQL

Input Schema

NameRequiredDescriptionDefault
container_nameYesName of the Cosmos DB container
database_nameNoName of the Cosmos DB database (optional, defaults to 'defaultdb')
parametersNoParameters for the SQL query (optional)
queryYesCosmos DB SQL query string

Input Schema (JSON Schema)

{ "properties": { "container_name": { "description": "Name of the Cosmos DB container", "type": "string" }, "database_name": { "description": "Name of the Cosmos DB database (optional, defaults to 'defaultdb')", "type": "string" }, "parameters": { "description": "Parameters for the SQL query (optional)", "items": { "properties": { "name": { "type": "string" }, "value": {} }, "type": "object" }, "type": "array" }, "query": { "description": "Cosmos DB SQL query string", "type": "string" } }, "required": [ "container_name", "query" ], "type": "object" }

Implementation Reference

  • The core handler logic for the 'cosmosdb_item_query' tool. It retrieves the container client and executes a SQL query on Cosmos DB items, returning the results.
    elif ( name == "cosmosdb_item_query" ): # Renamed table to container, simplified query container_client = database.get_container_client( arguments["container_name"] ) items = list( container_client.query_items( query=arguments["query"], parameters=arguments.get("parameters", []), # Optional parameters ) ) response = {"items": items}
  • The Tool schema definition for 'cosmosdb_item_query', including input validation schema with properties for container_name, database_name, query, and parameters.
    Tool( name="cosmosdb_item_query", # Renamed table to container, simplified query description="Query items in a Cosmos DB container using SQL", # Updated description inputSchema={ "type": "object", "properties": { "container_name": { # Renamed from table_name "type": "string", "description": "Name of the Cosmos DB container", # Updated description }, "database_name": { "type": "string", "description": "Name of the Cosmos DB database (optional, defaults to 'defaultdb')", }, "query": { "type": "string", "description": "Cosmos DB SQL query string", }, "parameters": { "type": "array", "description": "Parameters for the SQL query (optional)", "items": { "type": "object", "properties": { "name": {"type": "string"}, "value": {}, # Value can be any type }, }, }, }, "required": ["container_name", "query"], }, ),
  • Tool dispatch registration in call_tool(): routes 'cosmosdb_item_query' (matching cosmosdb_ prefix) to the cosmosdb_operations handler.
    elif name.startswith("cosmosdb_"): # Updated prefix to cosmosdb_ return await handle_cosmosdb_operations( azure_rm, name, arguments ) # Use cosmosdb handler
  • Registers the 'cosmosdb_item_query' tool (indirectly via get_azure_tools()) for listing available tools.
    async def list_tools() -> list[Tool]: """List available Azure tools""" logger.debug("Handling list_tools request") return get_azure_tools() # Use get_azure_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/mashriram/azure_mcp_server'

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