Для AI-агентов: markdown этой страницы — /docs/mcp-chains.mdиндекс документации — /llms.txt
MCP: chains
Обновлено
Определения инструментов. Обновляйте tools/list после изменения прав. required_scopes: ALL.
create_chain_step
Add a step with its message to the chain `chain_id`. `content` is required (text and/or `media_refs` from media_finalize); `title` and `delay_minutes` are optional. The first step of a chain becomes its entry point. Returns the step's `step_id`; when `wait_timed_out` is true, find the step with list_chain_steps. Set buttons, timeouts and entry state with update_chain_step; replace an existing step's message with publish_entity (intent REPLACE, replace_target id = the step id). A step is reusable prepared content in two modes: a STANDALONE message (video, file, photo, instruction) the AI agent sends instead of inventing text, attached to a knowledge entry with create_knowledge(prepared_step_ids); and an ENTRY into a funnel (an entry-point step): the AI sends the opening message and the whole funnel starts from it. Do not park standalone steps in a service chain with `is_active: false`: a switched-off step is never sent. `timeout_minutes: 0` with `timeout_next_step_id` sends the next step right after this one, as a reply to it — use it to follow a media card (caption up to 1024) with a long text step; the instant step carries no buttons and no `timeout_condition`.
Scopes (ALL): ["chains:write"]. Risk: "write".
create_message_chain
Create an empty message chain with a title, then add its steps with create_chain_step. Returns the created chain with its assigned `id` and `entry_url`. A step carries at most 3 transition buttons plus 1 goal button. A course is a linear chain or one that branches and merges back (lesson 1 → 2.1 / 2.2 → lesson 3); the course menu and progress live on a course page, and each lesson's goal button is "All materials" pointing to it. The bot keeps no per-user progress.
Scopes (ALL): ["chains:write"]. Risk: "write".
debug_chain_run
Debug one customer's message-chain runs, newest first (up to 10). Each run shows its chain, status, entry step, the current step with the moment it was entered, the step timer (`timeout_minutes`, `timeout_next_step_id`, `conditional`), `timer.due_at` — when the timeout is owed — `timer.fires_at` — the minute tick (its `:00` boundary) that moves the run on — and `timer.reason`: `timer_armed` (fires at a later tick), `fires_on_next_tick` (fires at the very next tick), `timer_overdue` (already due; the next tick moves it), `waiting_offer_delivery` (a conditional timer starts when the offer card reaches the private chat), `timer_skipped_by_purchase`, `step_has_no_timeout`, `timeout_target_missing` (target step absent, deleted or switched off), `run_not_active`. It also lists the last transitions with their actor. A customer with no run in the asked chain gets `no_run`: `no_run`, or `step_not_entry_point` — a step that is not an entry point shows its card without a run, so no timer exists; start the funnel at an entry step or move the customer with move_user_in_chain. `user_id` is the customer's id; `chain_id` / `step_id` narrow the read. 0-cost read.
Scopes (ALL): ["chains:read"]. Risk: "read".
delete_chain_step
Soft-delete a chain step by tenant-local `chain_id` and `step_id`. Repeating a successful deletion is idempotent.
Scopes (ALL): ["chains:write"]. Risk: "destructive".
delete_message_chain
Soft-delete a message chain by `id`. Idempotent (deleting an absent/already-deleted chain returns deleted:true).
Scopes (ALL): ["chains:write"]. Risk: "destructive".
execute_chain_batch_entry
Enter users into the chain identified by a matching prepared scenario. The result splits the users: `entered_user_ids` got a run on the entry step, or kept their live run under `noop`; `content_shown_user_ids` were shown the step's card and no run moved. Call this tool only after final human confirmation of the prepared scenario.
Scopes (ALL): ["chains:write"]. Risk: "write".
get_chain_step
Read one chain step by tenant-local chain_id and step_id. Returns complete configuration (including the step `goal`), content_available, the message `text` and `media` (type, mime, file_name, size_bytes of each file; a published file carries no media ref, so to reuse it upload it again) and the existing opaque deeplink_code/public_url for this exact step. Publish content with publish_entity.
Scopes (ALL): ["chains:read"]. Risk: "read".
list_chain_runs
List recorded message-chain runs for the current tenant. Optionally filter by the customer `user_id`; all returned entity references are tenant-scoped ids.
Scopes (ALL): ["chains:read"]. Risk: "read".
list_chain_steps
List ALL steps of one message chain: `chain_id` is the only parameter, there is no paging, and any other key is ignored and named in `ignored_fields`. Every result carries the tenant-local `id`; pass that number (never a database id) to update or delete a step. Use get_chain_step for one step. Each step exposes its registry deeplink_code/public_url, content_available, and also returns its message `text` (null for media-only), `media` (the message files: type, mime, file_name, size_bytes), `has_message` (false = the step is never delivered) and, for an entry point, `entry_url` — the ready public link that starts the chain at that step; share it as is. 0-cost read.
Scopes (ALL): ["chains:read"]. Risk: "read".
list_message_chains
List the tenant message chains (automated message sequences). Returns each with its `id` (pass it to update/delete and as `chain_id` to the step tools), title, computed `is_active` flag, `entry_url` — the ready public link that starts the chain; share it as is, never build one — and `entry_points` (each active entry step with its own `entry_url`). Manage steps with list_chain_steps / get_chain_step / create_chain_step / update_chain_step / delete_chain_step. 0-cost read.
Scopes (ALL): ["chains:read"]. Risk: "read".
move_user_in_chain
Move ONE customer to a step of a funnel by hand — the road the operator's tap and the CRM use, recorded with you as the actor. With a live run of the step's chain the run moves there (the old step's timer goes with it); with no run, a run starts at that step even if it is not an entry point. The step's card is delivered to the customer and mirrored to the dialog topic. It never restarts a live run: to let the customer go through again, send the entry link. Read the state first with debug_chain_run. `expected_from_step_id` makes the move conditional on the step the run stands on now (if another move won, you get FAILED_PRECONDITION). `idempotency_key` is mandatory: a retry with the same key shows nothing twice. Result `outcome`: `run_started`, `run_moved`, `already_at_step` (the card was shown again; the run and its timer are unchanged).
Scopes (ALL): ["chains:write"]. Risk: "write".
prepare_chain_batch_entry
Prepare entry of up to 50 users into a message chain. You MUST name `on_active`: `noop` preserves a live run, `deliver` sends the selected step without moving it, and `restart` abandons it before a new run. A run starts only on an entry step: a `step_id` that is not an entry step shows that step's card under every `on_active`, starts no run and moves no live run. Show the immutable prepared scenario to a human before executing it.
Scopes (ALL): ["chains:write"]. Risk: "write".
update_chain_step
Patch one chain step by `chain_id` plus `step_id`. Steps own title, buttons and targets, timeout and timeout target, entry-point and active state, delay, message lifetime, prior-message deletion and the goal. `goal` is what the step sells (`order_created` — the order is placed, `order_paid` — it is paid; `null` clears it): a run standing on or past the step is closed as converted when the customer reaches it. TRANSITION buttons — a tap moves the customer's run to another step — are `deeplink_buttons: [{title, target_id}]`, the target is a step id of the same chain, at most 3 per step: a fourth is refused with CHAIN_STEP_TOO_MANY_TRANSITIONS (split the choice into two steps or move one option to the goal button). After a tap only the chosen transition stays on the sent card. `button_target` (kind url / deeplink / web_app) is the ONE goal button of the step, a LINK that opens a page or the bot, never a transition inside a funnel. Timeout targets (`timeout_next_step_id`) are step ids in the same chain. `timeout_minutes: 0` with `timeout_next_step_id` sends the next step right after this one, as a reply to it — use it to follow a media card (caption up to 1024) with a long text step; the instant step carries no buttons and no `timeout_condition`. A step breaking those rules is refused with CHAIN_INSTANT_STEP_INVALID. The chain shell has no stored active state: its graph is computed from steps. The step message (text, caption, files) is not edited here — a request carrying it is refused by name; replace it with publish_entity (intent REPLACE, target_topic message_chains, replace_target {kind: card, id: the step id}).
Scopes (ALL): ["chains:write"]. Risk: "write".
update_message_chain
Update a message chain by its `id` (a partial patch — send only the fields you change). Idempotent. Returns the updated chain. Errors NOT_FOUND if the id does not exist for your tenant.
Scopes (ALL): ["chains:write"]. Risk: "write".