cosmosdb_item_read
Retrieve a specific item from an Azure Cosmos DB container by providing its ID and partition key. Use this tool to access stored data for processing or analysis.
Instructions
Read an item from a Cosmos DB container
Input Schema
TableJSON 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 |
Implementation Reference
- mcp_server_azure/azure_server.py:275-283 (handler)Executes the cosmosdb_item_read tool by getting the container client and calling 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
- Defines the input schema and metadata for the cosmosdb_item_read tool.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:171-176 (registration)Registers all Azure tools, including cosmosdb_item_read, by returning the list from get_azure_tools().@server.list_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