box_metadata_set_instance_on_file_tool
Assign metadata to a file using a specified template. Requires a template key, file ID, and metadata values. Updates file attributes for enhanced organization and retrieval.
Instructions
Set a metadata instance on a file.
Args: ctx (Context): The context object containing the request and lifespan context. template_key (str): The key of the metadata template. file_id (str): The ID of the file to set the metadata on. metadata (dict): The metadata to set. Example: {'test_field': 'Test Value', 'date_field': '2023-10-01T00:00:00.000Z', 'float_field': 3.14, 'enum_field': 'option1', 'multiselect_field': ['option1', 'option2']}
Returns: dict: The response from the Box API after setting the metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_id | Yes | ||
| metadata | Yes | ||
| template_key | Yes |
Implementation Reference
- src/tools/box_tools_metadata.py:129-152 (handler)The main asynchronous handler function implementing the tool logic. It extracts the Box client from the MCP context and delegates to the box_ai_agents_toolkit's box_metadata_set_instance_on_file function to set metadata on a specified file.async def box_metadata_set_instance_on_file_tool( ctx: Context, template_key: str, file_id: str, metadata: dict, ) -> dict: """ Set a metadata template instance on a specific file. Args: client (BoxClient): An authenticated Box client. template_key (str): The key of the metadata template to set. file_id (str): The ID of the file to set the metadata on. metadata (Dict[str, Any]): The metadata instance to set, as a dictionary. Metadata example: {'test_field': 'Test Value', 'date_field': '2023-10-01T00:00:00.000Z', 'float_field': 3.14, 'enum_field': 'option1', 'multiselect_field': ['option1', 'option2']} Returns: dict: The response from the Box API after setting the metadata. """ box_client = get_box_client(ctx) return box_metadata_set_instance_on_file( box_client, template_key, file_id, metadata )
- src/tool_registry/metadata_tools.py:15-23 (registration)The registration function that decorates and registers the box_metadata_set_instance_on_file_tool (and other metadata tools) with the FastMCP server instance.def register_metadata_tools(mcp: FastMCP): mcp.tool()(box_metadata_template_create_tool) mcp.tool()(box_metadata_template_list_tool) mcp.tool()(box_metadata_template_get_by_key_tool) mcp.tool()(box_metadata_template_get_by_name_tool) mcp.tool()(box_metadata_set_instance_on_file_tool) mcp.tool()(box_metadata_get_instance_on_file_tool) mcp.tool()(box_metadata_update_instance_on_file_tool) mcp.tool()(box_metadata_delete_instance_on_file_tool)