download_template
Download the original source file of a Carbone template, like DOCX or HTML, using a template ID or version ID to inspect, edit, or back it up.
Instructions
Download the original source file of a stored Carbone template (e.g. the DOCX, XLSX, PPTX, or HTML file that was uploaded). Use this to inspect, edit, or back up a template. Pass a Template ID to download the currently deployed version, or a Version ID to download a specific version.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| templateId | Yes | Template ID (64-bit) or Version ID (SHA-256) to download. Template ID — downloads the currently deployed version of the template. Version ID — downloads that exact version regardless of deployment status. Both formats are returned by upload_template and list_templates. |
Implementation Reference
- src/tools/templates.ts:418-434 (handler)Handler function that calls the CarboneClient to download a template and returns the file content as tool content.
export async function handleDownloadTemplate( args: { templateId: string }, client: CarboneClient, options?: CallOptions ) { try { const result = await client.downloadTemplate(args.templateId, options); const ext = result.filename.split('.').pop() ?? 'bin'; const content = toToolContent(result.buffer, result.filename, ext); return { content: [content] }; } catch (error) { return { isError: true, content: [{ type: 'text' as const, text: formatError(error) }], }; } } - src/tools/templates.ts:406-416 (schema)Input schema defining the templateId parameter (accepts Template ID or Version ID) for the download_template tool.
export const downloadTemplateSchema = { templateId: z .string() .min(1) .describe( 'Template ID (64-bit) or Version ID (SHA-256) to download. ' + 'Template ID — downloads the currently deployed version of the template. ' + 'Version ID — downloads that exact version regardless of deployment status. ' + 'Both formats are returned by upload_template and list_templates.' ), }; - src/validation/schemas.ts:100-102 (schema)Validation schema for download_template using Zod, requiring a non-empty templateId string.
export const DownloadTemplateSchema = z.object({ templateId: z.string().min(1, 'Template ID required'), }); - src/tools/index.ts:105-109 (registration)Registration of the download_template tool with the MCP server, wiring up name, description, schema, and handler.
server.registerTool( downloadTemplateToolName, { description: downloadTemplateDescription, inputSchema: downloadTemplateSchema }, (args, extra) => handleDownloadTemplate(args, client, { apiKey: extra.authInfo?.token }) ); - src/carbone/client.ts:235-243 (helper)CarboneClient method that performs the actual HTTP GET request to /template/{id} and returns the binary file buffer and filename.
async downloadTemplate( templateId: string, options?: CallOptions ): Promise<{ buffer: Buffer; filename: string }> { const response = await this.request(`/template/${templateId}`, { method: 'GET', }, options); return this.handleBinaryResponse(response); }