Skip to main content
Glama
Catter58

mcpBPMSoft

by Catter58

Пакетное обновление

bpm_batch_update
Idempotent

Updates multiple records in a single OData v4 batch request, automatically resolving lookup fields and supporting continue_on_error for non-blocking error handling.

Instructions

Обновляет несколько записей в одном $batch (только OData v4). Lookup-поля резолвятся автоматически. Поддерживает continue_on_error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionYes
updatesYesМассив обновлений [{id, data}]
continue_on_errorNoНе прерывать batch на первой ошибке

Implementation Reference

  • The handler function for bpm_batch_update. Receives params with {collection, updates: [{id, data}], continue_on_error?}, resolves lookups for each update, builds PATCH batch requests, executes via OData $batch, and returns a summary with success/failure counts.
      async (params): Promise<CallToolResult> => {
        if (!services.initialized) return notInitialized();
        try {
          await services.authManager.ensureAuthenticated();
    
          if (params.updates.length === 0) {
            return { content: [{ type: 'text', text: 'Массив обновлений пуст.' }], isError: true };
          }
    
          const batchRequests: Array<{ method: 'PATCH'; url: string; body: Record<string, unknown> }> = [];
          for (let i = 0; i < params.updates.length; i++) {
            const update = params.updates[i];
            try {
              const resolvedData = await services.lookupResolver.resolveDataLookups(params.collection, update.data);
              batchRequests.push({
                method: 'PATCH',
                url: services.odataClient.buildRecordPath(params.collection, update.id),
                body: resolvedData,
              });
            } catch (error) {
              return {
                content: [
                  {
                    type: 'text',
                    text: `Ошибка резолвинга lookup в обновлении #${i + 1} (ID: ${update.id}): ${error instanceof Error ? error.message : String(error)}`,
                  },
                ],
                isError: true,
              };
            }
          }
    
          const result = await services.odataClient.executeBatch(batchRequests, params.continue_on_error ?? false);
    
          const succeeded = result.responses
            .map((r, i) => ({ index: i, ...r }))
            .filter((r) => r.status >= 200 && r.status < 300);
          const failed = result.responses
            .map((r, i) => ({ index: i, ...r }))
            .filter((r) => r.status >= 300);
    
          const lines = [
            `Пакетное обновление в ${params.collection}:`,
            `  Всего запросов: ${params.updates.length}`,
            `  Успешно обновлено: ${succeeded.length}`,
            `  Ошибок: ${failed.length}`,
          ];
          if (failed.length > 0) {
            lines.push('', 'Ошибки:');
            failed.forEach((f) =>
              lines.push(`  #${f.index + 1} (id=${params.updates[f.index]?.id}): HTTP ${f.status} — ${JSON.stringify(f.body).slice(0, 300)}`)
            );
          }
    
          return {
            content: [{ type: 'text', text: lines.join('\n') }],
            isError: failed.length > 0 && succeeded.length === 0,
            structuredContent: {
              collection: params.collection,
              total: params.updates.length,
              succeeded: succeeded.length,
              failed: failed.length,
              first_failed_index: failed.length > 0 ? failed[0].index : null,
            },
          };
        } catch (error) {
          const toolError = formatToolError(error, params.collection);
          return { content: [{ type: 'text', text: JSON.stringify(toolError, null, 2) }], isError: true };
        }
      }
    );
  • Input schema for bpm_batch_update: collection (string), updates (array of {id: string, data: Record<string, unknown>}), and optional continue_on_error (boolean).
    inputSchema: {
      collection: z.string(),
      updates: z
        .array(
          z.object({
            id: z.string(),
            data: z.record(z.string(), z.unknown()),
          })
        )
        .describe('Массив обновлений [{id, data}]'),
      continue_on_error: z.boolean().optional().describe('Не прерывать batch на первой ошибке'),
    },
  • Registration of bpm_batch_update tool via server.registerTool() within the registerBatchTools function, pulling metadata from the tool registry.
    // bpm_batch_update
    {
      const meta = getTool('bpm_batch_update');
      server.registerTool(
        meta.name,
        {
          title: meta.title,
          description: meta.description,
          inputSchema: {
            collection: z.string(),
            updates: z
              .array(
                z.object({
                  id: z.string(),
                  data: z.record(z.string(), z.unknown()),
                })
              )
              .describe('Массив обновлений [{id, data}]'),
            continue_on_error: z.boolean().optional().describe('Не прерывать batch на первой ошибке'),
          },
          annotations: meta.annotations,
        },
        async (params): Promise<CallToolResult> => {
          if (!services.initialized) return notInitialized();
          try {
            await services.authManager.ensureAuthenticated();
    
            if (params.updates.length === 0) {
              return { content: [{ type: 'text', text: 'Массив обновлений пуст.' }], isError: true };
            }
    
            const batchRequests: Array<{ method: 'PATCH'; url: string; body: Record<string, unknown> }> = [];
            for (let i = 0; i < params.updates.length; i++) {
              const update = params.updates[i];
              try {
                const resolvedData = await services.lookupResolver.resolveDataLookups(params.collection, update.data);
                batchRequests.push({
                  method: 'PATCH',
                  url: services.odataClient.buildRecordPath(params.collection, update.id),
                  body: resolvedData,
                });
              } catch (error) {
                return {
                  content: [
                    {
                      type: 'text',
                      text: `Ошибка резолвинга lookup в обновлении #${i + 1} (ID: ${update.id}): ${error instanceof Error ? error.message : String(error)}`,
                    },
                  ],
                  isError: true,
                };
              }
            }
    
            const result = await services.odataClient.executeBatch(batchRequests, params.continue_on_error ?? false);
    
            const succeeded = result.responses
              .map((r, i) => ({ index: i, ...r }))
              .filter((r) => r.status >= 200 && r.status < 300);
            const failed = result.responses
              .map((r, i) => ({ index: i, ...r }))
              .filter((r) => r.status >= 300);
    
            const lines = [
              `Пакетное обновление в ${params.collection}:`,
              `  Всего запросов: ${params.updates.length}`,
              `  Успешно обновлено: ${succeeded.length}`,
              `  Ошибок: ${failed.length}`,
            ];
            if (failed.length > 0) {
              lines.push('', 'Ошибки:');
              failed.forEach((f) =>
                lines.push(`  #${f.index + 1} (id=${params.updates[f.index]?.id}): HTTP ${f.status} — ${JSON.stringify(f.body).slice(0, 300)}`)
              );
            }
    
            return {
              content: [{ type: 'text', text: lines.join('\n') }],
              isError: failed.length > 0 && succeeded.length === 0,
              structuredContent: {
                collection: params.collection,
                total: params.updates.length,
                succeeded: succeeded.length,
                failed: failed.length,
                first_failed_index: failed.length > 0 ? failed[0].index : null,
              },
            };
          } catch (error) {
            const toolError = formatToolError(error, params.collection);
            return { content: [{ type: 'text', text: JSON.stringify(toolError, null, 2) }], isError: true };
          }
        }
      );
  • Metadata definition in the TOOLS registry: name 'bpm_batch_update', title 'Пакетное обновление', description, annotations (idempotentHint: true), blurb, and category 'batch'.
    {
      name: 'bpm_batch_update',
      title: 'Пакетное обновление',
      description:
        'Обновляет несколько записей в одном $batch (только OData v4). Lookup-поля резолвятся автоматически. Поддерживает continue_on_error.',
      annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
      blurb: 'пакетное обновление (OData v4)',
      category: 'batch',
    },
  • The getTool() function used at registration time to look up the ToolDescriptor for 'bpm_batch_update' from the TOOLS array.
    export function getTool(name: string): ToolDescriptor {
      const t = TOOLS.find((x) => x.name === name);
      if (!t) throw new Error(`Tool not registered in registry: ${name}`);
      return t;
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate non-destructive, non-read-only, idempotent, and open-world behavior. The description adds 'only OData v4', automatic lookup resolution, and continue_on_error support, providing useful context beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is three concise sentences with no extraneous information. It front-loads the main purpose and includes key features efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers batch operation, OData v4 restriction, automatic lookup resolution, and continue_on_error. It does not address error handling details or return format, but given the presence of continue_on_error and no output schema, it is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 67% with descriptions for updates and continue_on_error. The description additionally explains that lookup fields are resolved automatically, adding meaning to the data parameter. However, the collection parameter remains undescribed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it updates multiple records in one batch using OData v4, with automatic lookup resolution and continue_on_error support. This distinguishes it from sibling tools like bpm_update_record (single update) and bpm_batch_create/bpm_batch_delete.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for batch updates but does not explicitly state when to use versus alternatives like bpm_update_record or other batch tools. It only mentions OData v4 constraint, lacking when-not or alternative guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Catter58/mcpBPMSoft'

If you have feedback or need assistance with the MCP directory API, please join our Discord server