Principle:0xsline OpenChatCut Headless Tool Execution
| 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:
- Policy definition: A central policy declares which tools are headless-safe (no browser dependencies).
- Whitelist derivation: The headless surface is the intersection of all tools and the policy whitelist.
- Validation gate: Every tool invocation is checked against the whitelist before execution.
- 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"))