Skip to content

Agents and MCP

nodemode-ai edited this page Nov 29, 2026 · 3 revisions

Agents and MCP

formcraft includes a Model Context Protocol (MCP) server, so a coding or chat agent can generate media, search the library, manage projects and, with the window open, drive the Scene, Canvas, Board and Edit studios. Agents are off by default. Nothing is exposed until you turn them on in Preferences, Agents.

How it fits together

Part Where Job
Launcher formcraft mcp (setup/mcp_stdio.py, Python standard library only) speaks MCP on standard input and output and forwards each message to the engine over loopback HTTP. It keeps no state
Server the engine, POST /mcp and /api/agents/* (backend/app/routers/mcp.py, routers/agents.py, services/agents.py, services/mcp_protocol.py, services/mcp_tools.py) the tool table, consent, token, activity, approvals and job waiting. The protocol is written by hand with no SDK dependency
Bridge engine queue plus a long-poll from the window (frontend/src/automation/) runs the tools that only the window can run, because the studio stores and the renderer live there

The server speaks two protocol generations: the stateless 2026-07-28 revision (server/discover, version in _meta) and the handshake revisions such as 2025-11-25 (initialize, notifications/initialized, ping). It offers tools, plus a few resources and prompts.

Engine tools and window tools

Engine tools work with the window closed. Window tools need the app open and answer window_required when no window is polling, and within a few seconds after the window closes or reloads, instead of waiting out the call limit (90 seconds; longer for edit_export, scene_capture, scene_save, scene_export, scene_open and scene_record_start). Tool names are frozen.

Group Tools
Status and models app_status, models_list, edit_capability
Generation plan_generation, estimate_cost, generate, jobs_list, job_get, job_wait, job_cancel, mask_video
Library library_search, library_item, library_frame, library_update, library_import, library_save_copy, library_delete
Organising folders_list, folders_create, folders_update, folders_delete, folders_add_items, tags_list, tags_apply, tags_rename, tags_delete, characters_list, characters_get, characters_create, characters_update, characters_delete, prompt_history
Projects and packs projects_list, projects_get, projects_create, projects_update, projects_export, projects_import, projects_delete, sounds_list, sounds_import, starter_pack_status, starter_pack_install
Window: commands commands_list, command_describe, command_run, studio_state, studio_open
Window: Edit edit_state, edit_add_media, edit_add_text, edit_move, edit_trim, edit_split, edit_remove, edit_set_param, edit_toggle_key, edit_set_speed, edit_add_effect, edit_set_mask, edit_bookmark, edit_settings, edit_undo, edit_redo, edit_export
Window: Scene build scene_schema, scene_state, scene_list_objects, scene_add, scene_add_many, scene_update, scene_delete, scene_select, scene_group, scene_ungroup, scene_camera
Window: Scene animation and output scene_mode, scene_timeline_get, scene_keys_set, scene_keys_delete, scene_timeline_set, scene_capture, scene_record_start, scene_record_status, scene_record_stop, scene_save, scene_export, scene_open
Window: Canvas, Board canvas_state, canvas_add_image, board_state, board_add_items

That is 44 engine tools and 49 window tools. Every tool has a title, a description and the four annotation hints (read-only, destructive, idempotent, open-world); a tool that writes anything, a library item included, is never marked read-only. commands_list shows the same command catalogue the window uses, with a description, parameters, whether the command changes anything and whether it is risky. Prefer a studio tool over a command: commands follow what is selected and open in the window, the tools do not. The scene tools need no selection, open panel or mode: scene_keys_set keys any object at any time in one batch, scene_record_start switches to Record mode by itself and keeps the selection, and scene_schema describes the scene, keyframe and .fcrft formats so an agent never has to read the app's code. Materials are arguments, not separate tools: scene_add, scene_add_many and scene_update take metalness, roughness, opacity, emissive, emissiveStrength, tiling, colorMapId, normalMapId, roughnessMapId and materialMediaId (a material from the starter library, by its library id), and scene_update also takes envMapId, envIntensity, envRotation and envBackground for the saved environment image. When a command cannot run, command_describe and command_run say which condition is missing and name the tool to call instead. Window tools appear in tools/list once the window has mirrored them; a change fires notifications/tools/list_changed.

Never exposed: provider keys (reading, writing or testing them), engine settings, encode sessions, cover uploads and the agent routes themselves.

Consent, token and policies

  • Master switch: Preferences, Agents, "Let outside agents use formcraft". It is the engine setting agentsAllowed and is off by default. While it is off every agent call is refused.
  • Token: a random token in the file agent.token in the data folder, readable only by you. formcraft mcp reads it (or takes FORMCRAFT_MCP_TOKEN) and sends it as a bearer token to /mcp. Rotate it in Preferences, Agents; the token itself is never shown or returned.
  • Level per agent: each agent (by the name it reports when it connects) has one of four levels, set in Preferences, Agents, Clients, or from the request card. A fifth choice, Deny, refuses the agent at once with client_denied. A new agent starts at Ask every time.
  • Activity: Preferences, Agents lists the last 200 calls with client, tool, status and time, and a Stop button that cancels every pending bridged call.
  • Secrets never appear in results, resources, logs or errors.

Levels

Level What it does
Ask every time every call that changes anything asks first
Ask once per session the first time an agent uses a tool it asks, and after you allow it the same tool does not ask again until formcraft closes
Always allow in this project changing calls do not ask while that project is the current one (the project you used last). It needs a project to exist, and is kept per project
Always allow everywhere changing calls do not ask, in any project

Reading never asks, at any level: the tools marked read-only in agents/manifest.json just run. Two kinds of call ask whatever the level, because they spend money or can lose files: generate, and the risky calls (library_delete, projects_delete, library_import, starter_pack_install, library_save_copy or projects_export with overwrite, and command_run for a command marked risky). With no window open, a call that needs an answer is refused with window_required.

The request card

A request for an ordinary tool shows as a card in the window. It does not take over the screen: you can keep working, and the studio stays usable underneath. The card names the agent and the action, shows the tool and its first arguments, and says which level is set now. Its buttons:

Button Does
Allow (Enter) allows this one call
Deny (Esc) refuses this one call
Always allow in this project allows this call and sets that level for this agent in the open project. Disabled, with the hint "Open or save a project first.", when there is no project yet
Stop asking for this session allows this call and stops asking this agent for ordinary tools until formcraft closes
Allow all appears when more than one request waits, and allows them all

When more than one request waits, the card counts them ("2 waiting") and shows the oldest first. The Agents button at the top right of the title bar shows a count of waiting requests and a mark while an agent is running. An unanswered request is refused after about two minutes, and a request the agent gave up on closes by itself.

Spending and the risky calls above use a dialog instead of the card, because they cannot be granted for ever. The dialog shows the estimated cost when there is one and has a "Remember this choice" box where that is allowed. A remembered generate approval covers later generations up to the approved cost.

Spending

Preferences, Agents, Allowed has a switch, "Allow spending without asking", and an amount, "Up to, in dollars per run" (from 0.01 to 1000). With the switch on, a generate call whose estimate is at or below the amount runs without asking. A call above the amount still asks. It is off by default.

The Allowed list

Preferences, Agents, Allowed lists every standing permission: always allow everywhere, always allow in a project (with the project's name), remembered choices, and session permissions, each with a Revoke button. Revoke removes just that permission. "Nothing is allowed yet." shows when the list is empty.

The cost rule

generate costs money. It refuses unless the call carries acceptCostUsd at or above the estimate, so the agent must call plan_generation or estimate_cost first and pass the figure. A remembered generate approval covers later generates up to the approved cost, and the spending switch in Preferences, Agents covers any generate up to the amount you set. Neither is turned on for a new agent program: it starts at Ask every time. The calls are idempotent by clientRequestId. A cancelled World Labs job may still be charged by the provider.

Connect a client

Use an absolute path to the formcraft program that FormPortal or your installer placed on your computer, or ./formcraft from a clone. FormPortal can write these entries for you. The server name is formcraft. If formcraft is not open, formcraft mcp starts a headless engine for itself and stops it when the client disconnects. If the app is open it attaches to the app's engine.

Claude Code

claude mcp add --transport stdio formcraft -- /path/to/formcraft mcp
claude mcp get formcraft

In a clone of this repository, .mcp.json already runs ./formcraft mcp for the project.

Claude Desktop

Edit claude_desktop_config.json (Settings, Developer, Edit Config), then restart Claude Desktop completely.

{
  "mcpServers": {
    "formcraft": { "command": "/path/to/formcraft", "args": ["mcp"] }
  }
}

The file is ~/Library/Application Support/Claude/ on macOS, %APPDATA%\Claude\ on Windows (escape backslashes in JSON) and ~/.config/Claude/ on Linux.

Codex

[mcp_servers.formcraft]
command = "/path/to/formcraft"
args = ["mcp"]
startup_timeout_sec = 60
tool_timeout_sec = 120

This goes in ~/.codex/config.toml, or .codex/config.toml in a trusted project. The default start-up limit is 10 seconds; raise it if the first start is slow.

Cursor

{
  "mcpServers": {
    "formcraft": { "type": "stdio", "command": "/path/to/formcraft", "args": ["mcp"] }
  }
}

This goes in ~/.cursor/mcp.json, or .cursor/mcp.json in a project.

Antigravity

{
  "mcpServers": {
    "formcraft": { "command": "/path/to/formcraft", "args": ["mcp"] }
  }
}

This goes in ~/.gemini/config/mcp_config.json. Restart Antigravity, or refresh its MCP list, after you change it.

All at once

./formcraft agents install writes the Claude Code, Codex and Cursor entries (.mcp.json, .codex/config.toml, .cursor/mcp.json) in the formcraft folder and in the folder you ran it from, adds formcraft to Antigravity's ~/.gemini/config/mcp_config.json, and copies the two skills to ~/.claude/skills, ~/.agents/skills and .agents/skills. It merges into existing files, keeps every other server, and saves the old file as .bak-<time> before changing it. --dry-run lists what it would do and writes nothing. ./formcraft agents sync refreshes the skill copies and agents/manifest.json; sync --check changes nothing and exits 1 when they are stale.

Launcher options

formcraft mcp [--attach] [--root DIR] [--read-root DIR] [--user-data-dir DIR] [--where]. --attach never starts an engine. --root and --read-root confine where agents may import from and save to. --user-data-dir picks the data folder. --where prints the data folder, the engine it found and the token file, and starts nothing. The environment variable FORMCRAFT_MCP_URL points at a specific engine and FORMCRAFT_MCP_TOKEN supplies the token. On stdout the launcher writes only protocol messages, one per line; logs go to standard error and the engine log.

Skills

Two Claude skills ship in .claude/skills/: formcraft-driving teaches an agent to use formcraft through these tools, and formcraft-harness teaches an agent how to change this repository. Releases attach them as formcraft-skills-v<version>.zip.

Contract for a new tool

  • Name in snake_case, never renamed after release. Give it a title, a description, an input schema and all four hints.
  • Call the same service or store action the interface calls. No second code path, and one undo step for each window mutation.
  • Check agentsAllowed first. If it can spend money or delete, mark it risky and require consent; if it spends money, require acceptCostUsd.
  • Return failures as tool errors with the engine's error.code. Never return key material.

Clone this wiki locally