b24_disk_folder_list
Retrieve the contents of a folder in Bitrix24 Disk, supporting optional filters. If no folder ID is provided, lists the user's root storage.
Instructions
Lista el contenido de una carpeta en el Disk de Bitrix24.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder_id | No | ID de la carpeta. Si no se indica, lista el storage raíz del usuario | |
| filter | No | Filtros opcionales. Ejemplo: { "NAME": "Contratos" } | |
| webhook_url | No |
Implementation Reference
- src/tools/disk.js:25-46 (handler)Handler function for b24_disk_folder_list. Calls Bitrix24 API 'disk.folder.getchildren' to list folder contents. If no folder_id provided, gets the user's personal storage root via 'disk.storage.getforapp'.
export async function diskFolderList({ folder_id, filter = {}, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); if (!folder_id) { // Get user's personal storage root const storageRes = await client.call('disk.storage.getforapp'); folder_id = storageRes.result?.ROOT_OBJECT?.ID; } const res = await client.call('disk.folder.getchildren', { id: folder_id, filter }); const items = res.result ?? []; return { portal: client.portal, folder_id, total: items.length, items: items.map(i => ({ id: i.ID, name: i.NAME, type: i.TYPE, size: i.SIZE, created: i.CREATE_TIME, modified: i.UPDATE_TIME, download_url: i.DOWNLOAD_URL, })), }; } - src/tools/disk.js:19-23 (schema)Zod schema for b24_disk_folder_list inputs: folder_id (optional string/number), filter (optional record), and webhook_url (optional URL).
export const diskFolderListSchema = z.object({ folder_id: z.union([z.string(), z.number()]).optional().describe('ID de la carpeta. Si no se indica, lista el storage raíz del usuario'), filter: z.record(z.any()).optional().default({}).describe('Filtros opcionales. Ejemplo: { "NAME": "Contratos" }'), webhook_url: z.string().url().optional(), }); - index.js:209-211 (registration)Registration of the 'b24_disk_folder_list' tool on the MCP server with its schema description and handler.
server.tool('b24_disk_folder_list', 'Lista el contenido de una carpeta en el Disk de Bitrix24.', diskFolderListSchema.shape, wrap(diskFolderList)); - index.js:44-49 (registration)Import of diskFolderListSchema and diskFolderList from src/tools/disk.js into the main server file.
import { diskStoragesSchema, diskStorages, diskFolderListSchema, diskFolderList, diskFileGetSchema, diskFileGet, diskFileUploadSchema, diskFileUpload, } from './src/tools/disk.js'; - index.js:78-90 (helper)Wrap function that wraps handlers with error handling and JSON serialization for MCP responses.
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 }; } }; }