b24_disk_file_upload
Upload files to a Bitrix24 Disk folder by providing the folder ID, file name, and base64-encoded content.
Instructions
Sube un archivo a una carpeta del Disk de Bitrix24.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder_id | Yes | ID de la carpeta destino | |
| name | Yes | Nombre del archivo incluyendo extensión | |
| content_base64 | Yes | Contenido del archivo en Base64 | |
| webhook_url | No |
Implementation Reference
- src/tools/disk.js:70-78 (handler)Handler function that executes the 'b24_disk_file_upload' tool logic. Creates a Bitrix24Client, calls the 'disk.folder.uploadfile' API method with folder_id, name, and base64 file content, and returns the result.
export async function diskFileUpload({ folder_id, name, content_base64, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const res = await client.call('disk.folder.uploadfile', { id: folder_id, data: { NAME: name }, fileContent: content_base64, }); return { portal: client.portal, file: res.result, success: true }; } - src/tools/disk.js:63-68 (schema)Zod schema defining input parameters for b24_disk_file_upload: folder_id (string|number), name (string), content_base64 (string), and optional webhook_url.
export const diskFileUploadSchema = z.object({ folder_id: z.union([z.string(), z.number()]).describe('ID de la carpeta destino'), name: z.string().describe('Nombre del archivo incluyendo extensión'), content_base64: z.string().describe('Contenido del archivo en Base64'), webhook_url: z.string().url().optional(), }); - index.js:217-219 (registration)Registers the 'b24_disk_file_upload' tool on the MCP server with a description, schema validation, and wrapped handler.
server.tool('b24_disk_file_upload', 'Sube un archivo a una carpeta del Disk de Bitrix24.', diskFileUploadSchema.shape, wrap(diskFileUpload)); - index.js:44-49 (registration)Import statement that brings diskFileUploadSchema and diskFileUpload from src/tools/disk.js into the main index.js registration file.
import { diskStoragesSchema, diskStorages, diskFolderListSchema, diskFolderList, diskFileGetSchema, diskFileGet, diskFileUploadSchema, diskFileUpload, } from './src/tools/disk.js'; - index.js:78-90 (helper)The wrap() helper function used to wrap the diskFileUpload handler, providing error handling and JSON response formatting.
function wrap(fn) { return async (params) => { try { const result = await fn(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (err) { const msg = err.response?.data ? `${err.message}\nBitrix24: ${JSON.stringify(err.response.data)}` : err.message; return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true }; } }; }