[
  {
    "type": "function",
    "name": "browser_back",
    "description": "Navigate back to the previous page in browser history. Requires browser_navigate to be called first.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "browser_click",
    "description": "Click on an element identified by its ref ID from the snapshot (e.g., '@e5'). The ref IDs are shown in square brackets in the snapshot output. Requires browser_navigate and browser_snapshot to be called first.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "ref": {
          "type": "string",
          "description": "The element reference from the snapshot (e.g., '@e5', '@e12')"
        }
      },
      "required": [
        "ref"
      ]
    }
  },
  {
    "type": "function",
    "name": "browser_console",
    "description": "Get browser console output and JavaScript errors from the current page. Returns console.log/warn/error/info messages and uncaught JS exceptions. Use this to detect silent JavaScript errors, failed API calls, and application warnings. Requires browser_navigate to be called first. When 'expression' is provided, evaluates JavaScript in the page context and returns the result — use this for DOM inspection, reading page state, or extracting data programmatically.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "clear": {
          "type": "boolean",
          "default": false,
          "description": "If true, clear the message buffers after reading"
        },
        "expression": {
          "type": "string",
          "description": "JavaScript expression to evaluate in the page context. Runs in the browser like DevTools console — full access to DOM, window, document. Return values are serialized to JSON. Example: 'document.title' or 'document.querySelectorAll(\"a\").length'"
        }
      }
    }
  },
  {
    "type": "function",
    "name": "browser_get_images",
    "description": "Get a list of all images on the current page with their URLs and alt text. Useful for finding images to analyze with the vision tool. Requires browser_navigate to be called first.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "browser_navigate",
    "description": "Navigate to a URL in the browser. Initializes the session and loads the page. Must be called before other browser tools. For simple information retrieval, prefer web_search or web_extract (faster, cheaper). For plain-text endpoints — URLs ending in .md, .txt, .json, .yaml, .yml, .csv, .xml, raw.githubusercontent.com, or any documented API endpoint — prefer curl via the terminal tool or web_extract; the browser stack is overkill and much slower for these. Use browser tools when you need to interact with a page (click, fill forms, dynamic content). Returns a compact page snapshot with interactive elements and ref IDs — no need to call browser_snapshot separately after navigating.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "description": "The URL to navigate to (e.g., 'https://example.com')"
        }
      },
      "required": [
        "url"
      ]
    }
  },
  {
    "type": "function",
    "name": "browser_press",
    "description": "Press a keyboard key. Useful for submitting forms (Enter), navigating (Tab), or keyboard shortcuts. Requires browser_navigate to be called first.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "Key to press (e.g., 'Enter', 'Tab', 'Escape', 'ArrowDown')"
        }
      },
      "required": [
        "key"
      ]
    }
  },
  {
    "type": "function",
    "name": "browser_scroll",
    "description": "Scroll the page in a direction. Use this to reveal more content that may be below or above the current viewport. Requires browser_navigate to be called first.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "direction": {
          "type": "string",
          "enum": [
            "up",
            "down"
          ],
          "description": "Direction to scroll"
        }
      },
      "required": [
        "direction"
      ]
    }
  },
  {
    "type": "function",
    "name": "browser_snapshot",
    "description": "Get a text-based snapshot of the current page's accessibility tree. Returns interactive elements with ref IDs (like @e1, @e2) for browser_click and browser_type. full=false (default): compact view with interactive elements. full=true: complete page content. Snapshots over 8000 chars are truncated or LLM-summarized. Requires browser_navigate first. Note: browser_navigate already returns a compact snapshot — use this to refresh after interactions that change the page, or with full=true for complete content.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "full": {
          "type": "boolean",
          "description": "If true, returns complete page content. If false (default), returns compact view with interactive elements only.",
          "default": false
        }
      }
    }
  },
  {
    "type": "function",
    "name": "browser_type",
    "description": "Type text into an input field identified by its ref ID. Clears the field first, then types the new text. Requires browser_navigate and browser_snapshot to be called first.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "ref": {
          "type": "string",
          "description": "The element reference from the snapshot (e.g., '@e3')"
        },
        "text": {
          "type": "string",
          "description": "The text to type into the field"
        }
      },
      "required": [
        "ref",
        "text"
      ]
    }
  },
  {
    "type": "function",
    "name": "browser_vision",
    "description": "Take a screenshot of the current page so you can inspect it visually. Use this when you need to understand what the page looks like - especially for CAPTCHAs, visual verification challenges, complex layouts, or cases where the text snapshot misses important visual information. When your active model has native vision, the screenshot is attached to your context directly and you inspect it on the next turn; otherwise Hermes falls back to an auxiliary vision model and returns a text analysis. Includes a screenshot_path that you can share with the user by including MEDIA:<screenshot_path> in your response. Requires browser_navigate to be called first.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "question": {
          "type": "string",
          "description": "What you want to know about the page visually. Be specific about what you're looking for."
        },
        "annotate": {
          "type": "boolean",
          "default": false,
          "description": "If true, overlay numbered [N] labels on interactive elements. Each [N] maps to ref @eN for subsequent browser commands. Useful for QA and spatial reasoning about page layout."
        }
      },
      "required": [
        "question"
      ]
    }
  },
  {
    "type": "function",
    "name": "clarify",
    "description": "Ask the user a question when you need clarification, feedback, or a decision before proceeding. Supports two modes:\n\n1. **Multiple choice** — provide up to 4 choices. The user picks one or types their own answer via a 5th 'Other' option.\n2. **Open-ended** — omit choices entirely. The user types a free-form response.\n\nCRITICAL: when you are offering options, put each option ONLY in the `choices` array — NEVER enumerate the options inside the `question` text. The UI renders `choices` as selectable rows; options written into the question string render as dead prose the user can't pick. Right: question='Which deployment target?', choices=['staging', 'prod']. Wrong: question='Which target? 1) staging 2) prod', choices=[].\n\nUse this tool when:\n- The task is ambiguous and you need the user to choose an approach\n- You want post-task feedback ('How did that work out?')\n- You want to offer to save a skill or update memory\n- A decision has meaningful trade-offs the user should weigh in on\n\nDo NOT use this tool for simple yes/no confirmation of dangerous commands (the terminal tool handles that). Prefer making a reasonable default choice yourself when the decision is low-stakes.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "question": {
          "type": "string",
          "description": "The question itself, and ONLY the question (e.g. 'Which deployment target?'). Do NOT embed the answer options here — pass them as separate elements in `choices`."
        },
        "choices": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 4,
          "description": "REQUIRED whenever you are presenting selectable options: each distinct option is its own array element (up to 4). The UI renders these as pickable rows and auto-appends an 'Other (type your answer)' option. Omit this parameter entirely ONLY for a genuinely open-ended free-text question."
        }
      },
      "required": [
        "question"
      ]
    }
  },
  {
    "type": "function",
    "name": "cronjob",
    "description": "Manage scheduled cron jobs with a single compressed tool.\n\nUse action='create' to schedule a new job from a prompt or one or more skills.\nUse action='list' to inspect jobs.\nUse action='update', 'pause', 'resume', 'remove', or 'run' to manage an existing job.\n\nTo stop a job the user no longer wants: first action='list' to find the job_id, then action='remove' with that job_id. Never guess job IDs — always list first.\n\nJobs run in a fresh session with no current-chat context, so prompts must be self-contained.\nIf skills are provided on create, the future cron run loads those skills in order, then follows the prompt as the task instruction.\nOn update, passing skills=[] clears attached skills.\n\nNOTE: The agent's final response is auto-delivered to the target. Put the primary\nuser-facing content in the final response. Cron jobs run autonomously with no user\npresent — they cannot ask questions or request clarification.\n\nImportant safety rule: cron-run sessions should not recursively schedule more cron jobs.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "action": {
          "type": "string",
          "description": "One of: create, list, update, pause, resume, remove, run. When action=create, the 'schedule' and 'prompt' fields are REQUIRED."
        },
        "job_id": {
          "type": "string",
          "description": "Required for update/pause/resume/remove/run"
        },
        "prompt": {
          "type": "string",
          "description": "For create: the full self-contained prompt. If skills are also provided, this becomes the task instruction paired with those skills."
        },
        "schedule": {
          "type": "string",
          "description": "REQUIRED for action=create. For create/update: '30m', 'every 2h', '0 9 * * *', or ISO timestamp. Examples: '30m' (every 30 minutes), 'every 2h' (every 2 hours), '0 9 * * *' (daily at 9am), '2026-06-01T09:00:00' (one-shot). You MUST include this field when action=create."
        },
        "name": {
          "type": "string",
          "description": "Optional human-friendly name"
        },
        "repeat": {
          "type": "integer",
          "description": "Optional repeat count. Omit for defaults (once for one-shot, forever for recurring)."
        },
        "deliver": {
          "type": "string",
          "description": "Omit this parameter to auto-deliver back to the current chat and topic (recommended). Auto-detection preserves thread/topic context. Only set explicitly when the user asks to deliver somewhere OTHER than the current conversation. Values: 'origin' (same as omitting), 'local' (no delivery, save only), 'all' (fan out to every connected home channel), or platform:chat_id:thread_id for a specific destination. Combine with comma: 'origin,all' delivers to the origin plus every other connected channel. Examples: 'telegram:-1001234567890:17585', 'discord:#engineering', 'sms:+155****4567', 'all'. WARNING: 'platform:chat_id' without :thread_id loses topic targeting. 'all' resolves at fire time, so a job created before a channel was wired up will pick it up automatically once connected."
        },
        "skills": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional ordered list of skill names to load before executing the cron prompt. On update, pass an empty array to clear attached skills."
        },
        "model": {
          "type": "object",
          "description": "Optional per-job model override. If provider is omitted, the current main provider is pinned at creation time so the job stays stable.",
          "properties": {
            "provider": {
              "type": "string",
              "description": "Provider name (e.g. 'openrouter', 'anthropic', or 'custom:<name>' for a provider defined in custom_providers config — always include the ':<name>' suffix, never pass the bare 'custom'). Omit to use and pin the current provider."
            },
            "model": {
              "type": "string",
              "description": "Model name (e.g. 'anthropic/claude-sonnet-4', 'claude-sonnet-4')"
            }
          },
          "required": [
            "model"
          ]
        },
        "script": {
          "type": "string",
          "description": "Optional path to a script that runs each tick. In the default mode its stdout is injected into the agent's prompt as context (data-collection / change-detection pattern). With no_agent=True, the script IS the job and its stdout is delivered verbatim (classic watchdog pattern). Relative paths resolve under ~/.hermes/scripts/. ``.sh``/``.bash`` extensions run via bash, everything else via Python. On update, pass empty string to clear."
        },
        "no_agent": {
          "type": "boolean",
          "default": false,
          "description": "Default: False (LLM-driven job — the agent runs the prompt each tick). Set True to skip the LLM entirely: the scheduler just runs ``script`` on schedule and delivers its stdout verbatim. No tokens, no agent loop, no model override honoured. \n\nREQUIREMENTS when True: ``script`` MUST be set (``prompt`` and ``skills`` are ignored). \n\nDELIVERY SEMANTICS when True: (a) non-empty stdout is sent verbatim as the message; (b) EMPTY stdout means SILENT — nothing is sent to the user and they won't see anything happened, so design your script to stay quiet when there's nothing to report (the watchdog pattern); (c) non-zero exit / timeout sends an error alert so a broken watchdog can't fail silently. \n\nWHEN TO USE True: recurring script-only pings where the script itself produces the exact message text (memory/disk/GPU watchdogs, threshold alerts, heartbeats, CI notifications, API pollers with a fixed output shape). WHEN TO USE False (default): anything that needs reasoning — summarize a feed, draft a daily briefing, pick interesting items, rephrase data for a human, follow conditional logic based on content."
        },
        "context_from": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional job ID or list of job IDs whose most recent completed output is injected into the prompt as context before each run. Use this to chain cron jobs: job A collects data, job B processes it. Each entry must be a valid job ID (from cronjob action='list'). Note: injects the most recent completed output — does not wait for upstream jobs running in the same tick. On update, pass an empty array to clear."
        },
        "enabled_toolsets": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional list of toolset names to restrict the job's agent to (e.g. [\"web\", \"terminal\", \"file\", \"delegation\"]). When set, only tools from these toolsets are loaded, significantly reducing input token overhead. When omitted, all default tools are loaded. Infer from the job's prompt — e.g. use \"web\" if it calls web_search, \"terminal\" if it runs scripts, \"file\" if it reads files, \"delegation\" if it calls delegate_task. On update, pass an empty array to clear."
        },
        "workdir": {
          "type": "string",
          "description": "Optional absolute path to run the job from. When set, AGENTS.md / CLAUDE.md / .cursorrules from that directory are injected into the system prompt, and the terminal/file/code_exec tools use it as their working directory — useful for running a job inside a specific project repo. Must be an absolute path that exists. When unset (default), preserves the original behaviour: no project context files, tools use the scheduler's cwd. On update, pass an empty string to clear. Jobs with workdir run sequentially (not parallel) to keep per-job directories isolated."
        },
        "attach_to_session": {
          "type": "boolean",
          "description": "When True, this job becomes CONTINUABLE: the user can reply to its delivery and the agent has the brief in context instead of asking 'what is that?'. On thread-capable platforms (Telegram topics, Discord/Slack threads) a dedicated thread is opened for the job and its replies; on DM-only platforms (WhatsApp/Signal) the brief is mirrored into the origin DM session. Use this for conversational recurring jobs the user will reply to — daily briefings, reminders that kick off follow-up work. Leave unset for fire-and-forget alerts/watchdogs. Overrides the global cron.mirror_delivery config for this one job. Only the origin chat is touched (never fan-out targets); no effect when deliver='local'."
        }
      },
      "required": [
        "action"
      ]
    }
  },
  {
    "type": "function",
    "name": "delegate_task",
    "description": "Spawn one or more subagents to work on tasks in isolated contexts. Each subagent gets its own conversation, terminal session, and toolset. Only the final summary is returned -- intermediate tool results never enter your context window.\n\nTWO MODES (one of 'goal' or 'tasks' is required):\n1. Single task: provide 'goal' (+ optional context, toolsets).\n2. Batch (parallel): provide 'tasks' array with up to 3 items concurrently for this user (configured via delegation.max_concurrent_children in config.yaml). Nested delegation is OFF for this user (max_spawn_depth=1): every child is a leaf and cannot delegate further. Raise delegation.max_spawn_depth in config.yaml to enable nesting.\n\nBOTH MODES RUN IN THE BACKGROUND. delegate_task returns immediately — you and the user keep working, and each subagent's full result re-enters the conversation as its own new message when it finishes. A batch is just N independent background subagents (N handles, each completes on its own). Do NOT wait or poll; just continue with other work after dispatching.\n\nWHEN TO USE delegate_task:\n- Reasoning-heavy subtasks (debugging, code review, research synthesis)\n- Tasks that would flood your context with intermediate data\n- Parallel independent workstreams (research A and B simultaneously)\n\nWHEN NOT TO USE (use these instead):\n- Mechanical multi-step work with no reasoning needed -> use execute_code\n- Single tool call -> just call the tool directly\n- Tasks needing user interaction -> subagents cannot use clarify\n- Durable long-running work that must outlive the current turn -> use cronjob (action='create') or terminal(background=True, notify_on_complete=True) instead. Background delegations are NOT durable: if the parent session is closed (/new) or the process exits before a subagent finishes, that subagent's work is discarded, and /stop cancels every running background subagent.\n\nIMPORTANT:\n- Subagents have NO memory of your conversation. Pass all relevant info (file paths, error messages, constraints) via the 'context' field.\n- If the user is writing in a non-English language, or asked for output in a specific language / tone / style, say so in 'context' (e.g. \"respond in Chinese\", \"return output in Japanese\"). Otherwise subagents default to English and their summaries will contaminate your final reply with the wrong language.\n- Subagent summaries are SELF-REPORTS, not verified facts. A subagent that claims \"uploaded successfully\" or \"file written\" may be wrong. For operations with external side-effects (HTTP POST/PUT, remote writes, file creation at shared paths, publishing), require the subagent to return a verifiable handle (URL, ID, absolute path, HTTP status) and verify it yourself — fetch the URL, stat the file, read back the content — before telling the user the operation succeeded.\n- Leaf subagents (role='leaf', the default) CANNOT call: delegate_task, clarify, memory, send_message, execute_code.\n- Orchestrator subagents (role='orchestrator') retain delegate_task so they can spawn their own workers, but still cannot use clarify, memory, send_message, or execute_code. Orchestrators are bounded by max_spawn_depth=1 for this user and can be disabled globally via delegation.orchestrator_enabled=false.\n- Subagent model is NOT selectable per call: children inherit the parent model (plus its fallback chain) unless you pin all subagents to a model via delegation.provider / delegation.model in config.yaml.\n- Each subagent gets its own terminal session (separate working directory and state).\n- Results are always returned as an array, one entry per task.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "goal": {
          "type": "string",
          "description": "What the subagent should accomplish. Be specific and self-contained -- the subagent knows nothing about your conversation history."
        },
        "context": {
          "type": "string",
          "description": "Background information the subagent needs: file paths, error messages, project structure, constraints. The more specific you are, the better the subagent performs."
        },
        "tasks": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "goal": {
                "type": "string",
                "description": "Task goal"
              },
              "context": {
                "type": "string",
                "description": "Task-specific context"
              },
              "acp_command": {
                "type": "string",
                "description": "Per-task ACP command override (e.g. 'copilot'). Overrides the top-level acp_command for this task only. Do NOT set unless the user explicitly told you an ACP CLI is installed."
              },
              "acp_args": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Per-task ACP args override. Leave empty unless acp_command is set."
              },
              "role": {
                "type": "string",
                "enum": [
                  "leaf",
                  "orchestrator"
                ],
                "description": "Per-task role override. See top-level 'role' for semantics."
              }
            },
            "required": [
              "goal"
            ]
          },
          "description": "Batch mode: tasks to run in parallel (up to 3 for this user, set via delegation.max_concurrent_children). Each gets its own subagent with isolated context and terminal session. When provided, top-level goal/context/toolsets are ignored."
        },
        "role": {
          "type": "string",
          "enum": [
            "leaf",
            "orchestrator"
          ],
          "description": "Role of the child agent. 'leaf' (default) = focused worker, cannot delegate further. 'orchestrator' = can use delegate_task to spawn its own workers. Nesting is OFF for this user (max_spawn_depth=1); 'orchestrator' is silently forced to 'leaf'. Raise delegation.max_spawn_depth in config.yaml to enable."
        },
        "background": {
          "type": "boolean",
          "description": "DEPRECATED / IGNORED. Single-task delegations always run in the background automatically — you do not need to (and cannot) opt in or out. The result re-enters the conversation as a new message when the subagent finishes; just continue working in the meantime. Setting this has no effect; the parameter remains only for backward compatibility."
        },
        "acp_command": {
          "type": "string",
          "description": "Override ACP command for child agents (e.g. 'copilot'). When set, children use ACP subprocess transport instead of inheriting the parent's transport. Requires an ACP-compatible CLI (currently GitHub Copilot CLI via 'copilot --acp --stdio'). See agent/copilot_acp_client.py for the implementation. IMPORTANT: Do NOT set this unless the user has explicitly told you a specific ACP-compatible CLI is installed and configured. Leave empty to use the parent's default transport (Hermes subagents)."
        },
        "acp_args": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Arguments for the ACP command (default: ['--acp', '--stdio']). Only used when acp_command is set. Leave empty unless acp_command is explicitly provided."
        }
      }
    }
  },
  {
    "type": "function",
    "name": "execute_code",
    "description": "Run a Python script that can call Hermes tools programmatically. Use this when you need 3+ tool calls with processing logic between them, need to filter/reduce large tool outputs before they enter your context, need conditional branching (if X then Y else Z), or need to loop (fetch N pages, process N files, retry on failure).\n\nUse normal tool calls instead when: single tool call with no processing, you need to see the full result and apply complex reasoning, or the task requires interactive user input.\n\nAvailable via `from hermes_tools import ...`:\n\n  web_search(query: str, limit: int = 5) -> dict\n    Returns {\"data\": {\"web\": [{\"url\", \"title\", \"description\"}, ...]}}\n  web_extract(urls: list[str], char_limit: int = None) -> dict\n    Returns {\"results\": [{\"url\", \"title\", \"content\", \"error\"}, ...]} where content is markdown.\n    No LLM summarization. Pages over char_limit (default 15000) are head+tail truncated; full text stored on disk (path in the content footer).\n  read_file(path: str, offset: int = 1, limit: int = 500) -> dict\n    Lines are 1-indexed. Returns {\"content\": \"...\", \"total_lines\": N}\n  write_file(path: str, content: str) -> dict\n    Always overwrites the entire file.\n  search_files(pattern: str, target=\"content\", path=\".\", file_glob=None, limit=50) -> dict\n    target: \"content\" (search inside files) or \"files\" (find files by name). Returns {\"matches\": [...]}\n  patch(path: str, old_string: str, new_string: str, replace_all: bool = False) -> dict\n    Replaces old_string with new_string in the file.\n  terminal(command: str, timeout=None, workdir=None) -> dict\n    Foreground only (no background/pty). Returns {\"output\": \"...\", \"exit_code\": N}\n\nLimits: 5-minute timeout, 50KB stdout cap, max 50 tool calls per script. terminal() is foreground-only (no background or pty).\n\nScripts run in the session's working directory with the active venv's python, so project deps (pandas, etc.) and relative paths work like in terminal().\n\nPrint your final result to stdout. Use Python stdlib (json, re, math, csv, datetime, collections, etc.) for processing between tool calls.\n\nAlso available (no import needed — built into hermes_tools):\n  json_parse(text: str) — json.loads with strict=False; use for terminal() output with control chars\n  shell_quote(s: str) — shlex.quote(); use when interpolating dynamic strings into shell commands\n  retry(fn, max_attempts=3, delay=2) — retry with exponential backoff for transient failures",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Python code to execute. Import tools with `from hermes_tools import web_search, terminal, ...` and print your final result to stdout."
        }
      },
      "required": [
        "code"
      ]
    }
  },
  {
    "type": "function",
    "name": "hermeslink_deliver",
    "description": "Deliver one or more local files to the current HermesPilot App conversation.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "files": {
          "type": "array",
          "description": "Absolute local file paths to deliver to the App.",
          "items": {
            "type": "object",
            "properties": {
              "path": {
                "type": "string",
                "description": "Absolute local path of a file to deliver."
              },
              "caption": {
                "type": "string",
                "description": "Optional short label for the file."
              }
            },
            "required": [
              "path"
            ]
          }
        }
      },
      "required": [
        "files"
      ]
    }
  },
  {
    "type": "function",
    "name": "image_generate",
    "description": "Generate high-quality images from text prompts (text-to-image), or edit / transform an existing image (image-to-image) when the active model supports it. Pass `image_url` to edit that image; add `reference_image_urls` for style/composition references; omit both for text-to-image. The underlying backend (FAL, OpenAI, xAI, etc.) and model are user-configured and not selectable by the agent. Returns the result in the `image` field — either a URL or an absolute file path. To show it to the user, reference that path/URL in your response using the file-delivery convention for the current platform (your platform guidance describes how files are delivered here). When the active terminal backend has a different filesystem, successful local-file results may also include `agent_visible_image` for follow-up terminal/file operations.\n\nActive backend: xAI (Grok) · model: grok-imagine-image\n- supports both text-to-image (omit image_url) and image-to-image / editing (pass image_url); up to 2 reference image(s) via reference_image_urls — routes automatically",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "prompt": {
          "type": "string",
          "description": "The text prompt describing the desired image (text-to-image) or the edit to apply (image-to-image). Be detailed and descriptive."
        },
        "aspect_ratio": {
          "type": "string",
          "enum": [
            "landscape",
            "square",
            "portrait"
          ],
          "description": "The aspect ratio of the generated image. 'landscape' is 16:9 wide, 'portrait' is 16:9 tall, 'square' is 1:1.",
          "default": "landscape"
        },
        "image_url": {
          "type": "string",
          "description": "Optional source image to edit/transform (image-to-image). When provided, the active backend routes to its image editing endpoint; when omitted, it generates from text alone. Pass a public URL or an absolute local file path from the conversation. Only honored by models that support editing — the description above indicates whether the active model does."
        },
        "reference_image_urls": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional list of additional reference image URLs / paths (style, character, or composition references) to guide an image-to-image edit. Supported only by some models and capped per-model; the description above indicates the max."
        }
      },
      "required": [
        "prompt"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_kiwi_feedback_to_devs",
    "description": "Send feedback, bug reports, or feature requests to the Kiwi.com MCP server developers. Include any relevant details such as error messages, logs, or context that would help the developers understand the issue or suggestion.",
    "strict": false,
    "parameters": {
      "properties": {
        "text": {
          "description": "The content of the feedback. Include any relevant details such as error messages, logs, or context that would help the developers understand the issue or suggestion.",
          "maxLength": 3000,
          "minLength": 1,
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "text"
      ],
      "title": "feedback_to_devsArguments",
      "type": "object"
    }
  },
  {
    "type": "function",
    "name": "mcp_kiwi_get_prompt",
    "description": "Get a prompt by name from MCP server 'kiwi'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the prompt to retrieve"
        },
        "arguments": {
          "type": "object",
          "description": "Optional arguments to pass to the prompt",
          "properties": {},
          "additionalProperties": true
        }
      },
      "required": [
        "name"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_kiwi_list_prompts",
    "description": "List available prompts from MCP server 'kiwi'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_kiwi_list_resources",
    "description": "List available resources from MCP server 'kiwi'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_kiwi_read_resource",
    "description": "Read a resource by URI from MCP server 'kiwi'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "uri": {
          "type": "string",
          "description": "URI of the resource to read"
        }
      },
      "required": [
        "uri"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_kiwi_search_flight",
    "description": "# Search for flights\n\nSearches Kiwi.com for available flights between two locations for the given dates and passengers. City or airport names are resolved automatically, so call this whenever the user wants to search for flights — whether they gave IATA codes or just place names.\n\n## Result shape\n\nReturns `{ query, currency, passengers, resultsCount, itineraries, searchTimeMs }`. Each item in `itineraries` has:\n- `price` (number) and `priceFormatted` (e.g. \"123 EUR\")\n- `totalDurationSeconds`\n- `bookingUrl` — the link to book the flight\n- `outbound` (and `inbound` for return flights), each a leg with: `route` (list of airport codes including layovers, e.g. [\"PRG\",\"MAD\",\"BCN\"]), `departureTime` / `arrivalTime` (local ISO timestamps), `durationSeconds`, `stops`, `cabinClass`, and a `segments` list.\n\n## How to display\n\nRender a markdown table. Group results into cheapest (lowest `price`), shortest (lowest `totalDurationSeconds`), and other notable options. For each itinerary show, in order:\n  - Route: join `outbound.route` with \" → \" (e.g. \"PRG → MAD → BCN\"); for return flights show `inbound.route` on a second line.\n  - Times & duration: `outbound.departureTime` → `outbound.arrivalTime` (local), formatted readably (e.g. \"12 Jun 06:05 → 09:30 (3h 25m)\") using `outbound.durationSeconds`; add the `inbound` equivalents for return flights.\n  - Cabin: `outbound.cabinClass` (e.g. \"Economy\").\n  - Price: `priceFormatted`.\n  - Booking link: `bookingUrl`.\n\nFinally, summarise the best price and the shortest option, give a recommendation, and end wishing the user a nice trip with a short fun fact about the destination!",
    "strict": false,
    "parameters": {
      "properties": {
        "flyFrom": {
          "description": "Origin: IATA code, city or airport name (e.g. \"PRG\", \"Prague\", \"London Heathrow\")",
          "maxLength": 100,
          "minLength": 1,
          "title": "Flyfrom",
          "type": "string"
        },
        "flyTo": {
          "description": "Destination: IATA code, city or airport name",
          "maxLength": 100,
          "minLength": 1,
          "title": "Flyto",
          "type": "string"
        },
        "departureDate": {
          "description": "Departure date in dd/mm/yyyy — the day to fly, or the earliest date of a range (see departureDateTo)",
          "maxLength": 10,
          "title": "Departuredate",
          "type": "string"
        },
        "departureDateFlexDays": {
          "default": 0,
          "description": "Search +/- this many days around departureDate (symmetric). Leave 0 when using departureDateTo",
          "maximum": 3,
          "minimum": 0,
          "title": "Departuredateflexdays",
          "type": "integer"
        },
        "departureDateTo": {
          "maxLength": 10,
          "type": "string",
          "nullable": true,
          "title": "Departuredateto",
          "description": "Latest departure date in dd/mm/yyyy for an explicit range [departureDate .. departureDateTo]. Use instead of departureDateFlexDays for a one-directional or asymmetric range; must be >= departureDate",
          "default": null
        },
        "returnDate": {
          "maxLength": 10,
          "type": "string",
          "nullable": true,
          "title": "Returndate",
          "description": "Return date in dd/mm/yyyy — the day to fly back, or the earliest return date of a range (omit for one-way)",
          "default": null
        },
        "returnDateFlexDays": {
          "default": 0,
          "description": "Search +/- this many days around returnDate (symmetric). Leave 0 when using returnDateTo",
          "maximum": 3,
          "minimum": 0,
          "title": "Returndateflexdays",
          "type": "integer"
        },
        "returnDateTo": {
          "maxLength": 10,
          "type": "string",
          "nullable": true,
          "title": "Returndateto",
          "description": "Latest return date in dd/mm/yyyy for an explicit range [returnDate .. returnDateTo]. Requires returnDate; use instead of returnDateFlexDays; must be >= returnDate",
          "default": null
        },
        "adults": {
          "default": 1,
          "description": "Number of adults (12+)",
          "maximum": 9,
          "minimum": 1,
          "title": "Adults",
          "type": "integer"
        },
        "children": {
          "default": 0,
          "description": "Number of children (2-11)",
          "maximum": 8,
          "minimum": 0,
          "title": "Children",
          "type": "integer"
        },
        "infants": {
          "default": 0,
          "description": "Number of infants (<2)",
          "maximum": 4,
          "minimum": 0,
          "title": "Infants",
          "type": "integer"
        },
        "cabinClass": {
          "enum": [
            "M",
            "W",
            "C",
            "F"
          ],
          "type": "string",
          "nullable": true,
          "title": "Cabinclass",
          "description": "M=economy, W=premium economy, C=business, F=first",
          "default": null
        },
        "currency": {
          "default": "EUR",
          "description": "Currency code (e.g. EUR, USD)",
          "maxLength": 3,
          "minLength": 1,
          "title": "Currency",
          "type": "string"
        },
        "locale": {
          "default": "en",
          "description": "Locale (e.g. en, de, fr)",
          "maxLength": 10,
          "minLength": 1,
          "title": "Locale",
          "type": "string"
        },
        "nights_in_dst_from": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Nights In Dst From",
          "description": "Minimum nights at destination before return flight. Turns the search into a return search",
          "default": null
        },
        "nights_in_dst_to": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Nights In Dst To",
          "description": "Maximum nights at destination before return flight",
          "default": null
        },
        "one_for_city": {
          "default": false,
          "description": "If true, return only the single best result per destination city — useful for 'explore' searches with broad destinations",
          "title": "One For City",
          "type": "boolean"
        },
        "max_sector_stopovers": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Max Sector Stopovers",
          "description": "Maximum number of stopovers (connections) allowed per flight sector",
          "default": null
        },
        "price_from": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Price From",
          "description": "Minimum total price filter in the specified currency",
          "default": null
        },
        "price_to": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Price To",
          "description": "Maximum total price filter in the specified currency",
          "default": null
        },
        "max_fly_duration": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Max Fly Duration",
          "description": "Maximum total flight duration in hours",
          "default": null
        },
        "select_airlines": {
          "maxLength": 200,
          "type": "string",
          "nullable": true,
          "title": "Select Airlines",
          "description": "Only include flights operated by these airlines — comma-separated IATA codes, e.g. 'FR,U2,BA'. Mutually exclusive with exclude_airlines",
          "default": null
        },
        "exclude_airlines": {
          "maxLength": 200,
          "type": "string",
          "nullable": true,
          "title": "Exclude Airlines",
          "description": "Exclude flights operated by these airlines — comma-separated IATA codes, e.g. 'FR,W6'. Mutually exclusive with select_airlines",
          "default": null
        },
        "dtime_from": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Dtime From",
          "description": "Earliest outbound departure hour (0-23, local)",
          "default": null
        },
        "dtime_to": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Dtime To",
          "description": "Latest outbound departure hour (0-23, local)",
          "default": null
        },
        "atime_from": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Atime From",
          "description": "Earliest outbound arrival hour (0-23, local)",
          "default": null
        },
        "atime_to": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Atime To",
          "description": "Latest outbound arrival hour (0-23, local)",
          "default": null
        },
        "ret_dtime_from": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Ret Dtime From",
          "description": "Earliest return departure hour (0-23, local)",
          "default": null
        },
        "ret_dtime_to": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Ret Dtime To",
          "description": "Latest return departure hour (0-23, local)",
          "default": null
        },
        "ret_atime_from": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Ret Atime From",
          "description": "Earliest return arrival hour (0-23, local)",
          "default": null
        },
        "ret_atime_to": {
          "maximum": 23,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Ret Atime To",
          "description": "Latest return arrival hour (0-23, local)",
          "default": null
        },
        "stopover_from": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Stopover From",
          "description": "Minimum layover duration in hours",
          "default": null
        },
        "stopover_to": {
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Stopover To",
          "description": "Maximum layover duration in hours",
          "default": null
        },
        "adults_hold_bags": {
          "maximum": 2,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Adults Hold Bags",
          "description": "Checked (hold) bags per adult (0-2)",
          "default": null
        },
        "adults_hand_bags": {
          "maximum": 1,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Adults Hand Bags",
          "description": "Cabin (hand) bags per adult (0-1)",
          "default": null
        },
        "children_hold_bags": {
          "maximum": 2,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Children Hold Bags",
          "description": "Checked (hold) bags per child (0-2)",
          "default": null
        },
        "children_hand_bags": {
          "maximum": 1,
          "minimum": 0,
          "type": "integer",
          "nullable": true,
          "title": "Children Hand Bags",
          "description": "Cabin (hand) bags per child (0-1)",
          "default": null
        },
        "allow_self_transfer": {
          "default": true,
          "description": "Allow self-transfer (virtual interlining) connections between separate tickets",
          "title": "Allow Self Transfer",
          "type": "boolean"
        },
        "allow_overnight_stopovers": {
          "default": true,
          "description": "Allow overnight (red-eye) layovers",
          "title": "Allow Overnight Stopovers",
          "type": "boolean"
        },
        "allow_diff_airport_connection": {
          "default": true,
          "description": "Allow connections that change airports within the same city",
          "title": "Allow Diff Airport Connection",
          "type": "boolean"
        },
        "stopover_airports": {
          "maxLength": 200,
          "type": "string",
          "nullable": true,
          "title": "Stopover Airports",
          "description": "Only connect via these airports — comma-separated IATA codes. Constrains connecting flights only; direct (non-stop) flights are still returned.",
          "default": null
        },
        "exclude_stopover_airports": {
          "maxLength": 200,
          "type": "string",
          "nullable": true,
          "title": "Exclude Stopover Airports",
          "description": "Never connect via these airports — comma-separated IATA codes",
          "default": null
        },
        "stopover_countries": {
          "maxLength": 200,
          "type": "string",
          "nullable": true,
          "title": "Stopover Countries",
          "description": "Only connect via these countries — comma-separated ISO 3166-1 alpha-2 codes, e.g. 'DE,AT'. Constrains connecting flights only; direct (non-stop) flights are still returned.",
          "default": null
        },
        "exclude_stopover_countries": {
          "maxLength": 200,
          "type": "string",
          "nullable": true,
          "title": "Exclude Stopover Countries",
          "description": "Never connect via these countries — comma-separated ISO 3166-1 alpha-2 codes",
          "default": null
        },
        "fly_days": {
          "maxLength": 32,
          "type": "string",
          "nullable": true,
          "title": "Fly Days",
          "description": "Allowed outbound departure weekdays — comma-separated 0=Sun..6=Sat, e.g. '1,2,3,4,5' for weekdays",
          "default": null
        },
        "ret_fly_days": {
          "maxLength": 32,
          "type": "string",
          "nullable": true,
          "title": "Ret Fly Days",
          "description": "Allowed return departure weekdays — comma-separated 0=Sun..6=Sat",
          "default": null
        },
        "sort": {
          "default": "price",
          "description": "Result ordering",
          "enum": [
            "price",
            "duration",
            "quality",
            "date",
            "popularity"
          ],
          "title": "Sort",
          "type": "string"
        }
      },
      "required": [
        "flyFrom",
        "flyTo",
        "departureDate"
      ],
      "title": "search_flightsArguments",
      "type": "object"
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_apply_logic",
    "description": "Create or update logic rules using DSL syntax: WHEN <condition> THEN <action>.\n\n<uuid_references>\nAll UUIDs come from the ledger. Use the correct column:\n- **Condition LHS** → questionUuid column\n- **Condition RHS for choice fields (Dropdown, MultipleChoice, Checkboxes)** → optionBlockUuid (NOT the option text)\n- **Condition LHS for Matrix** → row blockUuid (MATRIX_ROW)\n- **Condition RHS for Matrix** → matrix column blockUuid (NOT the option text)\n- **SHOW/HIDE a full question** → questionUuid column\n- **SHOW/HIDE a single block (e.g. one option)** → blockUuid column\n- **REQUIRE** → questionUuid column\n- **JUMP TO PAGE** → page number column\n</uuid_references>\n\n<conditions>\nEach condition compares a field to a value, e.g. `<priceUuid> > 100`. Don't apply math to the field, and don't compare two fields to each other (for choice fields, the comparison value can still be an optionBlockUuid). To check a calculated value (like price × qty > 100), store the result as a calc field first and use that:\n- Choice fields (Dropdown, MultipleChoice): `<questionUuid> IS <optionBlockUuid>` / `IS NOT <optionBlockUuid>`\n- Text/Email/Link/Phone fields: `<questionUuid> IS \"literal text\"` / `IS NOT \"literal text\"`\n- Empty check (any field): `<questionUuid> IS EMPTY` / `IS NOT EMPTY`\n- Number/Rating/LinearScale: `<questionUuid> > 5` (any of `> >= < <= = !=`)\n- Text matching: `<questionUuid> CONTAINS \"text\"` / `DOES NOT CONTAIN \"text\"`\n- Text matching: `<questionUuid> STARTS WITH \"text\"` / `ENDS WITH \"text\"`\n- Text matching: `<questionUuid> DOES NOT START WITH \"text\"` / `DOES NOT END WITH \"text\"`\n- Checkboxes/MultiSelect (arrays): `<questionUuid> IS ANY OF (<blockUuid>,<blockUuid>)` / `IS NOT ANY OF` / `IS EVERY OF`\n- Checkboxes/MultiSelect: do NOT use IS/IS NOT — use CONTAINS or IS ANY OF instead\n- Matrix: `<matrixRowBlockUuid> IS <matrixColumnBlockUuid>`; use CONTAINS / IS ANY OF when multiple selection is enabled\n- Date fields: `<questionUuid> IS BEFORE \"2024-01-01\"` / `IS AFTER \"2024-01-01\"`\n- Combine: `<cond1> AND <cond2>` or `<cond1> OR <cond2>` (parentheses required when mixing)\n</conditions>\n\n<actions>\n- `SHOW <questionUuid>` / `HIDE <questionUuid>` (comma-separate for multiple)\n- `SHOW <blockUuid>` / `HIDE <blockUuid>` to target a single block within a question\n- `REQUIRE <questionUuid>`\n- `JUMP TO PAGE <pageNumber>` — jump to a specific page (use the page number from the ledger's page column). Check the Page flow section for current page order.\n- `JUMP TO END` — end the form early (jump to the default thank you page). If a custom thank you page exists, it will target that page instead.\n- `CALCULATE <calcFieldUuid> = <expression>` — assign a formula expression to a calculated field. See <calculated_fields> below.\n- `DISABLE SUBMISSION` — hide the submit button so the form can't be submitted while the condition holds (eligibility gate). Takes no target.\n- Multiple actions: `SHOW <questionUuid>, REQUIRE <questionUuid>`\n</actions>\n\n<calculated_fields>\nGroup calc field writes that share a condition into one rule's THEN clause; only split into separate rules when the conditions differ (e.g., per-event accumulators).\n\n- **Target** (left of `=`): the UUID of a calculated field from a `CALCULATED_FIELDS` block. The ledger lists them in the properties column as `<calcFieldUuid>=<name>(<TYPE>)` — use the UUID. Create the block via create_blocks before writing CALCULATE rules.\n- **Expression** (right of `=`): `+ - * /` for NUMBER, `+` only for TEXT concat. Parens for precedence. Number and string literals allowed. Field refs are bare uuids – questionUuid for inputs, the calc field's own uuid (properties column) for cross-calc / self-reference. No blockUuid, no `{{ }}`, no functions.\n- **Choice fields**: a Dropdown/MultipleChoice/Checkboxes/MultiSelect questionUuid contributes its selected option's label as a number when the labels are numeric (e.g. options `\"10\"`, `\"25\"`); multi-value selections contribute the sum of the selected labels. Ranking fields are not numeric.\n- **Multiple writes per rule**: a single `THEN` can contain any number of CALCULATEs (and other actions). Comma-separated.\n- **Sequential evaluation**: CALCULATEs run top-to-bottom — each reads values left by earlier rules. Place dependent CALCULATEs in dependency order (e.g. compute `subtotal` before `tax`), or group them under one THEN to lock the order.\n- **Defaults**: NUMBER calc fields start at 0, TEXT at `\"\"` when no `value` is set on the field.\n- **Constants on the field, not in rules**: For values that never change (e.g. `taxRate = 0.21`, `greeting = \"Hi \"`), set `value` on the calc field at creation time via create_blocks. Don't write a CALCULATE rule whose right-hand side is just a literal — CALCULATE is for expressions with field references.\n- **Calc fields are never empty** – they always carry the default (0 or `\"\"`). IS [NOT] EMPTY on a calc field is rejected. To gate a calculation on user input completion, use IS NOT EMPTY on the INPUT field driving the calc (not on the calc itself). To check the calc value, use a numeric comparison (`> 0`, `!= 0`) for NUMBER or `IS` / `IS NOT` for TEXT — but only when the default specifically means \"not yet answered\" (e.g. quiz score), not when 0 / `\"\"` is a legitimate result (e.g. an opt-out fee).\n- **Self-reference works** — the target can appear in its own expression. Use this for accumulators (quiz scoring, running totals) instead of creating per-question intermediate fields.\n- **No cycles between calc fields** — if rule A writes `<X>` using `<Y>`, no other rule should write `<Y>` using `<X>`. Cycles produce stale values, not an error.\n\nExample patterns (replace `<...Uuid>` with real UUIDs from the ledger):\n<example>WHEN <priceUuid> IS NOT EMPTY THEN CALCULATE <totalUuid> = <priceUuid> * <qtyUuid></example>\n<example>WHEN <amountUuid> > 100 THEN CALCULATE <discountUuid> = <amountUuid> * 0.1</example>\n<example>Plan dropdown with numeric price labels (\"10\", \"25\", \"50\") drives a total:\nWHEN <planUuid> IS NOT EMPTY THEN CALCULATE <monthlyTotalUuid> = <planUuid> * <seatsUuid></example>\n<example>Add-on checkboxes with numeric price labels sum their checked options:\nWHEN <addOnsUuid> IS NOT EMPTY THEN CALCULATE <totalUuid> = <basePriceUuid> + <addOnsUuid></example>\n<example>WHEN <firstUuid> IS NOT EMPTY THEN CALCULATE <greetingUuid> = \"Hello \" + <firstUuid> + \" \" + <lastUuid></example>\n<example>\nMulti-step under one condition — derive subtotal, tax, and total in a single rule:\nWHEN <priceUuid> IS NOT EMPTY THEN CALCULATE <subtotalUuid> = <priceUuid> * <qtyUuid>, CALCULATE <taxUuid> = <subtotalUuid> * 0.21, CALCULATE <totalUuid> = <subtotalUuid> + <taxUuid>\n</example>\n<example>\nAccumulator — one rule per event because the WHEN differs (quiz: +1 per correct answer):\nWHEN <q1Uuid> IS <correct1Uuid> THEN CALCULATE <scoreUuid> = <scoreUuid> + 1\nWHEN <q2Uuid> IS <correct2Uuid> THEN CALCULATE <scoreUuid> = <scoreUuid> + 1\n</example>\n</calculated_fields>\n\n<defaults>\nThe tool handles these — do NOT do them manually:\n- SHOW auto-hides the target (isHidden: true). Do NOT call configure_blocks to hide it first.\n- REQUIRE auto-marks the target optional (isRequired: false). Do NOT call configure_blocks to unset it first.\n</defaults>\n\n<no_if_else>\nThere is no if-else — do NOT add HIDE as the \"else\" for a SHOW rule. Logic rules are NOT if-else. All SHOW targets start hidden by default. When a SHOW condition is false, the target simply stays hidden — no HIDE needed.\n\n<example>\nWRONG — adds useless HIDE actions:\n  WHEN score <= 6 THEN SHOW feedback, HIDE review\n  WHEN score >= 9 THEN SHOW review, HIDE feedback\nRIGHT — each rule only SHOWs its target:\n  WHEN score <= 6 THEN SHOW feedback\n  WHEN score >= 9 THEN SHOW review\n</example>\n\nThe HIDE in the wrong example is a no-op:\n- fields that are marked as SHOW are automatically hidden by default\n- fields that are marked as REQUIRE are automatically optional by default\n</no_if_else>\n\n<verb_matches_user>\nMatch the action to the verb the user used. Don't invert by negating the condition.\n- User says \"hide X when Y\" → `WHEN <Y> THEN HIDE <X>` (target stays visible by default).\n- User says \"show X when Y\" → `WHEN <Y> THEN SHOW <X>` (target hidden by default, revealed when condition fires).\n\n<example>\nUser: \"Hide the company name field when the role is Student\"\nWRONG — inverted into SHOW + negated condition:\n  WHEN role IS Professional THEN SHOW companyName\n  WHEN role IS Academic THEN SHOW companyName\nRIGHT — direct HIDE matching the user's verb:\n  WHEN role IS Student THEN HIDE companyName\n</example>\n</verb_matches_user>",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "operations": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "string",
                    "enum": [
                      "update"
                    ]
                  },
                  "blockUuid": {
                    "type": "string"
                  },
                  "dsl": {
                    "type": "string"
                  }
                },
                "required": [
                  "operation",
                  "blockUuid",
                  "dsl"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "string",
                    "enum": [
                      "insert"
                    ]
                  },
                  "dsl": {
                    "type": "string"
                  }
                },
                "required": [
                  "operation",
                  "dsl"
                ]
              }
            ]
          }
        }
      },
      "required": [
        "operations"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_configure_blocks",
    "description": "Configure block's properties. Use the current form ledger to find blocks and their properties.\n\nIMPORTANT:\n- Those are partial (incremental) updates - only properties you include will be changed\n- Set a property to null to unset it\n- To change the type of a question, use the change_type operation once on ONLY 1 option block in the group. This will change the entire group to that type.\n- To hide entire question, update the TITLE block and all question blocks will be hidden automatically\n- For hidden_fields_settings: provide the complete list of hidden fields (add new, remove by exclusion, rename by keeping UUID and changing name)\n- For calculated_fields_settings: provide the complete list of calculated fields (add/remove/rename/change-value/retype). Keep an existing field's UUID to update it (rename, change type, change value), omit UUID for new entries, exclude an entry to remove it. CALCULATE rules referencing a removed field are auto-cleaned. To remove a single calc field while keeping others, remove_blocks works too — pass that field's UUID directly.\n",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "updates": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "visibility"
                    ]
                  },
                  "isHidden": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "isHidden"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "form_title_settings"
                    ]
                  },
                  "logo": {
                    "type": "string",
                    "nullable": true
                  },
                  "cover": {
                    "type": "string",
                    "nullable": true
                  },
                  "button": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "label"
                    ],
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "image_settings"
                    ]
                  },
                  "caption": {
                    "type": "string",
                    "nullable": true
                  },
                  "link": {
                    "type": "string",
                    "nullable": true
                  },
                  "altText": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "page_break_settings"
                    ]
                  },
                  "name": {
                    "type": "string",
                    "nullable": true
                  },
                  "button": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "label"
                    ],
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "change_type"
                    ]
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "TEXT",
                      "LABEL",
                      "TITLE",
                      "HEADING_1",
                      "HEADING_2",
                      "HEADING_3",
                      "INPUT_TEXT",
                      "TEXTAREA",
                      "INPUT_EMAIL",
                      "INPUT_LINK",
                      "MULTIPLE_CHOICE",
                      "DROPDOWN",
                      "MULTI_SELECT",
                      "CHECKBOXES"
                    ]
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "type"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "input_settings"
                    ]
                  },
                  "isRequired": {
                    "type": "boolean"
                  },
                  "defaultAnswer": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      }
                    ],
                    "nullable": true
                  },
                  "placeholder": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "text_constraints"
                    ]
                  },
                  "minCharacters": {
                    "type": "number",
                    "nullable": true
                  },
                  "maxCharacters": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "number_range"
                    ]
                  },
                  "minNumber": {
                    "type": "number",
                    "nullable": true
                  },
                  "maxNumber": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "number_formatting"
                    ]
                  },
                  "decimalSeparator": {
                    "type": "string",
                    "enum": [
                      ".",
                      ","
                    ]
                  },
                  "thousandsSeparator": {
                    "type": "string",
                    "enum": [
                      ".",
                      ",",
                      " "
                    ],
                    "nullable": true
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "NUMBER",
                      "PERCENT",
                      "US_DOLLAR",
                      "EURO",
                      "POUND",
                      "CUSTOM"
                    ]
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "number_custom_formatting"
                    ]
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "CUSTOM"
                    ]
                  },
                  "prefix": {
                    "type": "string",
                    "nullable": true
                  },
                  "suffix": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "format"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "email_settings"
                    ]
                  },
                  "requireVerification": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "requireVerification"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "phone_settings"
                    ]
                  },
                  "defaultCountryCode": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "date_display"
                    ]
                  },
                  "format": {
                    "type": "string"
                  },
                  "disableDays": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "IN_THE_PAST",
                        "IN_THE_FUTURE",
                        "MONDAYS",
                        "TUESDAYS",
                        "WEDNESDAYS",
                        "THURSDAYS",
                        "FRIDAYS",
                        "SATURDAYS",
                        "SUNDAYS"
                      ]
                    }
                  },
                  "startWeekOn": {
                    "type": "string",
                    "enum": [
                      "0",
                      "1",
                      "2",
                      "3",
                      "4",
                      "5",
                      "6"
                    ]
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "date_restrictions"
                    ]
                  },
                  "afterDate": {
                    "type": "string",
                    "nullable": true
                  },
                  "beforeDate": {
                    "type": "string",
                    "nullable": true
                  },
                  "dateRange": {
                    "type": "object",
                    "properties": {
                      "from": {
                        "type": "string"
                      },
                      "to": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "from",
                      "to"
                    ],
                    "nullable": true
                  },
                  "specificDates": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "choice_behavior"
                    ]
                  },
                  "randomize": {
                    "type": "boolean"
                  },
                  "allowMultiple": {
                    "type": "boolean"
                  },
                  "badgeType": {
                    "type": "string",
                    "enum": [
                      "OFF",
                      "NUMBERS",
                      "LETTERS"
                    ]
                  },
                  "image": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "matrix_settings"
                    ]
                  },
                  "allowMultiple": {
                    "type": "boolean"
                  },
                  "randomizeRows": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "choice_limits"
                    ]
                  },
                  "minChoices": {
                    "type": "number",
                    "nullable": true
                  },
                  "maxChoices": {
                    "type": "number",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "file_settings"
                    ]
                  },
                  "hasMultipleFiles": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "hasMultipleFiles"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "file_limits"
                    ]
                  },
                  "minFiles": {
                    "type": "number",
                    "nullable": true
                  },
                  "maxFiles": {
                    "type": "number",
                    "nullable": true
                  },
                  "maxFileSize": {
                    "type": "number",
                    "nullable": true
                  },
                  "maxFileSizeUnit": {
                    "type": "string",
                    "enum": [
                      "KB",
                      "MB",
                      "GB"
                    ]
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "file_types"
                    ]
                  },
                  "allowedFiles": {
                    "type": "object",
                    "properties": {
                      "image/*": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "video/*": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "audio/*": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "text/*": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "application/*": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "rating_settings"
                    ]
                  },
                  "stars": {
                    "type": "number"
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "stars"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "scale_range"
                    ]
                  },
                  "start": {
                    "type": "number"
                  },
                  "end": {
                    "type": "number"
                  },
                  "step": {
                    "type": "number"
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "start",
                  "end"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "scale_labels"
                    ]
                  },
                  "leftLabel": {
                    "type": "string",
                    "nullable": true
                  },
                  "centerLabel": {
                    "type": "string",
                    "nullable": true
                  },
                  "rightLabel": {
                    "type": "string",
                    "nullable": true
                  }
                },
                "required": [
                  "blockUuid",
                  "operation"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "payment_settings"
                    ]
                  },
                  "amount": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      }
                    ]
                  },
                  "currency": {
                    "type": "string",
                    "enum": [
                      "AED",
                      "AUD",
                      "BGN",
                      "BRL",
                      "CAD",
                      "CHF",
                      "CNY",
                      "CZK",
                      "DKK",
                      "EUR",
                      "GBP",
                      "HKD",
                      "HRK",
                      "HUF",
                      "IDR",
                      "ILS",
                      "INR",
                      "ISK",
                      "JPY",
                      "KRW",
                      "MAD",
                      "MXN",
                      "MYR",
                      "NOK",
                      "NZD",
                      "PHP",
                      "PLN",
                      "RON",
                      "RSD",
                      "RUB",
                      "SAR",
                      "SEK",
                      "SGD",
                      "THB",
                      "TRY",
                      "TWD",
                      "UAH",
                      "USD",
                      "VND",
                      "ZAR"
                    ]
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "amount",
                  "currency"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "signature_settings"
                    ]
                  },
                  "label": {
                    "type": "string"
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "label"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "hidden_fields_settings"
                    ]
                  },
                  "hiddenFields": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "uuid": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name"
                      ]
                    }
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "hiddenFields"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "blockUuid": {
                    "type": "string"
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "calculated_fields_settings"
                    ]
                  },
                  "calculatedFields": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "uuid": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "NUMBER",
                            "TEXT"
                          ]
                        },
                        "value": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        }
                      },
                      "required": [
                        "name",
                        "type"
                      ]
                    }
                  }
                },
                "required": [
                  "blockUuid",
                  "operation",
                  "calculatedFields"
                ]
              }
            ]
          }
        }
      },
      "required": [
        "updates"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_create_blocks",
    "description": "Creates new blocks in the form.\n\nBlocks default structure with examples:\n- Name question: [TITLE, INPUT_TEXT] (short text)\n- Message question: [TITLE, TEXTAREA] (long text)\n- Country question: [TITLE, DROPDOWN_OPTION, DROPDOWN_OPTION, ...] (compact single-select)\n- Interests question: [TITLE, CHECKBOX, CHECKBOX, ...] (multi-select checklist)\n- Satisfaction question: [TITLE, LINEAR_SCALE] (numeric scale with labels)\n- Quality rating: [TITLE, RATING] (star rating)\n- Payment collection: [TITLE, PAYMENT] (collect payment with Stripe)\n- Yes/No question: [TITLE, MULTIPLE_CHOICE_OPTION, MULTIPLE_CHOICE_OPTION] (radio buttons)\n- Skills multi-select: [TITLE, MULTI_SELECT_OPTION, MULTI_SELECT_OPTION, ...] (dropdown multi-select)\n- Priorities ranking: [TITLE, RANKING_OPTION, RANKING_OPTION, ...] (drag to reorder)\n- Matrix table: [TITLE, MATRIX, MATRIX_COLUMN, MATRIX_COLUMN, ..., MATRIX_ROW, MATRIX_ROW, ...] (columns first, then rows)\n- Bot protection: [CAPTCHA] (no TITLE needed)\n- Location detection: [RESPONDENT_COUNTRY] (auto-detects from IP, no TITLE needed)\n- URL tracking: [HIDDEN_FIELDS] (captures query params like ?utm_source=email&campaign=summer, no TITLE needed)\n- Calculated fields: [CALCULATED_FIELDS] (named targets for CALCULATE logic rules, no TITLE needed)\n- New page: [PAGE_BREAK, ...content] (creates a new page with content)\n- New section: [HEADING_2, TEXT, ...content] (creates a new section with content)\n\nPAGE BREAK SEMANTICS:\n- PAGE_BREAK starts a new page\n- All blocks on a page share the same page number in the ledger\n\nIMPORTANT:\n- Append to the end of the form (most common): omit insertAfterBlockUuid entirely.\n- Groups with the same insertAfterBlockUuid = auto-chain groups (only first group uses it, rest chain).\n- All questions are REQUIRED by default. The user sees a required indicator automatically in the UI. If you need to make a question optional, use configure_blocks tool after creating the question.\n\nExamples with ledger:\n# | text    | blockUuid | type            | questionUuid | page | insertAfterBlockUuid_BEFORE | notes\nPAGE 1 ───────────────────────────────────────────────────────────────────────────────────────────────────────\n1 | Contact | aaa       | FORM_TITLE      | -            | 1    | -                           | Form start\n2 | Name    | bbb       | TITLE           | xxx          | 1    | aaa                         | Name question starts\n3 |         | ccc       | INPUT_TEXT      | xxx          | 1    | bbb                         | Name question ends\n4 | Country | ddd       | TITLE           | yyy          | 1    | ccc                         | Country question starts\n5 | US      | eee       | DROPDOWN_OPTION | yyy          | 1    | ddd                         | Country question\n6 | UK      | fff       | DROPDOWN_OPTION | yyy          | 1    | eee                         | Country question ends\nPAGE 2 ───────────────────────────────────────────────────────────────────────────────────────────────────────\n7 |         | ggg       | PAGE_BREAK      | -            | 2    | fff                         | Page break (creates new page)\n8 | Email   | hhh       | TITLE           | zzz          | 2    | ggg                         | Email question starts\n9 |         | iii       | INPUT_EMAIL     | zzz          | 2    | hhh                         | Email question ends\n\nAdd a question at the end of the form:\n// APPEND: omit insertAfterBlockUuid entirely — no need to reference any ledger UUID\n{\"groups\":[{\"blocks\":[{\"type\":\"TITLE\",\"html\":\"Email\"},{\"type\":\"INPUT_EMAIL\"}]}]}\n\nAdd phone after name:\n// AFTER a question: copy the row's \"blockUuid\" you want to insert after (last block of the question)\n{\"groups\":[{\"blocks\":[{\"type\":\"TITLE\",\"html\":\"Phone\"},{\"type\":\"INPUT_PHONE_NUMBER\"}],\"insertAfterBlockUuid\":\"ccc\"}]}\n\nAdd company before country:\n// CRITICAL: BEFORE a question means DIRECTLY BEFORE the question. Use the row immediately preceding the question; there should be NO other rows between!\n// Find \"Country\" in the current form ledger and copy its \"insertAfterBlockUuid_BEFORE\" into insertAfterBlockUuid\n{\"groups\":[{\"blocks\":[{\"type\":\"TITLE\",\"html\":\"Company\"},{\"type\":\"INPUT_TEXT\"}],\"insertAfterBlockUuid\":\"ccc\"}]}\n\nAdd subtitles/descriptions/hints to each question:\n// WITHIN a question: use question's TITLE blockUuid\n// Execute in one atomic tool call: a group per subtitle.\n{\"groups\":[{\"blocks\":[{\"type\":\"TEXT\",\"html\":\"Your full legal name\"}],\"insertAfterBlockUuid\":\"bbb\"},{\"blocks\":[{\"type\":\"TEXT\",\"html\":\"Select your country\"}],\"insertAfterBlockUuid\":\"ddd\"},{\"blocks\":[{\"type\":\"TEXT\",\"html\":\"Your business email\"}],\"insertAfterBlockUuid\":\"hhh\"}]}\n\nAdd welcome text at the top:\n// AT THE TOP: use FORM_TITLE's blockUuid\n{\"groups\":[{\"blocks\":[{\"type\":\"TEXT\",\"html\":\"Welcome!\"}],\"insertAfterBlockUuid\":\"aaa\"}]}\n\nAdd birthdate, birth place and website after name:\n// Execute in one atomic tool call: sequential blocks together in one group.\n{\"groups\":[{\"blocks\":[{\"type\":\"TITLE\",\"html\":\"Birthdate\"},{\"type\":\"INPUT_DATE\"},{\"type\":\"TITLE\",\"html\":\"Birth place\"},{\"type\":\"INPUT_TEXT\"},{\"type\":\"TITLE\",\"html\":\"Website\"},{\"type\":\"INPUT_LINK\"}],\"insertAfterBlockUuid\":\"ccc\"}]}\n\nAdd new Page 1 with welcome text:\n// AT THE TOP: use FORM_TITLE's blockUuid\n{\"groups\":[{\"blocks\":[{\"type\":\"PAGE_BREAK\"},{\"type\":\"TEXT\",\"html\":\"Welcome!\"}],\"insertAfterBlockUuid\":\"aaa\"}]}\n\nAdd page 3 with phone question:\n// After last block on page 2\n{\"groups\":[{\"blocks\":[{\"type\":\"PAGE_BREAK\"},{\"type\":\"TITLE\",\"html\":\"Phone\"},{\"type\":\"INPUT_PHONE_NUMBER\"}],\"insertAfterBlockUuid\":\"iii\"}]}\n\nSplit the first page into two pages after name:\n// Use blockUuid where page should split\n// PAGE_BREAK is the only block in the group, no other blocks allowed\n{\"groups\":[{\"blocks\":[{\"type\":\"PAGE_BREAK\"}],\"insertAfterBlockUuid\":\"ccc\"}]}\n\nAdd hidden fields to capture UTM parameters:\n// Hidden fields capture values from URL query string (e.g., ?utm_source=email&utm_campaign=spring)\n// Can not have a TITLE - these fields are invisible to users\n{\"groups\":[{\"blocks\":[{\"type\":\"HIDDEN_FIELDS\",\"hiddenFields\":[{\"name\":\"utm_source\"},{\"name\":\"utm_campaign\"},{\"name\":\"utm_medium\"}]}],\"insertAfterBlockUuid\":\"iii\"}]}\n\nAdd thank you page with thank you message:\n// Use the last block's blockUuid\n{\"groups\":[{\"blocks\":[{\"type\":\"PAGE_BREAK\",\"isThankYouPage\":true},{\"type\":\"TEXT\",\"html\":\"Thank you for submitting!\"}],\"insertAfterBlockUuid\":\"iii\"}]}\n\nFIELD REFERENCES IN TEXT (Mentions):\nUse {{questionUuid}} or {{Field Title}} in TEXT, TITLE, or HEADING html to display a field's answer dynamically.\nOnly reference existing fields — create the field first, then reference it.\nExample: {\"type\":\"TEXT\",\"html\":\"Hello {{2c1674f6-843d-4fca-bddd-6598f0040ca7}}!\"}\nThis is NOT for default answers — use configure_blocks with defaultAnswer for that.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "groups": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "blocks": {
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "TEXT"
                          ]
                        },
                        "html": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "html"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "TITLE"
                          ]
                        },
                        "html": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "html"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "HEADING_1"
                          ]
                        },
                        "html": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "html"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "HEADING_2"
                          ]
                        },
                        "html": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "html"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "HEADING_3"
                          ]
                        },
                        "html": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "html"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "DIVIDER"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "PAGE_BREAK"
                          ]
                        },
                        "name": {
                          "type": "string",
                          "nullable": true
                        },
                        "isThankYouPage": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "IMAGE"
                          ]
                        },
                        "name": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "caption": {
                          "type": "string"
                        },
                        "link": {
                          "type": "string"
                        },
                        "altText": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "name",
                        "url"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "EMBED"
                          ]
                        },
                        "url": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "url"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "INPUT_TEXT"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "TEXTAREA"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "INPUT_NUMBER"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "INPUT_EMAIL"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "INPUT_PHONE_NUMBER"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "INPUT_DATE"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "INPUT_TIME"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "INPUT_LINK"
                          ]
                        },
                        "placeholder": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "FILE_UPLOAD"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "LINEAR_SCALE"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "RATING"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "SIGNATURE"
                          ]
                        },
                        "label": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "PAYMENT"
                          ]
                        },
                        "currency": {
                          "type": "string",
                          "enum": [
                            "AED",
                            "AUD",
                            "BGN",
                            "BRL",
                            "CAD",
                            "CHF",
                            "CNY",
                            "CZK",
                            "DKK",
                            "EUR",
                            "GBP",
                            "HKD",
                            "HRK",
                            "HUF",
                            "IDR",
                            "ILS",
                            "INR",
                            "ISK",
                            "JPY",
                            "KRW",
                            "MAD",
                            "MXN",
                            "MYR",
                            "NOK",
                            "NZD",
                            "PHP",
                            "PLN",
                            "RON",
                            "RSD",
                            "RUB",
                            "SAR",
                            "SEK",
                            "SGD",
                            "THB",
                            "TRY",
                            "TWD",
                            "UAH",
                            "USD",
                            "VND",
                            "ZAR"
                          ]
                        },
                        "amount": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "CAPTCHA"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "RESPONDENT_COUNTRY"
                          ]
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "HIDDEN_FIELDS"
                          ]
                        },
                        "hiddenFields": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "name"
                            ]
                          }
                        }
                      },
                      "required": [
                        "type",
                        "hiddenFields"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "CALCULATED_FIELDS"
                          ]
                        },
                        "calculatedFields": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "NUMBER",
                                  "TEXT"
                                ]
                              },
                              "value": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "name",
                              "type"
                            ]
                          }
                        }
                      },
                      "required": [
                        "type",
                        "calculatedFields"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "DROPDOWN_OPTION"
                          ]
                        },
                        "text": {
                          "type": "string"
                        },
                        "isOtherOption": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "MULTIPLE_CHOICE_OPTION"
                          ]
                        },
                        "text": {
                          "type": "string"
                        },
                        "isOtherOption": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "CHECKBOX"
                          ]
                        },
                        "text": {
                          "type": "string"
                        },
                        "isOtherOption": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "MULTI_SELECT_OPTION"
                          ]
                        },
                        "text": {
                          "type": "string"
                        },
                        "isOtherOption": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "RANKING_OPTION"
                          ]
                        },
                        "text": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "MATRIX"
                          ]
                        },
                        "allowMultiple": {
                          "type": "boolean"
                        },
                        "randomizeRows": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "MATRIX_COLUMN"
                          ]
                        },
                        "html": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "html"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "MATRIX_ROW"
                          ]
                        },
                        "html": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "html"
                      ]
                    }
                  ]
                }
              },
              "insertAfterBlockUuid": {
                "type": "string"
              }
            },
            "required": [
              "blocks"
            ]
          }
        }
      },
      "required": [
        "groups"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_create_new_form",
    "description": "Create a new form with the specified title and optional styling. This will clear any existing blocks and start fresh. MUST call SaveForm after building the form to publish it.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        },
        "workspaceId": {
          "type": "string"
        },
        "logoUrl": {
          "type": "string"
        },
        "coverImageUrl": {
          "type": "string"
        },
        "submitButtonText": {
          "type": "string"
        }
      },
      "required": [
        "title"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_extract_brand",
    "description": "Extract colors, fonts, and images from a website URL. Use when users want to match their website, copy brand colors, or style forms like an existing site. Automatically extracts primary/accent colors, button styling, and fonts for use with update_styling tool.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "url": {
          "type": "string"
        }
      },
      "required": [
        "url"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_fetch_insights",
    "description": "Fetch form analytics and performance insights. Returns metrics (views, completions, conversion rate), visitor time-series, submission time-series, traffic dimensions (sources, browsers, countries), and question drop-off data. Use the include parameter to request only specific sections.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "formId": {
          "type": "string"
        },
        "period": {
          "type": "string",
          "enum": [
            "today",
            "yesterday",
            "24h",
            "7d",
            "30d",
            "3m",
            "6m",
            "12m",
            "all"
          ]
        },
        "include": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "metrics",
              "visits",
              "submissions",
              "dimensions",
              "drop-off"
            ]
          }
        }
      },
      "required": [
        "formId",
        "period"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_fetch_submissions",
    "description": "Fetch submissions for a form. Returns paginated results with question labels and response data. Use the page parameter to navigate through results when hasMore is true.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "formId": {
          "type": "string"
        },
        "page": {
          "default": 1,
          "type": "number"
        },
        "limit": {
          "default": 50,
          "type": "number"
        },
        "filter": {
          "type": "object",
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "all",
                "completed",
                "partial"
              ]
            },
            "startDate": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "string"
                }
              ]
            },
            "endDate": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "string"
                }
              ]
            }
          }
        }
      },
      "required": [
        "formId"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_inspect_custom_css",
    "description": "Return Tally's CSS selector reference and this form's current custom CSS. Call before writing a value for update_custom_css so you can merge with existing rules instead of overwriting them.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_list_blocks",
    "description": "Retrieve the current form structure as a ledger. The ledger shows all blocks with their UUIDs, types, positions, and properties.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_list_forms",
    "description": "List forms the user has access to. Returns paginated results with form metadata including name, status, submission count, and timestamps. Use the page parameter to navigate through results when hasMore is true. Optionally filter by workspace IDs.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "page": {
          "default": 1,
          "type": "number"
        },
        "limit": {
          "default": 50,
          "type": "number"
        },
        "filter": {
          "type": "object",
          "properties": {
            "workspaceIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_list_resources",
    "description": "List available resources from MCP server 'tally'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_list_workspaces",
    "description": "List all workspaces the user can access. Use before creating a new form to select the target workspace. Selection rules: if only one workspace → use it; if multiple → ask the user which to use; if a personal workspace exists ('My Workspace' or unnamed) you may auto-select it. When presenting the list of workspaces, use a numbered list for easy selection.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_load_form",
    "description": "Load existing form for editing",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "formId": {
          "type": "string"
        }
      },
      "required": [
        "formId"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_move_blocks",
    "description": "Move individual blocks to a new position. Use the current form ledger to find blocks.\n\nIMPORTANT:\n- FORM_TITLE block cannot be moved (must stay at top)\n- To move or swap entire questions, use reposition_questions tool instead\n- To move, swap or reorder entire pages, use reposition_pages tool instead",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "blockUuids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "insertAfterBlockUuid": {
          "type": "string"
        }
      },
      "required": [
        "blockUuids",
        "insertAfterBlockUuid"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_read_resource",
    "description": "Read a resource by URI from MCP server 'tally'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "uri": {
          "type": "string",
          "description": "URI of the resource to read"
        }
      },
      "required": [
        "uri"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_remove_blocks",
    "description": "Remove specific blocks from the form. Use the current form ledger to find blocks. Also accepts the uuid of an individual calculated field or hidden field — in that case only that entry is removed, and the parent block stays unless it becomes empty.\n\nIMPORTANT:\n- Never remove blocks unless the user explicitly asked you to\n- To remove entire questions, use remove_questions tool instead\n- To remove entire pages, use remove_pages tool instead",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "blockUuids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "blockUuids"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_remove_pages",
    "description": "Remove entire pages from the form. Use the current form ledger to find page numbers.\n\nIMPORTANT:\n- Never remove pages unless the user explicitly asked you to\n- Removes all blocks on the page including the PAGE_BREAK\n- To remove individual blocks (TEXT, DIVIDER, etc.), use remove_blocks tool instead",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "pageNumbers": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "required": [
        "pageNumbers"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_remove_questions",
    "description": "Remove entire questions from the form. Use the current form ledger to find questions by their questionUuid.\n\nIMPORTANT:\n- Never remove questions unless the user explicitly asked you to\n- Removes all blocks that belong to the question (TITLE + input/options)\n- To remove individual blocks (TEXT, DIVIDER, etc.), use remove_blocks tool instead",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "questionUuids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "questionUuids"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_reposition_pages",
    "description": "Move, swap, or reorder pages (1-based). Commands: \"move\", \"swap\", \"reorder\". Use move for relocating a single page, swap for exchanging two pages, and reorder for setting the exact final sequence. IMPORTANT: Check the ledger first to see how many pages exist. The form may have only 1 page if no PAGE_BREAK blocks have been added yet.\n\nIMPORTANT:\n- To create new pages, use create_blocks tool instead",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "command": {
          "type": "string",
          "enum": [
            "move",
            "swap",
            "reorder"
          ]
        },
        "currentPageNumber": {
          "type": "number"
        },
        "newPageNumber": {
          "type": "number"
        },
        "pageNumberA": {
          "type": "number"
        },
        "pageNumberB": {
          "type": "number"
        },
        "order": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "required": [
        "command"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_reposition_questions",
    "description": "Move or swap entire questions (including their title and all inputs/options together).\n\nIMPORTANT:\n- This tool moves or swaps COMPLETE questions as a unit (title + all associated inputs/options)\n- To move individual blocks within a question (e.g., move options or reorder options), use move_blocks tool instead\n- To move, swap or reorder entire pages, use reposition_pages tool instead",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "command": {
          "type": "string",
          "enum": [
            "move",
            "swap"
          ]
        },
        "questionUuids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "afterBlockUuid": {
          "type": "string"
        },
        "questionUuidA": {
          "type": "string"
        },
        "questionUuidB": {
          "type": "string"
        }
      },
      "required": [
        "command"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_save_form",
    "description": "Save form changes, always report back to the user with the form URL and if it was published or saved as draft",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "formId": {
          "type": "string"
        },
        "status": {
          "default": "PUBLISHED",
          "type": "string",
          "enum": [
            "BLANK",
            "DRAFT",
            "PUBLISHED",
            "DELETED"
          ]
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_search_documentation",
    "description": "Answer-only search of the Tally Help Center for explicit documentation or product-knowledge questions: how Tally works, whether a capability exists, supported features, limits, or docs links. Never use as a preflight for form edits. Never use for commands that change the current form, including adding or creating blocks, configuring fields, setting defaults, updating settings, adding calculated fields, styling, moving, removing, formatting, or applying logic.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "query": {
          "type": "string"
        },
        "topK": {
          "type": "number"
        }
      },
      "required": [
        "query"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_set_column_layout",
    "description": "Organize blocks into side-by-side columns. Use \"create_column_list\" to create a new column layout with 2+ columns. Use \"create_column\" to add a NEW separate column to an existing layout. Use \"add_to_column\" to add more blocks within the SAME existing column (vertically stacked, not side-by-side). Use \"detach_from_column\" to remove blocks from their column layout. Use \"set_column_ratio\" to adjust column widths.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "layout": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "enum": [
                    "create_column_list"
                  ]
                },
                "columns": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "required": [
                "operation",
                "columns"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "enum": [
                    "create_column"
                  ]
                },
                "insertAfterBlockUuid": {
                  "type": "string"
                },
                "blockUuids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "operation",
                "insertAfterBlockUuid",
                "blockUuids"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "enum": [
                    "add_to_column"
                  ]
                },
                "insertAfterBlockUuid": {
                  "type": "string"
                },
                "blockUuids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "operation",
                "insertAfterBlockUuid",
                "blockUuids"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "enum": [
                    "detach_from_column"
                  ]
                },
                "blockUuids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "operation",
                "blockUuids"
              ]
            },
            {
              "type": "object",
              "properties": {
                "operation": {
                  "type": "string",
                  "enum": [
                    "set_column_ratio"
                  ]
                },
                "columnUuid": {
                  "type": "string"
                },
                "ratio": {
                  "type": "number"
                }
              },
              "required": [
                "operation",
                "columnUuid",
                "ratio"
              ]
            }
          ]
        }
      },
      "required": [
        "layout"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_set_form_title",
    "description": "Set or update the form title (always appears at the top of the form, position can not be changed)",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "title": {
          "type": "string"
        }
      },
      "required": [
        "title"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_update_custom_css",
    "description": "LAST-RESORT custom CSS for effects with no structured equivalent in update_styling: pseudo-states (:hover, :focus, :active), animations, hiding elements, ::placeholder. ALWAYS try update_styling first for colors, fonts, sizes, alignment, borders, padding, and width — those have structured properties. When the form already has custom CSS, call inspect_custom_css first to read and preserve it. Requires Tally Pro.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "css": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      },
      "required": [
        "css",
        "reason"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_update_settings",
    "description": "Update form settings and configuration.\n\nIMPORTANT:\n- selfEmailSubject and respondentEmailSubject support mentions\n- selfEmailBody and respondentEmailBody support rich HTML formatting (bold, italic, underline, colors) and mentions\n\nLINK PREVIEW METADATA:\nThe metaSiteName, metaSiteFaviconUrl, metaTitle, metaDescription, and metaImageUrl fields customize the preview card shown when a form URL is shared in apps like Slack, Discord, iMessage, and social platforms. They do not change the visible form content.\n\nFIELD REFERENCES (Mentions):\nUse {{questionUuid}} or {{Field Title}} to display a field's answer dynamically.\nExample: \"Hello {{2c1674f6-843d-4fca-bddd-6598f0040ca7}}! Thanks for your feedback.\"\n\nSpecial email mentions:\nUse {{allAnswers}} in selfEmailBody, respondentEmailBody to include all submitted question titles and answers.\nExample: \"A new response was submitted. {{allAnswers}}\"\nUse {{id}}, {{respondentId}}, or {{formName}} to include submission metadata in the subject or body.\nExample: \"New submission {{id}} for {{formName}}.\"\n",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "hasProgressBar": {
          "type": "boolean"
        },
        "language": {
          "type": "string",
          "enum": [
            "af",
            "ar",
            "sq",
            "bn",
            "bg",
            "ca",
            "zh-CN",
            "zh-TW",
            "hr",
            "cs",
            "da",
            "nl",
            "en",
            "et",
            "eu",
            "fo",
            "fa",
            "fil",
            "fi",
            "fr",
            "ka",
            "de",
            "kl",
            "el",
            "he",
            "hi",
            "hu",
            "is",
            "id",
            "ga",
            "it",
            "ja",
            "ko",
            "lv",
            "lt",
            "no",
            "ms",
            "mk",
            "pl",
            "pt",
            "pt-BR",
            "ro",
            "ru",
            "sr",
            "si",
            "sk",
            "sl",
            "es",
            "es-MX",
            "sv",
            "ta",
            "th",
            "tr",
            "uk",
            "uz",
            "vi",
            "yo"
          ]
        },
        "direction": {
          "type": "string",
          "enum": [
            "ltr",
            "rtl"
          ]
        },
        "hasPartialSubmissions": {
          "type": "boolean"
        },
        "pageAutoJump": {
          "type": "boolean"
        },
        "saveForLater": {
          "type": "boolean"
        },
        "submissionsDataRetention": {
          "type": "object",
          "properties": {
            "duration": {
              "type": "number"
            },
            "unit": {
              "type": "string",
              "enum": [
                "minute",
                "hour",
                "day",
                "week",
                "month",
                "year"
              ]
            }
          },
          "required": [
            "duration",
            "unit"
          ],
          "nullable": true
        },
        "redirectOnCompletionUrl": {
          "type": "string",
          "nullable": true
        },
        "selfEmail": {
          "type": "object",
          "properties": {
            "to": {
              "type": "string",
              "nullable": true
            },
            "fromName": {
              "type": "string",
              "nullable": true
            },
            "replyTo": {
              "type": "string",
              "nullable": true
            },
            "subject": {
              "type": "string",
              "nullable": true
            },
            "body": {
              "type": "string",
              "nullable": true
            },
            "sendingDomain": {
              "type": "string",
              "nullable": true
            },
            "attachPdf": {
              "type": "boolean"
            }
          },
          "nullable": true
        },
        "respondentEmail": {
          "type": "object",
          "properties": {
            "to": {
              "type": "string",
              "nullable": true
            },
            "fromName": {
              "type": "string",
              "nullable": true
            },
            "replyTo": {
              "type": "string",
              "nullable": true
            },
            "subject": {
              "type": "string",
              "nullable": true
            },
            "body": {
              "type": "string",
              "nullable": true
            },
            "sendingDomain": {
              "type": "string",
              "nullable": true
            },
            "attachPdf": {
              "type": "boolean"
            }
          },
          "nullable": true
        },
        "verifyEmail": {
          "type": "object",
          "properties": {
            "fromName": {
              "type": "string",
              "nullable": true
            },
            "sendingDomain": {
              "type": "string",
              "nullable": true
            }
          },
          "nullable": true
        },
        "submissionsLimit": {
          "type": "number",
          "nullable": true
        },
        "password": {
          "type": "string",
          "nullable": true
        },
        "closeMessage": {
          "type": "object",
          "properties": {
            "title": {
              "type": "string"
            },
            "description": {
              "type": "string"
            }
          },
          "required": [
            "title",
            "description"
          ],
          "nullable": true
        },
        "uniqueSubmissionKey": {
          "type": "string",
          "nullable": true
        },
        "metaSiteName": {
          "type": "string",
          "nullable": true
        },
        "metaSiteFaviconUrl": {
          "type": "string",
          "nullable": true
        },
        "metaTitle": {
          "type": "string",
          "nullable": true
        },
        "metaDescription": {
          "type": "string",
          "nullable": true
        },
        "metaImageUrl": {
          "type": "string",
          "nullable": true
        },
        "isClosed": {
          "type": "boolean"
        },
        "closeAt": {
          "type": "object",
          "properties": {
            "date": {
              "type": "string"
            },
            "timezone": {
              "type": "string"
            },
            "time": {
              "type": "string"
            }
          },
          "required": [
            "date",
            "time"
          ],
          "nullable": true
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_update_styling",
    "description": "Update form styling. Batch ALL desired changes (appearance, advanced) into a single call — do not split per property or call repeatedly across turns. For pseudo-states (:hover, :focus), animations, hiding elements, ::placeholder, or any effect without a structured equivalent here, use the separate update_custom_css tool instead. If any requested properties are unavailable for the current user, the tool drops them and its feedback tells you what to say.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "appearance": {
          "type": "object",
          "properties": {
            "theme": {
              "type": "string",
              "enum": [
                "LIGHT",
                "DARK",
                "CUSTOM"
              ]
            },
            "backgroundColor": {
              "type": "string"
            },
            "textColor": {
              "type": "string"
            },
            "buttonBackgroundColor": {
              "type": "string"
            },
            "buttonTextColor": {
              "type": "string"
            },
            "accentColor": {
              "type": "string"
            },
            "fontFamily": {
              "type": "string"
            },
            "logoUrl": {
              "type": "string"
            },
            "coverImageUrl": {
              "type": "string"
            },
            "submitButtonText": {
              "type": "string"
            }
          }
        },
        "advanced": {
          "type": "object",
          "properties": {
            "pageWidth": {
              "type": "number"
            },
            "baseFontSize": {
              "type": "number"
            },
            "logoWidth": {
              "type": "number"
            },
            "logoHeight": {
              "type": "number"
            },
            "logoBorderRadius": {
              "type": "number"
            },
            "coverHeight": {
              "type": "number"
            },
            "inputWidthMode": {
              "type": "string",
              "enum": [
                "full",
                "fixed"
              ]
            },
            "inputWidth": {
              "type": "number"
            },
            "inputHeight": {
              "type": "number"
            },
            "inputBackground": {
              "type": "string"
            },
            "inputPlaceholder": {
              "type": "string"
            },
            "inputBorder": {
              "type": "string"
            },
            "inputBorderWidth": {
              "type": "number"
            },
            "inputBorderRadius": {
              "type": "number"
            },
            "inputMarginBottom": {
              "type": "number"
            },
            "inputHorizontalPadding": {
              "type": "number"
            },
            "buttonWidthMode": {
              "type": "string",
              "enum": [
                "auto",
                "full",
                "fixed"
              ]
            },
            "buttonWidth": {
              "type": "number"
            },
            "buttonHeight": {
              "type": "number"
            },
            "buttonAlignment": {
              "type": "string",
              "enum": [
                "left",
                "center",
                "right"
              ]
            },
            "buttonFontSize": {
              "type": "number"
            },
            "buttonBorderRadius": {
              "type": "number"
            },
            "buttonVerticalMargin": {
              "type": "number"
            },
            "buttonHorizontalPadding": {
              "type": "number"
            }
          }
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_tally_update_text",
    "description": "Update text/HTML content for blocks in the form. Use the current form ledger to find blocks.\n\nSupports: form title, question titles, text blocks, headings (H1-H3), input placeholders (text/email/phone/date/time/link/number/textarea), and option text (dropdown/multiple choice/checkboxes/multi-select/ranking).\n\nBatch updates: Can update multiple blocks atomically in a single operation.\n\nIMPORTANT:\n- Text blocks (TITLE, TEXT, HEADING) support rich HTML formatting (bold, italic, underline, colors) and mentions\n- Input placeholders and option text automatically strip HTML to plain text (no mentions)\n- Use the \"blockUuid\" from the ledger to identify which blocks to update\n\nFIELD REFERENCES IN TEXT (Mentions):\nUse {{questionUuid}} or {{Field Title}} in TEXT, TITLE, or HEADING html to display a field's answer dynamically.\nExample: \"Hello {{2c1674f6-843d-4fca-bddd-6598f0040ca7}}! Thanks for your feedback.\"\nThis is NOT for default answers — use configure_blocks with defaultAnswer for that.",
    "strict": false,
    "parameters": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "updates": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "blockUuid": {
                "type": "string"
              },
              "html": {
                "type": "string"
              }
            },
            "required": [
              "blockUuid",
              "html"
            ]
          }
        }
      },
      "required": [
        "updates"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_add_saved_address",
    "description": "Create and save a new delivery address for the authenticated user. Requires location coordinates (latitude/longitude) and address details like flat number, building name, and a Google Maps formatted address. For Indian users, contactName and contactNumber should be provided. For international users, these fields can be omitted. After saving, the address will appear in list_saved_addresses and can be selected with select_saved_address.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "HOME",
            "WORK",
            "OTHER"
          ],
          "description": "Address label type"
        },
        "name": {
          "type": "string",
          "description": "Custom label for the address (e.g., \"Mom's place\", \"Office\")"
        },
        "flatDetails": {
          "type": "string",
          "description": "Flat/house number and floor details"
        },
        "buildingName": {
          "type": "string",
          "description": "Building or society name"
        },
        "landmark": {
          "type": "string",
          "description": "Nearby landmark (optional)"
        },
        "latitude": {
          "type": "number",
          "description": "Latitude coordinate of the address"
        },
        "longitude": {
          "type": "number",
          "description": "Longitude coordinate of the address"
        },
        "formattedAddress": {
          "type": "string",
          "description": "Full formatted address (from Google Maps or user description)"
        },
        "shortAddress": {
          "type": "string",
          "description": "Short display address (area, city, state)"
        },
        "contactName": {
          "type": "string",
          "description": "Contact person name for delivery. Required for Indian users, can be omitted for international users."
        },
        "contactNumber": {
          "type": "string",
          "description": "Contact phone number for delivery. Required for Indian users, can be omitted for international users."
        },
        "floor": {
          "type": "string",
          "description": "Floor number (optional)"
        },
        "buildingType": {
          "type": "string",
          "enum": [
            "BUILDING_TYPE_SOCIETY",
            "BUILDING_TYPE_HOUSE",
            "BUILDING_TYPE_OTHERS",
            "BUILDING_TYPE_UNSPECIFIED"
          ],
          "description": "Type of building (defaults to BUILDING_TYPE_SOCIETY)"
        }
      },
      "required": [
        "type",
        "name",
        "flatDetails",
        "buildingName",
        "latitude",
        "longitude",
        "formattedAddress",
        "shortAddress"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_check_payment_status",
    "description": "Check payment status for an order placed via create_online_payment_order. Do NOT call this tool unless instructed by a create_online_payment_order response or a previous check_payment_status response.\n• poll=false (default): Performs a single status check and returns immediately.\n• poll=true: Starts background polling and waits until payment reaches a terminal state (SUCCESS, FAILED, CANCELLED, etc.).\nDo NOT set poll=true unless the response from a previous check_payment_status call explicitly instructs you to do so.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "orderId": {
          "type": "string",
          "description": "The order ID returned by create_online_payment_order. Required."
        },
        "poll": {
          "type": "boolean",
          "description": "When false (default), performs a single status check and returns immediately. When true, starts background polling and waits until payment reaches a terminal state. Do NOT set to true unless explicitly instructed by a previous check_payment_status response.",
          "default": false
        }
      },
      "required": [
        "orderId"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_create_online_payment_order",
    "description": "Place an order via Zepto using an online payment link. Before calling this tool, always call get_payment_methods first to let the user choose their preferred payment method. Requires store context (from get_location_serviceability or select_store). After this tool returns successfully, you MUST call check_payment_status with the returned orderId. Do NOT skip this step.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "confirmOrder": {
          "type": "boolean",
          "description": "Set to false (or omit) initially to generate a cart preview. Only set to true after the user has reviewed the preview and explicitly confirmed."
        },
        "riderTip": {
          "type": "number",
          "description": "Tip for the rider.",
          "default": 0
        },
        "userAddressId": {
          "type": "string",
          "description": "Address ID to associate with the cart."
        },
        "useZeptoCash": {
          "type": "boolean",
          "description": "Whether to apply Zepto Cash to the order.",
          "default": false
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_create_order",
    "description": "Place a COD (Cash on Delivery) order via Zepto order API. IMPORTANT: Before calling this tool, always call get_payment_methods first to let the user choose their preferred payment method. Requires store context (from get_location_serviceability or select_store).",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "confirmOrder": {
          "type": "boolean",
          "description": "Set to false (or omit) initially to generate a cart preview. Only set to true after the user has reviewed the preview and explicitly confirmed."
        },
        "riderTip": {
          "type": "number",
          "description": "Tip for the rider.",
          "default": 0
        },
        "userAddressId": {
          "type": "string",
          "description": "Address ID to associate with the cart."
        },
        "useZeptoCash": {
          "type": "boolean",
          "description": "Whether to apply Zepto Cash to the order.",
          "default": false
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_create_upi_reserve_pay_order",
    "description": "Place an order via Zepto using UPI Reserve Pay (powered by NPCI and Razorpay). The reserve pay balance must fully cover the order total. Before calling this tool, always call get_payment_methods first to verify that reserve pay is available. Requires store context (from get_location_serviceability or select_store). After this tool returns successfully, you MUST call check_payment_status with the returned orderId. Do NOT skip this step.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "confirmOrder": {
          "type": "boolean",
          "description": "Set to false (or omit) initially to generate a cart preview. Only set to true after the user has reviewed the preview and explicitly confirmed."
        },
        "riderTip": {
          "type": "number",
          "description": "Tip for the rider.",
          "default": 0
        },
        "userAddressId": {
          "type": "string",
          "description": "Address ID to associate with the cart."
        },
        "useZeptoCash": {
          "type": "boolean",
          "description": "Whether to apply Zepto Cash to the order.",
          "default": false
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_create_wallet_order",
    "description": "Place an order via Zepto using Zepto Cash (wallet) as the payment method. The wallet must fully cover the order total. Before calling this tool, always call get_payment_methods first to verify that wallet payment is available. Requires store context (from get_location_serviceability or select_store).",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "confirmOrder": {
          "type": "boolean",
          "description": "Set to false (or omit) initially to generate a cart preview. Only set to true after the user has reviewed the preview and explicitly confirmed."
        },
        "riderTip": {
          "type": "number",
          "description": "Tip for the rider.",
          "default": 0
        },
        "userAddressId": {
          "type": "string",
          "description": "Address ID to associate with the cart."
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_get_location_serviceability",
    "description": "Check if Zepto services a location and get nearby store details. Returns store information and serviceability status.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "latitude": {
          "type": "number",
          "description": "Latitude coordinate of the delivery location"
        },
        "longitude": {
          "type": "number",
          "description": "Longitude coordinate of the delivery location"
        }
      },
      "required": [
        "latitude",
        "longitude"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_get_order_detail",
    "description": "Get detailed information about a specific order including items, pricing, and delivery details.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "orderId": {
          "type": "string",
          "description": "Order ID"
        }
      },
      "required": [
        "orderId"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_get_past_order_items",
    "description": "MANDATORY FIRST STEP before any product search. Call this tool BEFORE calling search_products or search_multiple_products.\n\nReturns a list of unique products the user has ordered in their last 30+ orders, sorted by order frequency. Use the EXACT product names from this list as search queries instead of generic terms.\n\nWHEN TO CALL:\n- ALWAYS call this tool first when the user wants to search, order, or add any product to cart\n- Only call once per conversation — after that, reuse the data already in your context\n\nWORKFLOW:\n1. User says \"order me milk\" → call get_past_order_items first\n2. Past orders show \"Amul Gold Milk 500ml\" (ordered 8 times) → use this exact name\n3. Call search_products(query=\"Amul Gold Milk 500ml\") → guaranteed match\n\nReturns: product name, productVariantId, and frequency (number of distinct orders containing that product).",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_get_payment_methods",
    "description": "Get available payment methods for the current cart. Call this before placing an order so the user can choose their preferred payment method. Returns COD and online payment options with availability status.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_get_product_details",
    "description": "Get detailed information about a specific product. Returns comprehensive product details including pricing, availability, specifications, ratings, description, return policy, and seller information.\n\nUse this tool when:\n- User wants to know more about a specific product\n- User asks about product specifications, materials, size, etc.\n- User wants to check product ratings and reviews count\n- User asks about return/exchange policy for a product\n- User needs seller or manufacturer information\n- User wants to see all available information before making a purchase decision\n\nThe product_variant_id can be obtained from search results.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "product_variant_id": {
          "type": "string",
          "description": "The unique identifier for the product variant (UUID format). This ID is returned in search results."
        }
      },
      "required": [
        "product_variant_id"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_get_user_details",
    "description": "Fetch the authenticated user's profile details including name, email, phone number, referral code, account status, and user type. No input parameters required.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_list_order_history",
    "description": "Get list of past orders for the user. Can also be used to fetch order status or order tracking information.\n\nFor ChatGPT Apps: Displays an interactive widget with order history, tracking, and reordering functionality. After the widget loads, guide users to click on orders in the widget to view details or track delivery.\n\nFor Claude CLI/MCP clients: Returns structured order data with order IDs, status, items, and delivery information that can be presented to the user.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "limit": {
          "type": "number",
          "description": "Number of orders to fetch (default: 10)",
          "default": 10
        },
        "pageNumber": {
          "type": "number",
          "description": "Page number for order history pagination (default: 1)",
          "default": 1
        }
      }
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_list_resources",
    "description": "List available resources from MCP server 'zepto'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_list_saved_addresses",
    "description": "List all saved customer addresses for the authenticated user.\n\nFor ChatGPT Apps: Displays an interactive widget with saved addresses and selection functionality. After the widget loads, guide users to click on an address in the widget to select it for delivery.\n\nFor Claude CLI/MCP clients: Returns structured address data with IDs, formatted addresses, and location coordinates. Use select_saved_address tool to set an address for delivery.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_read_resource",
    "description": "Read a resource by URI from MCP server 'zepto'",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "uri": {
          "type": "string",
          "description": "URI of the resource to read"
        }
      },
      "required": [
        "uri"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_search_multiple_products",
    "description": "Use this tool when the user asks for multiple items (e.g. \"diet coke and chips\", \"milk, bread, eggs\"). Search for MULTIPLE different products in parallel. ALWAYS use this tool when the user mentions more than one product.\n\nIMPORTANT — PAST ORDER OPTIMIZATION (do this FIRST):\n- If you have NOT yet called get_past_order_items in this conversation, STOP and call it FIRST before calling this tool\n- If you already have past order data in context from a previous get_past_order_items call, use that data — do NOT call it again\n- For each product the user mentions, check the past order list for a matching product and use the EXACT product name from past orders as the search query\n  (e.g., user says \"milk and bread\" -> past orders have \"Amul Gold Milk 500ml\" and \"Harvest Gold White Bread 400g\" -> queries: [\"Amul Gold Milk 500ml\", \"Harvest Gold White Bread 400g\"])\n- This ensures the user's preferred products appear in search results\n- If no past-order match exists for a product, use the normalized product name as usual\n\nCORE RULE: Never pass raw user text directly into a search tool.\n\nBEFORE CALLING ANY SEARCH TOOL:\n1) Identify user intent (search, order, add-to-cart, browse)\n2) Decide whether the user mentions:\n   - A concrete purchasable product\n   - Multiple different products\n   - A dish, meal, or recipe\n   - A category or collection\n3) Normalize the request into one or more concrete purchasable product names\n\nALWAYS use this tool when the query contains:\n- \"and\" connecting products: \"chips and diet coke\", \"milk and bread\"\n- Commas listing products: \"chips, coke, popcorn\", \"milk, bread, eggs\"\n- Multiple items: \"I need chips and also get me a coke\"\n\nHow to call this tool:\n- \"chips and diet coke\" -> queries: [\"chips\", \"diet coke\"]\n- \"Order milk, bread, and eggs\" -> queries: [\"milk\", \"bread\", \"eggs\"]\n- \"Get me popcorn, nachos, and cola\" -> queries: [\"popcorn\", \"nachos\", \"cola\"]\n\nParse the user's request into individual product terms. Each term becomes a separate search.\nReturns grouped results with separate sections for each query, displayed with headers. Present each section's results as a numbered list.\n\nDISH / RECIPE HANDLING:\n- If the user mentions a dish, meal, or recipe, do NOT search the dish name\n- First resolve the dish into individual ingredients\n- Dish answers must be converted to ingredients and searched via search_multiple_products\n- If variants (veg / chicken / egg) are unclear, default to the most common option and proceed\n- Search each ingredient individually using search_products or include them in queries\n\nAMBIGUITY RULE:\n- Never ask clarification questions\n- If the request is ambiguous or missing details, make a best-effort assumption and proceed\n\nQUALITY RULES:\n- Prefer concrete SKU-level or category-level product names\n- Handle spelling mistakes and informal language\n- If a guess is required, choose the most common/likely interpretation and proceed\n\nFor SINGLE product searches only (e.g., just \"milk\"), use search_products instead.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "queries": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Array of search queries (e.g., [\"chips\", \"diet coke\", \"popcorn\"])"
        },
        "pageNumber": {
          "type": "number",
          "description": "Page number for pagination (default: 0)",
          "default": 0
        }
      },
      "required": [
        "queries"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_search_products",
    "description": "Search for ONE concrete purchasable product in the Zepto catalog. Returns matching products with prices, availability, and details.\n\nIf the user's message lists multiple products (e.g. \"X and Y\", \"A, B, and C\"), use search_multiple_products instead of this tool.\n\nSINGLE PRODUCT ONLY:\n- Use this tool only when the request maps to ONE concrete item\n- Examples: \"milk\", \"basmati rice\", \"biryani masala\"\n- Do NOT use for multiple products like \"chips and coke\" or \"milk, bread, eggs\"\n- For multiple different products, use search_multiple_products instead\n\nIMPORTANT — PAST ORDER OPTIMIZATION (do this FIRST):\n- If you have NOT yet called get_past_order_items in this conversation, STOP and call it FIRST before calling this tool\n- If you already have past order data in context from a previous get_past_order_items call, use that data — do NOT call it again\n- Check the past order list for a matching product and use the EXACT product name from past orders as the search query\n  (e.g., user says \"milk\" -> past orders have \"Amul Gold Milk 500ml\" -> search for \"Amul Gold Milk 500ml\")\n- This ensures the user's preferred product appears in search results\n- If no past-order match exists, proceed with normal search\n\nCORE RULE: Never pass raw user text directly into a search tool.\n\nBEFORE CALLING ANY SEARCH TOOL:\n1) Identify user intent (search, order, add-to-cart, browse)\n2) Decide whether the user mentions:\n   - A concrete purchasable product\n   - Multiple different products\n   - A dish, meal, or recipe\n   - A category or collection\n3) Normalize the request into a concrete purchasable product name\n\nDISH / RECIPE HANDLING:\n- If the user mentions a dish, meal, or recipe, do NOT search the dish name\n- First resolve the dish into individual ingredients\n- Dish answers must be converted to ingredients and searched via search_multiple_products\n- If variants (veg / chicken / egg) are unclear, default to the most common option and proceed\n- Search each ingredient separately with search_products or use search_multiple_products\n\nAMBIGUITY RULE:\n- Never ask clarification questions\n- If the request is ambiguous or missing details, make a best-effort assumption and proceed\n\nQUALITY RULES:\n- Prefer concrete SKU-level or category-level product names\n- Handle spelling mistakes and informal language\n- If a guess is required, choose the most common/likely interpretation and proceed\n\nFor widget-enabled clients: The widget displays product results with add-to-cart functionality.\nFor CLI/API clients: Returns structured product data with prices, availability, and IDs for cart operations. Present search results as a numbered list.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "query": {
          "type": "string",
          "description": "Search query (e.g., \"milk\", \"organic vegetables\", \"bread\")"
        },
        "pageNumber": {
          "type": "number",
          "description": "Page number for pagination (default: 0)",
          "default": 0
        }
      },
      "required": [
        "query"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_select_saved_address",
    "description": "Pick a saved address and automatically set the corresponding store context for future actions.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "addressId": {
          "type": "string",
          "description": "The unique ID of the saved address. Use the ID value returned by list_saved_addresses, NOT the label or index number. Do NOT fabricate or guess this value."
        }
      },
      "required": [
        "addressId"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_select_store",
    "description": "Selects a store for the current session. All subsequent shopping operations will use this store. The store must be obtained from list_all_stores.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "storeId": {
          "type": "string",
          "description": "Store ID from list_all_stores response"
        },
        "latitude": {
          "type": "number",
          "description": "Optional: Latitude for this store location"
        },
        "longitude": {
          "type": "number",
          "description": "Optional: Longitude for this store location"
        }
      },
      "required": [
        "storeId"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_update_cart",
    "description": "Add, update, or remove items from the cart. Persists cart state for the session.\n\nUse this tool when:\n- Adding products to cart (set quantity > 0)\n- Updating quantities of existing items\n- Removing items (set quantity to 0)\n- Syncing cart state from widget interactions (with replaceCart: true)\n\nRequires productVariantId and storeProductId from search_products results.\n\n[SYSTEM NOTE: Product IDs below are for cart operations - show user-friendly product info in your response. SHOW THESE ITEMS IN CHAT.]\nReturns cart items list for review or modification.\n",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "deviceId": {
          "type": "string",
          "description": "Unique device identifier used as a fallback cart key when a transportSessionId is not available."
        },
        "cartItems": {
          "type": "array",
          "minItems": 1,
          "description": "List of cart items to upsert for the device.",
          "items": {
            "type": "object",
            "properties": {
              "productVariantId": {
                "type": "string",
                "description": "Product variant identifier (pvid)."
              },
              "storeProductId": {
                "type": "string",
                "description": "Store product identifier (spid)."
              },
              "quantity": {
                "type": "number",
                "description": "Quantity to set. Use 0 to remove the item.",
                "minimum": 0
              },
              "name": {
                "type": "string",
                "description": "Product name for display purposes."
              },
              "label": {
                "type": "string",
                "description": "Short product label (raw title) for display."
              },
              "price": {
                "type": "number",
                "nullable": true,
                "description": "Selling price in paisa."
              },
              "mrp": {
                "type": "number",
                "nullable": true,
                "description": "Maximum retail price in paisa."
              },
              "imageUrl": {
                "type": "string",
                "nullable": true,
                "description": "Primary product image URL."
              },
              "packSize": {
                "type": "string",
                "nullable": true,
                "description": "Pack size (e.g., \"500ml\", \"1kg\")."
              },
              "availableQuantity": {
                "type": "number",
                "nullable": true,
                "description": "Available stock quantity."
              },
              "isAd": {
                "type": "boolean",
                "description": "Whether this is a sponsored product."
              },
              "variantId": {
                "type": "string",
                "nullable": true,
                "description": "Variant ID (same as productVariantId where available)."
              },
              "cartProductId": {
                "type": "string",
                "nullable": true,
                "description": "Cart product identifier."
              }
            },
            "required": [
              "productVariantId",
              "storeProductId",
              "quantity"
            ]
          }
        },
        "replaceCart": {
          "type": "boolean",
          "description": "If true, replaces the entire cart with the provided items instead of merging. Use this when syncing the complete cart state from the client.",
          "default": false
        }
      },
      "required": [
        "deviceId",
        "cartItems"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_update_drop_zone",
    "description": "Update the delivery drop zone for an address. This tool is REQUIRED before placing an order when the cart response indicates a drop zone selection is needed (event/venue delivery locations).\n\nGUARDRAILS:\n- ONLY call this tool when create_order returns a dropZoneRequired response with available slots. Do NOT call it speculatively.\n- The dropZoneSlot value MUST exactly match one of the slot values returned by create_order in the dropZoneConfig.slots array. Do NOT fabricate or modify slot values.\n- ALWAYS present the full list of available drop zone slots to the user and let them choose. Do NOT auto-select a slot on the user's behalf.\n- The addressId MUST be a valid saved address ID from list_saved_addresses or select_saved_address. Do NOT use fabricated IDs.\n- After a successful update, call create_order again to proceed with order placement. The drop zone update does NOT place the order by itself.\n- If the PATCH call fails, inform the user and do NOT proceed with order placement.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "addressId": {
          "type": "string",
          "description": "Address ID to update. Must be the address ID currently selected for delivery."
        },
        "dropZoneSlot": {
          "type": "string",
          "description": "Selected drop zone value. Must exactly match a value from the dropZoneConfig slots (e.g., \"Hall - 1, Ground Floor\")."
        }
      },
      "required": [
        "dropZoneSlot"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_update_user_name",
    "description": "Updates the authenticated user's full name to complete their registration on Zepto.\n\nWhen to use this tool:\n- Call this tool ONLY after get_user_details has returned isRegistered as false, indicating the user has not yet completed registration.\n- Before calling this tool, you MUST ask the user for their full name. Do not assume or fabricate a name.\n\nBehavior:\n- Sends a PATCH request to update the user's profile with the provided full name.\n- On success, the user is considered registered and can proceed with address selection and shopping.\n\nPrerequisites:\n- The user must be authenticated (valid session with userId).\n- get_user_details must have been called first and returned isRegistered: false.\n\nFollow-up (MANDATORY — do not skip):\n- After a successful name update, you MUST call list_saved_addresses to check if the user has any delivery addresses.\n- If no saved addresses exist, inform the user that a delivery address is required before they can browse or shop on Zepto. Do NOT proceed to search, cart, or order tools without a saved address.\n- If saved addresses exist, call select_saved_address to set the delivery context before any shopping activity.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "fullName": {
          "type": "string",
          "description": "The full name provided by the user. Must be a non-empty string. Ask the user for this value — never generate it yourself."
        }
      },
      "required": [
        "fullName"
      ]
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_view_cart",
    "description": "View current cart contents. Returns all items with productVariantId, storeProductId, and quantity.\n\nFor widget-enabled clients: Displays interactive cart with quantity controls.\nFor CLI/API clients: Returns cart items list for review or modification.\n\nUse this tool when:\n- User wants to see what's in their cart\n- Before checkout to review items\n- To get cart item IDs for update_cart operations",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {}
    }
  },
  {
    "type": "function",
    "name": "mcp_zepto_zepto_shop",
    "description": "Open Zepto shopping experience for groceries and essentials delivery in 10 minutes.\n\n⚠️ MULTIPLE PRODUCTS: When the user asks for more than one product (e.g. \"diet coke and chips\", \"milk, bread, eggs\"), do NOT call this tool with that full string. Call search_multiple_products with a queries array instead (e.g. queries: [\"diet coke\", \"chips\"]) so the widget shows grouped results. zepto_shop with a query is for ONE product only.\n\nFor ChatGPT Apps: Opens a full interactive shopping widget with product search, cart management, address selection, checkout, and order tracking. Once the widget is displayed, all shopping actions are handled through widget interactions.\nSearch results should be presented as numbered lists.\n\nCORE RULE: Never pass raw user text directly into a search tool.\n\nBEFORE CALLING ANY SEARCH TOOL:\n1) Identify user intent (search, order, add-to-cart, browse)\n2) Decide whether the user mentions:\n   - A concrete purchasable product\n   - Multiple different products\n   - A dish, meal, or recipe\n   - A category or collection\n3) Normalize the request into one or more concrete purchasable product names\n\n⚠️ SINGLE PRODUCT ONLY: This tool only searches for ONE product at a time.\n- Use for: \"milk\", \"chips\", \"diet coke\" (single items)\n- DO NOT use for: \"chips and coke\", \"milk, bread, eggs\" (multiple items)\n- For MULTIPLE products: Use search_multiple_products tool instead with queries array.\n  Example: \"chips and diet coke\" → search_multiple_products({queries: [\"chips\", \"diet coke\"]})\n\nDISH / RECIPE HANDLING:\n- If the user mentions a dish, meal, or recipe, do NOT search the dish name\n- First resolve the dish into individual ingredients\n- Dish answers must be converted to ingredients and searched via search_multiple_products\n- If variants (veg / chicken / egg) are unclear, default to the most common option and proceed\n- Search each ingredient separately with search_products or use search_multiple_products\n\nAMBIGUITY RULE:\n- Never ask clarification questions\n- If the request is ambiguous or missing details, make a best-effort assumption and proceed\n\nQUALITY RULES:\n- Prefer concrete SKU-level or category-level product names\n- Handle spelling mistakes and informal language\n- If a guess is required, choose the most common/likely interpretation and proceed\n\nFor Claude CLI/MCP clients: DO NOT use this tool. Instead, use individual tools:\n  - search_products: Search for a single product\n  - search_multiple_products: Search for multiple different products\n  - view_cart: View current cart contents\n  - update_cart: Add/remove items from cart\n  - list_saved_addresses: View delivery addresses\n  - create_order: Place an order\n  - list_order_history: View past orders\n\nUse this tool ONLY when running in ChatGPT Apps with widget support.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "intent": {
          "type": "string",
          "enum": [
            "search",
            "order",
            "browse",
            "cart",
            "orders",
            "addresses"
          ],
          "description": "User intent: \"search\" for product lookup, \"order\" for complete ordering flow, \"browse\" for discovery, \"cart\" to view cart, \"orders\" for order history, \"addresses\" for address management"
        },
        "query": {
          "type": "string",
          "description": "Search query or product name if intent involves search (e.g., \"milk\", \"diet coke\")"
        },
        "quantity": {
          "type": "number",
          "description": "Desired quantity if ordering a specific product (default: 1)",
          "default": 1
        }
      },
      "required": [
        "intent"
      ]
    }
  },
  {
    "type": "function",
    "name": "memory",
    "description": "Save durable facts to persistent memory that survive across sessions. Memory is injected into every future turn, so keep entries compact and high-signal.\n\nHOW: make ALL your changes in ONE call via an 'operations' array (each item: {action, content?, old_text?}). The batch applies atomically and the char limit is checked only on the FINAL result — so a single call can remove/replace stale entries to free room AND add new ones, even when an add alone would overflow. The response reports current/limit chars and confirms completion; one batch call finishes the update, so don't repeat it. Use the bare action/content/old_text fields only for a single lone change.\n\nWHEN: save proactively when the user states a preference, correction, or personal detail, or you learn a stable fact about their environment, conventions, or workflow. Priority: user preferences & corrections > environment facts > procedures. The best memory stops the user repeating themselves.\n\nIF FULL: an add is rejected with the current entries shown. Reissue as ONE batch that removes or shortens enough stale entries and adds the new one together.\n\nTARGETS: 'user' = who the user is (name, role, preferences, style). 'memory' = your notes (environment, conventions, tool quirks, lessons).\n\nSKIP: trivial/obvious info, easily re-discovered facts, raw data dumps, task progress, completed-work logs, temporary TODO state (use session_search for those). Reusable procedures belong in a skill, not memory.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "action": {
          "type": "string",
          "enum": [
            "add",
            "replace",
            "remove"
          ],
          "description": "The action to perform (single-op shape). Omit when using 'operations'."
        },
        "target": {
          "type": "string",
          "enum": [
            "memory",
            "user"
          ],
          "description": "Which memory store: 'memory' for personal notes, 'user' for user profile."
        },
        "content": {
          "type": "string",
          "description": "The entry content. Required for 'add' and 'replace' (single-op shape)."
        },
        "old_text": {
          "type": "string",
          "description": "REQUIRED for 'replace' and 'remove' (single-op shape): a short unique substring identifying the existing entry to modify. Omit only for 'add'."
        },
        "operations": {
          "type": "array",
          "description": "Batch shape: a list of operations applied atomically in one call against the final char budget. Preferred when making multiple changes or consolidating to make room. Each item is {action, content?, old_text?}.",
          "items": {
            "type": "object",
            "properties": {
              "action": {
                "type": "string",
                "enum": [
                  "add",
                  "replace",
                  "remove"
                ]
              },
              "content": {
                "type": "string",
                "description": "Entry content for add/replace."
              },
              "old_text": {
                "type": "string",
                "description": "Substring identifying the entry for replace/remove."
              }
            },
            "required": [
              "action"
            ]
          }
        }
      },
      "required": [
        "target"
      ]
    }
  },
  {
    "type": "function",
    "name": "patch",
    "description": "Targeted find-and-replace edits in files. Use this instead of sed/awk in terminal. Uses fuzzy matching (9 strategies) so minor whitespace/indentation differences won't break it. Returns a unified diff. Auto-runs syntax checks after editing.\n\nREPLACE MODE (mode='replace', default): find a unique string and replace it. REQUIRED PARAMETERS: mode, path, old_string, new_string.\nPATCH MODE (mode='patch'): apply V4A multi-file patches for bulk changes. REQUIRED PARAMETERS: mode, patch.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "replace",
            "patch"
          ],
          "description": "Edit mode. 'replace' (default): requires path + old_string + new_string. 'patch': requires patch content only.",
          "default": "replace"
        },
        "path": {
          "type": "string",
          "description": "REQUIRED when mode='replace'. File path to edit."
        },
        "old_string": {
          "type": "string",
          "description": "REQUIRED when mode='replace'. Exact text to find and replace. Must be unique in the file unless replace_all=true. Include surrounding context lines to ensure uniqueness."
        },
        "new_string": {
          "type": "string",
          "description": "REQUIRED when mode='replace'. Replacement text. Pass empty string '' to delete the matched text."
        },
        "replace_all": {
          "type": "boolean",
          "description": "Replace all occurrences instead of requiring a unique match (default: false)",
          "default": false
        },
        "patch": {
          "type": "string",
          "description": "REQUIRED when mode='patch'. V4A format patch content. Format:\n*** Begin Patch\n*** Update File: path/to/file\n@@ context hint @@\n context line\n-removed line\n+added line\n*** End Patch"
        },
        "cross_profile": {
          "type": "boolean",
          "description": "Opt out of the cross-profile soft guard. Defaults to false. Set true ONLY after explicit user direction to edit another Hermes profile's skills/plugins/cron/memories.",
          "default": false
        }
      },
      "required": [
        "mode"
      ]
    }
  },
  {
    "type": "function",
    "name": "process",
    "description": "Manage background processes started with terminal(background=true). Actions: 'list' (show all), 'poll' (check status + new output), 'log' (full output with pagination), 'wait' (block until done or timeout), 'kill' (terminate), 'write' (send raw stdin data without newline), 'submit' (send data + Enter, for answering prompts), 'close' (close stdin/send EOF).",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "action": {
          "type": "string",
          "enum": [
            "list",
            "poll",
            "log",
            "wait",
            "kill",
            "write",
            "submit",
            "close"
          ],
          "description": "Action to perform on background processes"
        },
        "session_id": {
          "type": "string",
          "description": "Process session ID (from terminal background output). Required for all actions except 'list'."
        },
        "data": {
          "type": "string",
          "description": "Text to send to process stdin (for 'write' and 'submit' actions)"
        },
        "timeout": {
          "type": "integer",
          "description": "Max seconds to block for 'wait' action. Returns partial output on timeout.",
          "minimum": 1
        },
        "offset": {
          "type": "integer",
          "description": "Line offset for 'log' action (default: last 200 lines)"
        },
        "limit": {
          "type": "integer",
          "description": "Max lines to return for 'log' action",
          "minimum": 1
        }
      },
      "required": [
        "action"
      ]
    }
  },
  {
    "type": "function",
    "name": "read_file",
    "description": "Read a text file with line numbers and pagination. Use this instead of cat/head/tail in terminal. Output format: 'LINE_NUM|CONTENT'. Suggests similar filenames if not found. Use offset and limit for large files. Reads exceeding ~100K characters are rejected; use offset and limit to read specific sections of large files. Jupyter notebooks (.ipynb), Word documents (.docx), and Excel workbooks (.xlsx) are auto-extracted to readable text. NOTE: Cannot read images or other binary files — use vision_analyze for images.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "path": {
          "type": "string",
          "description": "Path to the file to read (absolute, relative, or ~/path)"
        },
        "offset": {
          "type": "integer",
          "description": "Line number to start reading from (1-indexed, default: 1)",
          "default": 1,
          "minimum": 1
        },
        "limit": {
          "type": "integer",
          "description": "Maximum number of lines to read (default: 500, max: 2000)",
          "default": 500,
          "maximum": 2000
        }
      },
      "required": [
        "path"
      ]
    }
  },
  {
    "type": "function",
    "name": "search_files",
    "description": "Search file contents or find files by name. Use this instead of grep/rg/find/ls in terminal. Ripgrep-backed, faster than shell equivalents.\n\nContent search (target='content'): Regex search inside files. Output modes: full matches with line numbers, file paths only, or match counts.\n\nFile search (target='files'): Find files by glob pattern (e.g., '*.py', '*config*'). Also use this instead of ls — results sorted by modification time.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "pattern": {
          "type": "string",
          "description": "Regex pattern for content search, or glob pattern (e.g., '*.py') for file search"
        },
        "target": {
          "type": "string",
          "enum": [
            "content",
            "files"
          ],
          "description": "'content' searches inside file contents, 'files' searches for files by name",
          "default": "content"
        },
        "path": {
          "type": "string",
          "description": "Directory or file to search in (default: current working directory)",
          "default": "."
        },
        "file_glob": {
          "type": "string",
          "description": "Filter files by pattern in grep mode (e.g., '*.py' to only search Python files)"
        },
        "limit": {
          "type": "integer",
          "description": "Maximum number of results to return (default: 50)",
          "default": 50
        },
        "offset": {
          "type": "integer",
          "description": "Skip first N results for pagination (default: 0)",
          "default": 0
        },
        "output_mode": {
          "type": "string",
          "enum": [
            "content",
            "files_only",
            "count"
          ],
          "description": "Output format for grep mode: 'content' shows matching lines with line numbers, 'files_only' lists file paths, 'count' shows match counts per file",
          "default": "content"
        },
        "context": {
          "type": "integer",
          "description": "Number of context lines before and after each match (grep mode only)",
          "default": 0
        }
      },
      "required": [
        "pattern"
      ]
    }
  },
  {
    "type": "function",
    "name": "session_search",
    "description": "Search past sessions stored in the local session DB, or scroll inside one. FTS5-backed retrieval over the SQLite message store. No LLM calls — every shape returns actual messages from the DB.\n\nSOURCE-FIRST LIMIT\n\n  This tool searches Hermes conversation history only. It is not evidence about the current contents of external sources. If the user provided a direct source such as a URL, phone number/contact, app/thread, file path, account, website, or live system, inspect that original source before or instead of session_search when accessible. Use session_search as secondary context for what was previously said, not as primary proof of what the source currently contains. If the original source is inaccessible, say so and why before falling back to session history. Do not conclude 'not found' or 'no prior correspondence' from session_search alone when a direct source was provided.\n\nFOUR CALLING SHAPES\n\n  1) DISCOVERY — pass `query`:\n     session_search(query=\"auth refactor\", limit=3)\n     Runs FTS5, dedupes hits by session lineage, returns the top N sessions. Each result carries:\n       - session_id, title, when, source\n       - snippet: FTS5-highlighted match excerpt\n       - bookend_start: first 3 user+assistant messages of the session (the goal / kickoff)\n       - messages: ±5 messages around the FTS5 match, with the anchor message flagged (the hit in context)\n       - bookend_end: last 3 user+assistant messages of the session (the resolution / decisions)\n       - match_message_id, messages_before, messages_after\n     Bookends + window together let you reconstruct goal → match → resolution without paying for the whole transcript.\n\n  2) SCROLL — pass `session_id` + `around_message_id`:\n     session_search(session_id=\"...\", around_message_id=12345, window=10)\n     Returns a window of ±`window` messages centered on the anchor. No FTS5, no bookends — just the slice. Use after a discovery call when you need more context than the ±5 default window.\n       - To scroll FORWARD: pass messages[-1].id back as around_message_id.\n       - To scroll BACKWARD: pass messages[0].id back as around_message_id.\n       - The boundary message appears in both windows — orientation marker.\n       - When messages_before or messages_after is < window, you're at the start or end of the session.\n\n  3) READ — pass `session_id` only (no around_message_id):\n     session_search(session_id=\"...\", profile=\"work\")\n     Dumps the whole session by id (first 20 + last 10 messages when large). This is how you resolve an `@session:<profile>/<id>` link the user dropped into the chat: split the value on `/` into profile + id and call session_search(session_id=id, profile=profile).\n\n  4) BROWSE — no args:\n     session_search()\n     Returns recent sessions chronologically: titles, previews, timestamps. Use when the user asks \"what was I working on\" without naming a topic.\n\nFTS5 SYNTAX\n\n  AND is the default — multi-word queries require all terms. Use OR explicitly for broader recall (`alpha OR beta OR gamma`), quoted phrases for exact match (`\"docker networking\"`), boolean (`python NOT java`), or prefix wildcards (`deploy*`).\n\nWHEN TO USE\n\n  Reach for this on questions about Hermes conversation history itself, such as \"what did we do about X\", \"where did we leave Y\", or \"find the session where Z\". If the user provided a direct source identifier, inspect that source first when accessible; session_search can then supply historical context. The session DB carries what was said when; external tools show current source/world state.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "query": {
          "type": "string",
          "description": "Search query (discovery shape). Keywords, phrases, or boolean expressions to find in past sessions. Omit to browse recent sessions. Ignored when session_id + around_message_id are set (scroll shape)."
        },
        "limit": {
          "type": "integer",
          "description": "Discovery shape only. Max sessions to return (default 3, max 10). Bump to 5–10 when the topic likely spans several sessions and you want to pick the right one to scroll into.",
          "default": 3
        },
        "sort": {
          "type": "string",
          "enum": [
            "newest",
            "oldest"
          ],
          "description": "Discovery shape only. Temporal bias on top of FTS5 ranking. Omit to keep relevance-only ordering (suitable for exploratory recall — \"what do we know about X\"). Set 'newest' for recency-shaped questions (\"where did we leave X\"). Set 'oldest' for origin-shaped questions (\"how did X start\"). Ignored in scroll and browse shapes."
        },
        "session_id": {
          "type": "string",
          "description": "Scroll shape. Session to read inside. Use the session_id returned from a prior discovery call. Must be paired with around_message_id."
        },
        "around_message_id": {
          "type": "integer",
          "description": "Scroll shape. Message id to center the window on. From a discovery result use match_message_id, or any id seen in a prior window. To scroll forward pass the last window message's id; to scroll backward pass the first."
        },
        "window": {
          "type": "integer",
          "description": "Scroll shape only. Messages to return on each side of the anchor (anchor itself always included). Clamped to [1, 20]. Default 5.",
          "default": 5
        },
        "role_filter": {
          "type": "string",
          "description": "Optional. Comma-separated roles to include. Discovery defaults to 'user,assistant' (tool output is usually noise). Pass 'user,assistant,tool' to include tool output (debugging tool behaviour) or 'tool' to search tool output only."
        },
        "profile": {
          "type": "string",
          "description": "Optional. Read sessions from another Hermes profile's database (read-only). Use when resolving an `@session:<profile>/<id>` link: pass the profile segment here with session_id as the id segment. Omit to use the current profile."
        }
      }
    }
  },
  {
    "type": "function",
    "name": "skill_manage",
    "description": "Manage skills (create, update, delete). Skills are your procedural memory — reusable approaches for recurring task types. New skills go to ~/.hermes/skills/; existing skills can be modified wherever they live.\n\nActions: create (full SKILL.md + optional category), patch (old_string/new_string — preferred for fixes), edit (full SKILL.md rewrite — major overhauls only), delete, write_file, remove_file.\n\nOn delete, pass `absorbed_into=<umbrella>` when you're merging this skill's content into another one, or `absorbed_into=\"\"` when you're pruning it with no forwarding target. This lets the curator tell consolidation from pruning without guessing, so downstream consumers (cron jobs that reference the old skill name, etc.) get updated correctly. The target you name in `absorbed_into` must already exist — create/patch the umbrella first, then delete.\n\nCreate when: complex task succeeded (5+ calls), errors overcome, user-corrected approach worked, non-trivial workflow discovered, or user asks you to remember a procedure.\nUpdate when: instructions stale/wrong, OS-specific failures, missing steps or pitfalls found during use. If you used a skill and hit issues not covered by it, patch it immediately.\n\nAfter difficult/iterative tasks, offer to save as a skill. Skip for simple one-offs. Confirm with user before creating/deleting.\n\nGood skills: trigger conditions, numbered steps with exact commands, pitfalls section, verification steps. Use skill_view() to see format examples.\n\nPinned skills are protected from deletion only — skill_manage(action='delete') will refuse with a message pointing the user to `hermes curator unpin <name>`. Patches and edits go through on pinned skills so you can still improve them as pitfalls come up; pin only guards against irrecoverable loss.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "action": {
          "type": "string",
          "enum": [
            "create",
            "patch",
            "edit",
            "delete",
            "write_file",
            "remove_file"
          ],
          "description": "The action to perform."
        },
        "name": {
          "type": "string",
          "description": "Skill name (lowercase, hyphens/underscores, max 64 chars). Must match an existing skill for patch/edit/delete/write_file/remove_file."
        },
        "content": {
          "type": "string",
          "description": "Full SKILL.md content (YAML frontmatter + markdown body). Required for 'create' and 'edit'. For 'edit', read the skill first with skill_view() and provide the complete updated text."
        },
        "old_string": {
          "type": "string",
          "description": "Text to find in the file (required for 'patch'). Must be unique unless replace_all=true. Include enough surrounding context to ensure uniqueness."
        },
        "new_string": {
          "type": "string",
          "description": "Replacement text (required for 'patch'). Can be empty string to delete the matched text."
        },
        "replace_all": {
          "type": "boolean",
          "description": "For 'patch': replace all occurrences instead of requiring a unique match (default: false)."
        },
        "category": {
          "type": "string",
          "description": "Optional category/domain for organizing the skill (e.g., 'devops', 'data-science', 'mlops'). Creates a subdirectory grouping. Only used with 'create'."
        },
        "file_path": {
          "type": "string",
          "description": "Path to a supporting file within the skill directory. For 'write_file'/'remove_file': required, must be under references/, templates/, scripts/, or assets/. For 'patch': optional, defaults to SKILL.md if omitted."
        },
        "file_content": {
          "type": "string",
          "description": "Content for the file. Required for 'write_file'."
        },
        "absorbed_into": {
          "type": "string",
          "description": "For 'delete' only — declares intent so the curator can tell consolidation from pruning without guessing. Pass the umbrella skill name when this skill's content was merged into another (the target must already exist). Pass an empty string when the skill is truly stale and being pruned with no forwarding target. Omitting the arg on delete is supported for backward compatibility but downstream tooling (e.g. cron-job skill reference rewriting) will have to guess at intent."
        }
      },
      "required": [
        "action",
        "name"
      ]
    }
  },
  {
    "type": "function",
    "name": "skill_view",
    "description": "Skills allow for loading information about specific tasks and workflows, as well as scripts and templates. Load a skill's full content or access its linked files (references, templates, scripts). First call returns SKILL.md content plus a 'linked_files' dict showing available references/templates/scripts. To access those, call again with file_path parameter.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The skill name (use skills_list to see available skills). For plugin-provided skills, use the qualified form 'plugin:skill' (e.g. 'superpowers:writing-plans')."
        },
        "file_path": {
          "type": "string",
          "description": "OPTIONAL: Path to a linked file within the skill (e.g., 'references/api.md', 'templates/config.yaml', 'scripts/validate.py'). Omit to get the main SKILL.md content."
        }
      },
      "required": [
        "name"
      ]
    }
  },
  {
    "type": "function",
    "name": "skills_list",
    "description": "List available skills (name + description). Use skill_view(name) to load full content.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "category": {
          "type": "string",
          "description": "Optional category filter to narrow results"
        }
      }
    }
  },
  {
    "type": "function",
    "name": "terminal",
    "description": "Execute shell commands on a Linux environment. Filesystem, current working directory, and exported environment variables persist between calls.\n\nDo NOT use cat/head/tail to read files — use read_file instead.\nDo NOT use grep/rg/find to search — use search_files instead.\nDo NOT use ls to list directories — use search_files(target='files') instead.\nDo NOT use sed/awk to edit files — use patch instead.\nDo NOT use echo/cat heredoc to create files — use write_file instead.\nReserve terminal for: builds, installs, git, processes, scripts, network, package managers, and anything that needs a shell.\nBecause exported environment state persists, activate a virtualenv or export setup variables once per session; do not re-source the same environment before every command unless a command proves the shell state was reset.\n\nForeground (default): Commands return INSTANTLY when done, even if the timeout is high. Set timeout=300 for long builds/scripts — you'll still get the result in seconds if it's fast. Prefer foreground for short commands.\nBackground: Set background=true to get a session_id. Almost always pair with notify_on_complete=true — bg without notify runs SILENTLY and you have no way to learn it finished short of calling process(action='poll') yourself. Two legitimate uses:\n  (1) Long-lived processes that never exit (servers, watchers, daemons) — silent is correct, there's no exit to notify on.\n  (2) Long-running bounded tasks (tests, builds, deploys, CI pollers, batch jobs) — MUST set notify_on_complete=true. Without it you'll either forget to poll or sit blocked waiting for the user to surface the result.\nFor servers/watchers, do NOT use shell-level background wrappers (nohup/disown/setsid/trailing '&') in foreground mode. Use background=true so Hermes can track lifecycle and output.\nAfter starting a server, verify readiness with a health check or log signal, then run tests in a separate terminal() call. Avoid blind sleep loops.\nUse process(action=\"poll\") for progress checks, process(action=\"wait\") to block until done.\nWorking directory: Use 'workdir' for per-command cwd.\nPTY mode: Set pty=true for interactive CLI tools (Codex, Claude Code, Python REPL).\n\nDo NOT use vim/nano/interactive tools without pty=true — they hang without a pseudo-terminal. Pipe git output to cat if it might page.\n",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "command": {
          "type": "string",
          "description": "The command to execute on the VM"
        },
        "background": {
          "type": "boolean",
          "description": "Run the command in the background. Almost always pair with notify_on_complete=true — without it, the process runs silently and you'll have no way to learn it finished short of calling process(action='poll') yourself (easy to forget, leading to silent blindness on long jobs). Two legitimate patterns: (1) Long-lived processes that never exit (servers, watchers, daemons) — these stay silent because there's no exit to notify on. (2) Long-running bounded tasks (tests, builds, deploys, CI pollers, batch jobs) — these MUST set notify_on_complete=true. For short commands, prefer foreground with a generous timeout instead.",
          "default": false
        },
        "timeout": {
          "type": "integer",
          "description": "Max seconds to wait (default: 180, foreground max: 600). Returns INSTANTLY when command finishes — set high for long tasks, you won't wait unnecessarily. Foreground timeout above 600s is rejected; use background=true for longer commands.",
          "minimum": 1
        },
        "workdir": {
          "type": "string",
          "description": "Working directory for this command (absolute path). Defaults to the session working directory."
        },
        "pty": {
          "type": "boolean",
          "description": "Run in pseudo-terminal (PTY) mode for interactive CLI tools like Codex, Claude Code, or Python REPL. Only works with local and SSH backends. Default: false.",
          "default": false
        },
        "notify_on_complete": {
          "type": "boolean",
          "description": "When true (and background=true), you'll be automatically notified exactly once when the process finishes. **This is the right choice for almost every long-running task** — tests, builds, deployments, multi-item batch jobs, anything that takes over a minute and has a defined end. Use this and keep working on other things; the system notifies you on exit. MUTUALLY EXCLUSIVE with watch_patterns — when both are set, watch_patterns is dropped.",
          "default": false
        },
        "watch_patterns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Strings to watch for in background process output. HARD RATE LIMIT: at most 1 notification per 15 seconds per process — matches arriving inside the cooldown are dropped. After 3 consecutive 15-second windows with dropped matches, watch_patterns is automatically disabled for that process and promoted to notify_on_complete behavior (one notification on exit, no more mid-process spam). USE ONLY for truly rare, one-shot mid-process signals on LONG-LIVED processes that will never exit on their own — e.g. ['Application startup complete'] on a server so you know when to hit its endpoint, or ['migration done'] on a daemon. DO NOT use for: (1) end-of-run markers like 'DONE'/'PASS' — use notify_on_complete instead; (2) error patterns like 'ERROR'/'Traceback' in loops or multi-item batch jobs — they fire on every iteration and you'll hit the strike limit fast; (3) anything you'd ever combine with notify_on_complete. When in doubt, choose notify_on_complete. MUTUALLY EXCLUSIVE with notify_on_complete — set one, not both."
        }
      },
      "required": [
        "command"
      ]
    }
  },
  {
    "type": "function",
    "name": "text_to_speech",
    "description": "Convert text to speech audio. Returns a MEDIA: path that the platform delivers as native audio. Compatible providers render as a voice bubble on Telegram; otherwise audio is sent as a regular attachment. In CLI mode, saves to ~/voice-memos/. Voice and provider are user-configured (built-in providers like edge/openai or custom command providers under tts.providers.<name>), not model-selected.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string",
          "description": "The text to convert to speech. Provider-specific character caps apply and are enforced automatically (OpenAI 4096, xAI 15000, MiniMax 10000, ElevenLabs 5k-40k depending on model); over-long input is truncated."
        },
        "output_path": {
          "type": "string",
          "description": "Optional custom file path to save the audio. Defaults to ~/.hermes/audio_cache/<timestamp>.mp3"
        }
      },
      "required": [
        "text"
      ]
    }
  },
  {
    "type": "function",
    "name": "todo",
    "description": "Manage your task list for the current session. Use for complex tasks with 3+ steps or when the user provides multiple tasks. Call with no parameters to read the current list.\n\nWriting:\n- Provide 'todos' array to create/update items\n- merge=false (default): replace the entire list with a fresh plan\n- merge=true: update existing items by id, add any new ones\n\nEach item: {id: string, content: string, status: pending|in_progress|completed|cancelled}\nList order is priority. Only ONE item in_progress at a time.\nMark items completed immediately when done. If something fails, cancel it and add a revised item.\n\nAlways returns the full current list.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "todos": {
          "type": "array",
          "description": "Task items to write. Omit to read current list.",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Unique item identifier"
              },
              "content": {
                "type": "string",
                "description": "Task description"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "in_progress",
                  "completed",
                  "cancelled"
                ],
                "description": "Current status"
              }
            },
            "required": [
              "id",
              "content",
              "status"
            ]
          }
        },
        "merge": {
          "type": "boolean",
          "description": "true: update existing items by id, add new ones. false (default): replace the entire list.",
          "default": false
        }
      }
    }
  },
  {
    "type": "function",
    "name": "vision_analyze",
    "description": "Load an image into the conversation so you can see it. Accepts a URL, local file path, or data URL. When your active model has native vision, the image is attached to your context directly and you read the pixels yourself on the next turn — call this any time the user references an image (filepath in their message, URL in tool output, screenshot from the browser, etc.). For non-vision models, falls back to an auxiliary vision model that returns a text description.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "image_url": {
          "type": "string",
          "description": "Image URL (http/https), local file path, or data: URL to load."
        },
        "question": {
          "type": "string",
          "description": "Your specific question or request about the image. Optional context the model uses on the next turn after seeing the image."
        }
      },
      "required": [
        "image_url",
        "question"
      ]
    }
  },
  {
    "type": "function",
    "name": "web_extract",
    "description": "Extract content from web page URLs. Returns clean page content in markdown/text (no LLM summarization — fast). Also works with PDF URLs (arxiv papers, documents) — pass the PDF link directly. Pages within the char budget (default 15000) return whole; larger pages return a head+tail window with a footer telling you the full text's saved file path and the read_file call to page through the omitted middle. Inline images appear as [IMAGE: alt] placeholders; real image URLs are kept as links. If a URL fails or times out, use the browser tool instead.",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "urls": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List of URLs to extract content from (max 5 URLs per call)",
          "maxItems": 5
        },
        "char_limit": {
          "type": "integer",
          "description": "Optional per-page character budget sent back (default 15000). Pages larger than this are head+tail truncated with the full text stored to disk. Raise it when you need more of a long page inline.",
          "minimum": 2000
        }
      },
      "required": [
        "urls"
      ]
    }
  },
  {
    "type": "function",
    "name": "write_file",
    "description": "Write content to a file, completely replacing existing content. Use this instead of echo/cat heredoc in terminal. Creates parent directories automatically. OVERWRITES the entire file — use 'patch' for targeted edits. Auto-runs syntax checks on .py/.json/.yaml/.toml and other linted languages; only NEW errors introduced by this write are surfaced (pre-existing errors are filtered out).",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "path": {
          "type": "string",
          "description": "Path to the file to write (will be created if it doesn't exist, overwritten if it does)"
        },
        "content": {
          "type": "string",
          "description": "Complete content to write to the file"
        },
        "cross_profile": {
          "type": "boolean",
          "description": "Opt out of the cross-profile soft guard. Defaults to false. Set true ONLY after explicit user direction to edit another Hermes profile's skills/plugins/cron/memories — by default these writes are blocked with a warning because they affect a different profile than the one this session is running under.",
          "default": false
        }
      },
      "required": [
        "path",
        "content"
      ]
    }
  },
  {
    "type": "function",
    "name": "x_search",
    "description": "Search X (Twitter) posts, profiles, and threads using xAI's built-in X Search tool. Use this for current discussion, reactions, or claims on X rather than general web pages. Available when xAI credentials are configured (SuperGrok OAuth or XAI_API_KEY).",
    "strict": false,
    "parameters": {
      "type": "object",
      "properties": {
        "query": {
          "type": "string",
          "description": "What to look up on X."
        },
        "allowed_x_handles": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional list of X handles to include exclusively (max 10)."
        },
        "excluded_x_handles": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Optional list of X handles to exclude (max 10)."
        },
        "from_date": {
          "type": "string",
          "description": "Optional start date in YYYY-MM-DD format."
        },
        "to_date": {
          "type": "string",
          "description": "Optional end date in YYYY-MM-DD format."
        },
        "enable_image_understanding": {
          "type": "boolean",
          "description": "Whether xAI should analyze images attached to matching X posts.",
          "default": false
        },
        "enable_video_understanding": {
          "type": "boolean",
          "description": "Whether xAI should analyze videos attached to matching X posts.",
          "default": false
        }
      },
      "required": [
        "query"
      ]
    }
  },
  {
    "type": "web_search"
  }
]