create_item
Add new items to the system by providing a name, optional description, and metadata for structured data management.
Instructions
Create a new item.
Args: name: The name of the item (required) description: Optional description metadata: Optional key-value metadata
Returns: The created item data including the generated ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| description | No | ||
| metadata | No |
Input Schema (JSON Schema)
{
"properties": {
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null
},
"metadata": {
"anyOf": [
{
"additionalProperties": {
"type": "string"
},
"type": "object"
},
{
"type": "null"
}
],
"default": null
},
"name": {
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}
Implementation Reference
- src/skeleton_mcp/api/example.py:104-140 (handler)The handler function that implements the create_item tool logic. It generates a unique ID, timestamps the item, stores it in mock data, and returns the created item.async def create_item( name: str, description: str | None = None, metadata: dict[str, str] | None = None, ) -> dict[str, Any]: """ Create a new item. Args: name: The name of the item (required) description: Optional description metadata: Optional key-value metadata Returns: The created item data including the generated ID """ # In a real implementation: # client = get_client() # return client.post("items", data={"name": name, "description": description, "metadata": metadata}) import uuid from datetime import datetime, timezone item_id = f"item-{uuid.uuid4().hex[:8]}" now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") item = { "id": item_id, "name": name, "description": description, "metadata": metadata, "created_at": now, "updated_at": now, } MOCK_ITEMS[item_id] = item return item
- src/skeleton_mcp/server.py:89-93 (registration)Registration of API tools including create_item using the mcp.tool() decorator from the example module.mcp.tool()(example.list_items) mcp.tool()(example.get_item) mcp.tool()(example.create_item) mcp.tool()(example.update_item) mcp.tool()(example.delete_item)