Skip to main content

Set runtime policies for commands and MCP tools

Runtime policies are enforcement rules for CLI commands and MCP tools, evaluated through coding-agent hooks. Each rule can stop a call, ask the person before it runs, or let it run while flagging it in logs and alerts.

CLI rules use the shell hooks in Claude Code, Cursor, Codex, GitHub Copilot CLI, and Pi. MCP tool rules are enforced in Claude Code, Cursor, and Codex. They do not apply to calls through the Willow gateway. For gateway enforcement, configure guards and MCP tool controls.

Before you start​

  • You need administrator access.
  • Turn on Runtime Policy under Admin > Settings > Beta Features. Refresh the page if Policies does not appear in the sidebar.
  • Enable guard hooks on the devices and coding agents you want to cover. On Policies > Runtime, Set up hooks opens their setup. A rule cannot enforce anything where the agent's hooks are off.

Runtime rules run alongside your guards. Guards keep their own scopes; creating a runtime rule does not change them.

Add a CLI command rule​

  1. Open Control > Policies and select Runtime.

  2. Select Add rule, then CLI command.

  3. Enter a Command: a program and up to two subcommand words. For example, kubectl covers all kubectl commands, while kubectl delete covers its delete subcommand. Flags and paths are not matched. Matching also works inside chained commands, sudo, and bash -c.

  4. Choose an Action:

    ActionEffect
    BlockStops the call before it runs.
    Ask userAsks the person to approve the call before it runs.
    WarnLets the call run and flags it in logs and alerts.
  5. Under AI agents, select All agents to choose which coding agents the rule covers. Under Applies to, select Everyone to limit the rule to groups.

  6. Optionally enter a Name, shown in logs and alerts, and a Message to the user explaining the decision.

  7. Leave Rule is on enabled to enforce it, or turn it off to save it without enforcement. Select Add rule.

Add an MCP tool rule​

Select Add rule > MCP tool, then enter:

  • MCP server: the server to match, or * for any server.
  • Tool: the tool name or a wildcard pattern such as delete_*.

Choose the action, agents, groups, and optional message as above, then select Add rule.

Cursor does not report the MCP server separately. A server-specific rule there only matches tools whose name starts with that server name. Use the tool name reported by Cursor when configuring the match.

You can also open the rule editor with the gavel action on a command in CLI tools or an MCP tool in Tool calls.

Check enforcement​

  1. Start with a rule limited to a test group and one coding agent.
  2. Let the Scan Agent sync the hooks, then restart the coding agent. See When devices get changes.
  3. Ask that coding agent to run a harmless command covered by your test rule, such as git status in a test repository.
  4. Confirm the expected block, approval prompt, or warning, and inspect the matching event in Monitor > Logs. Warn lets the call run and records a warning.
  5. Check a command outside the rule's scope before expanding it to more people.

Troubleshooting​

SymptomWhat to check
Policies is missingEnable the Runtime Policy beta flag and refresh the dashboard.
The page says to set up agent hooksTurn on hooks for a supported coding agent and let the device pick them up.
A CLI rule does not matchUse the program and up to two subcommands, without flags or paths. Check the rule's agent and group scope.
An MCP rule misses calls in CursorCheck the reported tool name and the server-prefix limitation above.
A gateway call is unaffectedRuntime policies apply through coding-agent hooks. Configure gateway guards or tool controls for gateway calls.