cosmosdb_item_read
Retrieve a specific item from a Cosmos DB container using its ID and partition key. The tool ensures accurate data retrieval from a specified database and container.
Instructions
Read an item from a Cosmos DB container
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| container_name | Yes | Name of the Cosmos DB container | |
| database_name | No | Name of the Cosmos DB database (optional, defaults to 'defaultdb') | |
| item_id | Yes | ID of the item to read | |
| partition_key | Yes | Partition key value for the item |
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"
},
"item_id": {
"description": "ID of the item to read",
"type": "string"
},
"partition_key": {
"description": "Partition key value for the item",
"type": "string"
}
},
"required": [
"container_name",
"item_id",
"partition_key"
],
"type": "object"
}
Implementation Reference
- mcp_server_azure/azure_server.py:275-283 (handler)Handler logic within handle_cosmosdb_operations that performs the actual item read using Cosmos DB container_client.read_item with item_id and partition_key.name == "cosmosdb_item_read" ): # Renamed from get to read, and table to container container_client = database.get_container_client( arguments["container_name"] ) item = container_client.read_item( item=arguments["item_id"], partition_key=arguments["partition_key"] ) response = item
- Tool schema definition including inputSchema for parameters: container_name (required), database_name (optional), item_id (required), partition_key (required).Tool( name="cosmosdb_item_read", # Renamed from get to read, and table to container description="Read an item from a Cosmos DB container", # 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')", }, "item_id": { "type": "string", "description": "ID of the item to read", }, "partition_key": { "type": "string", "description": "Partition key value for the item", }, }, "required": ["container_name", "item_id", "partition_key"], }, ),
- mcp_server_azure/azure_server.py:172-176 (registration)Registers the tools by returning get_azure_tools() in response to list_tools MCP call, which includes the cosmosdb_item_read tool.async def list_tools() -> list[Tool]: """List available Azure tools""" logger.debug("Handling list_tools request") return get_azure_tools() # Use get_azure_tools
- mcp_server_azure/azure_server.py:436-439 (registration)Dispatches cosmosdb_* tool calls, including cosmosdb_item_read, to the handle_cosmosdb_operations function.elif name.startswith("cosmosdb_"): # Updated prefix to cosmosdb_ return await handle_cosmosdb_operations( azure_rm, name, arguments ) # Use cosmosdb handler