box_docgen_create_batch_tool
Generate multiple documents from a Box Doc Gen template using specific data, saving them to a designated folder. Supports PDF or DOCX output formats.
Instructions
Create a new Box Doc Gen batch to generate documents from a template.
Args: client (BoxClient): Authenticated Box client. docgen_template_id (str): ID of the Doc Gen template. destination_folder_id (str): ID of the folder to save the generated document. document_generation_data (List[Dict[str, Any]]): Data for document generation. example: [ { "generated_file_name": "Image test", "user_input": { "order": { "id": "12305", "date": "18-08-2023", "products": [ { "id": 1, "name": "A4 Papers", "type": "non-fragile", "quantity": 100, "price": 29, "amount": 2900 }, ] } } }, ] output_type (str): Output file type (only, "pdf" or "docx").
Returns: dict[str, Any]: Response containing batch creation status and details. If successful, contains a message with batch ID. If an error occurs, contains an "error" key with the error message.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| destination_folder_id | Yes | ||
| docgen_template_id | Yes | ||
| document_generation_data | Yes | ||
| output_type | No |
Implementation Reference
- src/tools/box_tools_docgen.py:168-220 (handler)The core handler function implementing the box_docgen_create_batch_tool. It takes template ID, folder ID, data list, and output type, gets a Box client, and calls the underlying box_docgen_create_batch function.async def box_docgen_create_batch_tool( ctx: Context, docgen_template_id: str, destination_folder_id: str, document_generation_data: list[dict[str, Any]], output_type: str = "pdf", ) -> dict[str, Any]: """ Create a new Box Doc Gen batch to generate documents from a template. Args: client (BoxClient): Authenticated Box client. docgen_template_id (str): ID of the Doc Gen template. destination_folder_id (str): ID of the folder to save the generated document. document_generation_data (List[Dict[str, Any]]): Data for document generation. example: [ { "generated_file_name": "Image test", "user_input": { "order": { "id": "12305", "date": "18-08-2023", "products": [ { "id": 1, "name": "A4 Papers", "type": "non-fragile", "quantity": 100, "price": 29, "amount": 2900 }, ] } } }, ] output_type (str): Output file type (only, "pdf" or "docx"). Returns: dict[str, Any]: Response containing batch creation status and details. If successful, contains a message with batch ID. If an error occurs, contains an "error" key with the error message. """ box_client = get_box_client(ctx) return box_docgen_create_batch( box_client, docgen_template_id=docgen_template_id, destination_folder_id=destination_folder_id, document_generation_data=document_generation_data, output_type=output_type, )
- src/tool_registry/doc_gen_tools.py:19-32 (registration)The registration function that registers box_docgen_create_batch_tool (and other docgen tools) with the MCP server using mcp.tool().def register_doc_gen_tools(mcp: FastMCP): mcp.tool()(box_docgen_create_batch_tool) mcp.tool()(box_docgen_get_job_by_id_tool) mcp.tool()(box_docgen_list_jobs_tool) mcp.tool()(box_docgen_list_jobs_by_batch_tool) mcp.tool()(box_docgen_template_create_tool) mcp.tool()(box_docgen_template_list_tool) # mcp.tool()(box_docgen_template_delete_tool) # very dangerous tool, use with caution mcp.tool()(box_docgen_template_get_by_id_tool) mcp.tool()(box_docgen_template_list_tags_tool) mcp.tool()(box_docgen_template_list_jobs_tool) mcp.tool()(box_docgen_template_get_by_name_tool) mcp.tool()(box_docgen_create_single_file_from_user_input_tool)
- src/tool_registry/doc_gen_tools.py:3-16 (registration)Import statement importing the box_docgen_create_batch_tool handler from src/tools/box_tools_docgen.py for registration.from tools.box_tools_docgen import ( box_docgen_create_batch_tool, box_docgen_create_single_file_from_user_input_tool, box_docgen_get_job_by_id_tool, box_docgen_list_jobs_by_batch_tool, box_docgen_list_jobs_tool, box_docgen_template_create_tool, box_docgen_template_get_by_id_tool, box_docgen_template_get_by_name_tool, box_docgen_template_list_jobs_tool, # box_docgen_template_delete_tool, # very dangerous tool, use with caution box_docgen_template_list_tags_tool, box_docgen_template_list_tool, )