b24_crm_fields
Retrieve all standard and custom CRM fields with types, labels, and configuration for any entity: deal, contact, company, or lead.
Instructions
Lista todos los campos disponibles de una entidad CRM (estándar + personalizados) con sus tipos, etiquetas y configuración.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| entity | No | Tipo de entidad: deal, contact, company, lead | |
| entity_type_id | No | ID de SPA | |
| webhook_url | No |
Implementation Reference
- src/tools/crm.js:129-141 (handler)Handler function that calls the Bitrix24 CRM .fields API method to list all available fields for a given entity (deal, contact, company, lead) or a Smart Process by entity_type_id. Returns each field's code and definition.
export async function crmFields({ entity, entity_type_id, webhook_url }) { const client = new Bitrix24Client(resolveWebhook(webhook_url)); const { base, extra } = resolveMethod(entity, entity_type_id); const res = await client.call(`${base}.fields`, extra); const fields = res.result?.fields ?? res.result ?? {}; const fieldList = Object.entries(fields).map(([code, def]) => ({ code, ...def })); return { entity: entity || `SPA_${entity_type_id}`, portal: client.portal, total_fields: fieldList.length, fields: fieldList, }; } - src/tools/crm.js:123-127 (schema)Zod schema defining the input parameters: entity (optional string), entity_type_id (optional int), and webhook_url (optional URL).
export const crmFieldsSchema = z.object({ entity: z.string().optional().describe('Tipo de entidad: deal, contact, company, lead'), entity_type_id: z.number().int().optional().describe('ID de SPA'), webhook_url: z.string().url().optional(), }); - index.js:129-131 (registration)Registration of the 'b24_crm_fields' tool on the MCP server with its description, schema, and handler.
server.tool('b24_crm_fields', 'Lista todos los campos disponibles de una entidad CRM (estándar + personalizados) con sus tipos, etiquetas y configuración.', crmFieldsSchema.shape, wrap(crmFields)); - src/tools/crm.js:18-23 (helper)Helper function resolveMethod() maps entity names to Bitrix24 REST API method prefixes (e.g., deal -> crm.deal) and handles Smart Processes via crm.item.
function resolveMethod(entity, entityTypeId) { if (entityTypeId) return { base: 'crm.item', extra: { entityTypeId } }; const base = ENTITY_METHOD[entity?.toLowerCase()]; if (!base) throw new Error(`Entidad desconocida: "${entity}". Usá deal, contact, company, lead, quote, invoice, o pasá entityTypeId para SPA.`); return { base, extra: {} }; } - src/tools/crm.js:7-16 (helper)ENTITY_METHOD mapping object that translates entity names to Bitrix24 REST API base method names.
const ENTITY_METHOD = { deal: 'crm.deal', contact: 'crm.contact', company: 'crm.company', lead: 'crm.lead', quote: 'crm.quote', invoice: 'crm.invoice', order: 'sale.order', // SPA / Smart Process usa crm.item con entityTypeId };