update_item
Modify existing items in the Skeleton MCP Server by updating names, descriptions, or metadata using item identifiers.
Instructions
Update an existing item.
Args: item_id: The unique identifier of the item to update name: New name (optional) description: New description (optional) metadata: New metadata (optional, replaces existing)
Returns: The updated item data
Raises: ValueError: If the item is not found
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item_id | Yes | ||
| name | No | ||
| description | No | ||
| metadata | No |
Implementation Reference
- src/skeleton_mcp/api/example.py:143-185 (handler)The main handler function for the 'update_item' tool. It updates an existing item in the mock data store by copying the item, applying optional updates to name, description, and metadata, updating the timestamp, and returning the updated item.async def update_item( item_id: str, name: str | None = None, description: str | None = None, metadata: dict[str, str] | None = None, ) -> dict[str, Any]: """ Update an existing item. Args: item_id: The unique identifier of the item to update name: New name (optional) description: New description (optional) metadata: New metadata (optional, replaces existing) Returns: The updated item data Raises: ValueError: If the item is not found """ # In a real implementation: # client = get_client() # return client.put(f"items/{item_id}", data={"name": name, "description": description, "metadata": metadata}) if item_id not in MOCK_ITEMS: raise ValueError(f"Item not found: {item_id}") from datetime import datetime, timezone item = MOCK_ITEMS[item_id].copy() if name is not None: item["name"] = name if description is not None: item["description"] = description if metadata is not None: item["metadata"] = metadata item["updated_at"] = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") MOCK_ITEMS[item_id] = item return item
- src/skeleton_mcp/server.py:92-92 (registration)Registers the update_item handler as an MCP tool using the mcp.tool() decorator.mcp.tool()(example.update_item)