High Risk →

exec

Execute JavaScript code on a tldraw canvas. The code runs in the widget with access to the live editor instance, helper functions, and normal js. Use the search tool first to discover available Editor methods and shape types. Each canvas has a unique canvasId. Omit canvasId to create a new blank ...

Risk signalsAccepts freeform code/query input (code)

Part of the Tldraw server.

exec can trigger actions in Tldraw, with no limits today. PolicyLayer puts allow, deny, and rate-limit rules on every call. Live in minutes.

SECURE TLDRAW →

Free to start. No card required.

AI agents invoke exec to trigger processes or run actions in Tldraw. Execute operations can have side effects beyond the immediate call -- triggering builds, sending notifications, or starting workflows. Rate limits and argument validation are essential to prevent runaway execution.

exec can trigger processes with real-world consequences. An uncontrolled agent might start dozens of builds, send mass notifications, or kick off expensive compute jobs. PolicyLayer enforces rate limits and validates arguments to keep execution within safe bounds.

Execute tools trigger processes. Rate-limit and validate arguments to prevent unintended side effects.

policy.json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "exec": {
      "limits": [
        {
          "counter": "exec_rate",
          "window": "minute",
          "max": 10,
          "scope": "grant"
        }
      ]
    }
  }
}

See the full Tldraw policy for all 6 tools.

Get this rule live on your own Tldraw server in minutes. PolicyLayer enforces it on every call, before it runs.

ENFORCE ON MY TLDRAW →

These attack patterns abuse exactly the kind of access exec gives an agent. Each links to the full case and the policy that stops it:

Browse the full MCP Attack Database →

Every attack above starts with a tool call. PolicyLayer checks each one against your policy first, so exec only ever does what you allow.

SECURE TLDRAW →

Other execute tools across the catalogue. The same approach applies to each: rate-limit and validate the arguments.

What does the exec tool do? +

Execute JavaScript code on a tldraw canvas. The code runs in the widget with access to the live editor instance, helper functions, and normal js. Use the search tool first to discover available Editor methods and shape types. Each canvas has a unique canvasId. Omit canvasId to create a new blank canvas. To edit an existing canvas, pass the canvasId that was returned by a previous exec call. Shapes and text grow depending on the amount of text they have. Use clever scripting to ensure there are no unintended overlaps. Examples: - Create a rectangle: editor.createShape({ _type: 'rectangle', shapeId: 'box1', x: 200, y: 120, w: 320, h: 180, text: 'Hello' }) - Connect shapes with an arrow: editor.createShape({ _type: 'arrow', shapeId: 'a1', fromId: 'box1', toId: 'box2', x1: 0, y1: 0, x2: 100, y2: 0 }) - Select and zoom: editor.select('box1'); editor.zoomToSelection() - Read shapes: return editor.getCurrentPageShapes() - Distribute evenly: editor.distributeShapes(editor.getSelectedShapeIds(), 'horizontal') - Box around shapes: boxShapes(['box1', 'box2'], { text: 'Group label', color: 'blue' }) - Stack shapes dynamically: editor.createShape({ _type: 'rectangle', shapeId: 'a', x: 0, y: 0, w: 300, h: 200, text: 'First box\nwith wrapping text' }); const bounds = editor.getShapePageBounds('a'); editor.createShape({ _type: 'rectangle', shapeId: 'b', x: 0, y: bounds.maxY + 20, w: 300, h: 200, text: 'Below first' }). It is categorised as a Execute tool in the Tldraw MCP Server, which means it can trigger actions or run processes. Use rate limits and argument validation.

How do I enforce a policy on exec? +

Register the Tldraw MCP server in PolicyLayer and add a rule for exec: allow, deny, rate-limit, or require approval. Point your MCP client at the PolicyLayer proxy URL and the rule is enforced on every call, before it reaches Tldraw. Nothing to install.

What risk level is exec? +

exec is a Execute tool with high risk. Execute tools should be rate-limited and have argument validation enabled.

Can I rate-limit exec? +

Yes. Add a rate_limit block to the exec rule in your PolicyLayer policy. For example, setting max: 10 and window: 60 limits the tool to 10 calls per minute. Rate limits are tracked per agent session and reset automatically.

How do I block exec completely? +

Set action: deny in the PolicyLayer policy for exec. The AI agent will receive a policy violation error and cannot call the tool. You can also include a reason field to explain why the tool is blocked.

What MCP server provides exec? +

exec is provided by the Tldraw MCP server (https://tldraw-mcp-app.tldraw.workers.dev/mcp). PolicyLayer sits as a proxy in front of this server to enforce policies before tool calls reach the server.

Enforce policy on every Tldraw tool call.

Deterministic rules across all 6 Tldraw tools. Per-identity grants. Full audit log. Live in minutes. Nothing to install.

Free to start. No card required.

4,600+ MCP servers and 31,000+ tools scanned and risk-classified.

// GET IN TOUCH

Have a question or want to learn more? Send us a message.

Message sent.

We'll get back to you soon.