cosmosdb_item_create
Add a new item to a Cosmos DB container using JSON data. Specify the container name and item details for efficient document storage and retrieval. Simplifies database management on Azure MCP Server.
Instructions
Create a new item in 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 | Yes | Item data to create (JSON object) |
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": {
"description": "Item data to create (JSON object)",
"type": "object"
}
},
"required": [
"container_name",
"item"
],
"type": "object"
}
Implementation Reference
- mcp_server_azure/azure_server.py:267-273 (handler)Implements the core logic for creating a new item in a Cosmos DB container by calling create_item on the container client with the provided item data.name == "cosmosdb_item_create" ): # Renamed from put to create, and table to container container_client = database.get_container_client( arguments["container_name"] ) item = container_client.create_item(body=arguments["item"]) response = {"item_id": item["id"], "created": True}
- Defines the Tool object for cosmosdb_item_create, including name, description, and inputSchema specifying container_name, optional database_name, and required item object.Tool( name="cosmosdb_item_create", # Renamed from put to create, and table to container description="Create a new item in 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": { "type": "object", "description": "Item data to create (JSON object)", }, }, "required": ["container_name", "item"], }, ),
- mcp_server_azure/azure_server.py:171-176 (registration)Registers the cosmosdb_item_create tool (among others) by including it in the list returned from get_azure_tools() in the MCP list_tools handler.@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