Skip to main content
Glama

run_plan

Executes a multi-step plan of tool calls in one request, handling loops, conditions, and pagination, then returns only the final result.

Instructions

Run a multi-step plan of tool calls in ONE call and get back only the final value. Use it when a job needs several calls, loops or conditions. Find tool names and their output shapes with list_tools first. Only read-only (or allow-listed) tools may run in a plan.

Plan = {"start": "", "steps": {"": , ...}, "input": , "limits": {"max_steps", "max_calls", "timeout_s"} (optional, can only lower)} Step ids: lowercase letters, digits, underscore. Each step result is stored under its id.

Step kinds (each step is exactly one): call {"call": "server.tool", "args": {...}} for_each {"for_each": "", "as": "item", "call": "server.tool", "args": {... "{{item.id}}" ...}, "parallel": 4, "max_items": 100} -> list of results, in the same order as the items Several steps per item: use "do": {"start": "", "steps": {...}} instead of call/args. The sub-plan sees outer results and the loop variable; its step ids are new and local; the item's result is its return (or last value). retry goes on its steps. Nest at most 2. Inside do, next/goto reach only its own steps; ids must not reuse an outer id or the loop variable. parallel and on_error apply per item; sub-steps count toward the limits. {"for_each": "s.ids", "as": "c", "do": {"start": "f", "steps": {"f": {"call": "mail.search", "args": {"q": "{{c}}"}, "next": "g"}, "g": {"call": "mail.get_thread", "args": {"id": "{{f[0].id}}"}}}}} paginate {"paginate": "server.tool", "args": {...}, "cursor_in": "", "cursor_out": "", "collect": "", "max_pages": 10} -> all collected items joined into one list return {"return": ""} ends the plan with this value Optional on call/for_each/paginate: "on_error": "stop" (default) | "skip" (skip: a failed call gives null, a failed for_each item gives {"error": ...}), "retry": 0-5 (default 0) tries a failed call again after 1 s, 2 s, 4 s ... (per item or page). Use retry for tools that fail for a short time; on_error applies when the retries are used up. Do not retry errors that will not change (bad arguments, not found), or tools that write.

Flow: "next": "" or "next": [{"if": "", "goto": "", "wait_s": 0}, ..., {"else": ""}] A branch may point back to an earlier step (a loop); global limits stop runaway plans. No next and no return: the plan ends with the last step's value.

Expressions are JMESPath over {"input": ..., "": result, "": item}. length(s1.items) == 0 s2[?total > 100].name s1.items[0].id Literals: numbers and booleans in backticks (0, true), strings in single quotes ('draft'). In args, "{{expr}}" is replaced by the value (a whole-string template keeps its type).

Example: {"start": "find", "steps": { "find": {"call": "mail.search", "args": {"q": "invoice"}, "next": [{"if": "length(find.messages) == 0", "goto": "none"}, {"else": "read"}]}, "read": {"for_each": "find.messages", "as": "m", "call": "mail.get_thread", "args": {"id": "{{m.thread_id}}"}, "parallel": 4, "retry": 2, "next": "out"}, "out": {"return": "read[].{subject: subject, from: from}"}, "none": {"return": "'no invoices'"}}}

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "plan": "<plan>"
    },
    "name": "run_plan"
  }
}

Input Schema

NameRequiredDescriptionDefault
planYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

With no annotations present, the description carries the full behavioral burden and does so thoroughly: read-only restriction, limit semantics (limits "can only lower" globals, sub-steps count toward limits), retry backoff schedule (1s, 2s, 4s) and when retries are inappropriate, on_error default and skip semantics per call vs per for_each item, nesting capped at 2, and sub-plan variable scoping rules.

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

Conciseness4/5

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

Front-loaded one-sentence purpose, then clearly labeled sections for step kinds, flow, expressions, and examples, so an agent can scan to the part it needs. It is long, and the two examples (a nested `do` snippet plus a full plan) overlap somewhat in what they demonstrate, leaving modest redundancy for a DSL spec.

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

Completeness5/5

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

For a single-parameter DSL tool with high internal complexity, this covers everything needed to author a valid plan; the presence of an output schema and the explicit "get back only the final value" relieve it of documenting return shapes. Edge behavior (no next/return ends with last value, loops bounded by global limits) is also stated.

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

Parameters5/5

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

The input schema is a bare `plan` object with 0% description coverage, so the description must define the payload and it does: the plan envelope keys (start, steps, input, limits), every step kind with its fields, id character rules, next/goto branch form, and JMESPath expression context with backtick/single-quote literal conventions. This is the schema documentation the schema itself lacks.

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?

Opens with a precise verb, resource, and scope: "Run a multi-step plan of tool calls in ONE call and get back only the final value." The contrast with the sibling `call` (one call vs many) and the pointer to `list_tools` for discovering tool names makes the tool's unique role unambiguous.

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

Usage Guidelines4/5

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

States the selection condition explicitly: "Use it when a job needs several calls, loops or conditions," plus the prerequisite to call `list_tools` first and the hard constraint that only read-only/allow-listed tools may run in a plan. It stops short of an explicit inverse (e.g. 'for a single tool call use `call`'), leaving that to inference.

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

Deploy Server

Other Tools