b24_disk_file_get
Retrieve file information including download URL from Bitrix24 Disk using the file ID.
Instructions
Obtiene información de un archivo incluyendo URL de descarga.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_id | Yes | ID del archivo | |
| webhook_url | No |
Implementation Reference
- src/tools/disk.js:55-58 (handler)Handler function for b24_disk_file_get. Calls Bitrix24 API 'disk.file.get' with the given file_id and returns file info including download URL.
export async function diskFileGet({ file_id, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const res = await client.call('disk.file.get', { id: file_id }); return { portal: client.portal, file: res.result }; - src/tools/disk.js:50-53 (schema)Zod schema for b24_disk_file_get: requires file_id (string or number), optional webhook_url.
export const diskFileGetSchema = z.object({ file_id: z.union([z.string(), z.number()]).describe('ID del archivo'), webhook_url: z.string().url().optional(), }); - index.js:213-215 (registration)Tool registration on the MCP server: name 'b24_disk_file_get', description, schema, and handler via wrap(diskFileGet).
server.tool('b24_disk_file_get', 'Obtiene información de un archivo incluyendo URL de descarga.', diskFileGetSchema.shape, wrap(diskFileGet)); - src/utils/resolve-webhook.js:1-10 (helper)Helper function that resolves the webhook URL from parameter or environment variable B24_DEFAULT_WEBHOOK.
export function resolveWebhook(webhookParam) { const url = webhookParam || process.env.B24_DEFAULT_WEBHOOK; if (!url) { throw new Error( 'No se especificó webhook_url y no hay B24_DEFAULT_WEBHOOK configurado. ' + 'Indicá el webhook en el parámetro webhook_url o configuralo en el servidor MCP.' ); } return url; } - src/bitrix24/client.js:6-40 (helper)Bitrix24Client class used by the handler to make API calls with retry and rate limiting.
export class Bitrix24Client { constructor(webhookUrl) { this.webhookUrl = webhookUrl.endsWith('/') ? webhookUrl : webhookUrl + '/'; this.limiter = new RateLimiter(500); this.portal = this._extractPortal(webhookUrl); } _extractPortal(url) { try { return new URL(url).hostname; } catch { return 'unknown'; } } async call(method, params = {}, retries = 0) { return this.limiter.schedule(async () => { try { const url = `${this.webhookUrl}${method}.json`; const response = await axios.post(url, params, { timeout: 30000 }); if (response.data.error) { throw new Error(`Bitrix24 error [${response.data.error}]: ${response.data.error_description}`); } return response.data; } catch (err) { if (err.response?.status === 429 && retries < MAX_RETRIES) { const retryAfter = parseInt(err.response.headers['retry-after'] || '2', 10); await new Promise(r => setTimeout(r, retryAfter * 1000)); return this.call(method, params, retries + 1); } if (err.code === 'ECONNABORTED' && retries < MAX_RETRIES) { const backoff = Math.pow(2, retries) * 1000; await new Promise(r => setTimeout(r, backoff)); return this.call(method, params, retries + 1); }