Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:0xsline OpenChatCut Headless Tool Execution

From Leeroopedia
Knowledge Sources
Domains Security, Tooling, Editing
Last Updated 2026-10-22 14:00 GMT

Overview

Design pattern that restricts the set of editing tools available in a headless (no-browser) context to a vetted subset, ensuring only tools without runtime browser dependencies can be invoked by CLI agents or MCP clients.

Description

Headless Tool Execution applies the Principle of Least Privilege to editing tool surfaces. In a hybrid editor that runs both in a browser (with full DOM/media access) and headlessly (CLI, MCP), not all tools can run without the browser. Tools that render previews, manipulate the DOM, or require user interaction are browser-backed and must be excluded from the headless surface.

The pattern defines:

  • A whitelist of headless-safe tools, derived from a shared tool policy.
  • Validation that rejects non-whitelisted tools with a clear error message explaining why (browser-backed tools need the editor open).
  • Parsing of tool invocations from structured input (JSON `--ops` arrays or MCP tool calls) into validated tool operations.

This prevents silent failures where a tool appears to run but actually had no effect because its browser dependencies were missing.

Usage

Use this principle when:

  • Building CLI tools that share an editing surface with a browser-based editor.
  • Exposing editing capabilities over MCP or other programmatic interfaces.
  • Ensuring automated agents cannot accidentally invoke tools that require human interaction.
  • Maintaining a single source of truth for which tools are headless-safe.

Theoretical Basis

The mechanism is capability-based access control applied to a tool catalog:

  1. Policy definition: A central policy declares which tools are headless-safe (no browser dependencies).
  2. Whitelist derivation: The headless surface is the intersection of all tools and the policy whitelist.
  3. Validation gate: Every tool invocation is checked against the whitelist before execution.
  4. Fail-fast rejection: Non-whitelisted tools are rejected immediately with an actionable error.
# Abstract algorithm (NOT real implementation)
def headless_tool_names(policy, all_tools):
    return {tool.name for tool in all_tools if policy.is_headless_safe(tool)}

def require_headless_tool(name, whitelist, all_tools):
    if name in whitelist:
        return
    known = name in all_tools
    raise Error(f"Cannot run {name}: "
        + ("not headless-safe" if known else "no such tool"))

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment