add_extra_fields_to_item
Extend RSpace inventory items with custom metadata fields for experiments or projects, supporting text and number data types to organize research data.
Instructions
Adds custom metadata fields to inventory items
Usage: Extend items with experiment-specific or project-specific data Field format: [{"name": "Field Name", "type": "text|number", "content": "value"}] Types: 'text' for strings, 'number' for numeric values
Returns: Updated item with new custom fields
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| field_data | Yes | ||
| item_id | Yes |
Implementation Reference
- main.py:1131-1149 (handler)This is the main handler function for the 'add_extra_fields_to_item' tool, decorated with @mcp.tool for automatic registration. It processes a list of field data dictionaries, converts them to RSpace ExtraField objects, and calls the inventory client's add_extra_fields method to attach custom metadata fields to the specified inventory item.@mcp.tool(tags={"rspace", "inventory", "utility"}) def add_extra_fields_to_item(item_id: Union[int, str], field_data: List[dict]) -> dict: """ Adds custom metadata fields to inventory items Usage: Extend items with experiment-specific or project-specific data Field format: [{"name": "Field Name", "type": "text|number", "content": "value"}] Types: 'text' for strings, 'number' for numeric values Returns: Updated item with new custom fields """ extra_fields = [] for field in field_data: field_type = i.ExtraFieldType.TEXT if field.get('type', 'text').lower() == 'text' else i.ExtraFieldType.NUMBER ef = i.ExtraField(field['name'], field_type, field.get('content', '')) extra_fields.append(ef) return inv_cli.add_extra_fields(item_id, *extra_fields)