---
title: "Policy enforcement"
version: "v0.29.0"
canonical: "https://docs.obot.ai/device-management/enforcement"
unreleased: false
---

# Policy enforcement

<a id="obot-doc-tool-call-enforcement"></a>

## Tool call enforcement

Tool call enforcement controls which tool calls Claude Code, Codex, Cursor, and Kiro may run on enrolled devices. Before a supported client runs a tool, Obot Sentry checks it against the allowlist for the device configuration. A call runs only when an allow rule matches it.

> **NOTE**
>
> Tool call enforcement is experimental.

<a id="obot-doc-what-enforcement-does"></a>

### What enforcement does

Enforcement keeps local AI clients on the MCP servers and tools you approve. It blocks the common ways an unapproved server ends up in use, such as a server copied from a blog post, a repository that ships its own `.mcp.json`, or a mistyped package name. Every allow and block is recorded, so you can see which servers people try to use and approve the ones they need.

Obot Sentry runs on the user's device and works from each client's own configuration, so enforcement has limits that a determined user can work around. Read [Limitations](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-limitations) before you roll it out. When you need controls that the user can't change, run agents and MCP servers on infrastructure Obot manages instead; see [Strengthen enforcement](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-strengthen-enforcement).

<a id="obot-doc-fail-closed-behavior"></a>

### Fail-closed behavior and client support

Enforcement fails closed. A call is blocked when:

- No allow rule matches it.
- Obot Sentry cannot identify the MCP server targeted by the call.
- Obot cannot be reached or cannot return a decision.
- The device is not enrolled.

Local tool call auditing for Visual Studio Code continues to work, but Visual Studio Code does not currently support enforcement.

> **IMPORTANT**
>
> Kiro runs hooks only in folders the user has trusted. In an untrusted folder, Kiro still runs the agent and asks the user to approve each tool call, but Obot Sentry neither checks nor audits those calls. The same is true in a window with no folder open. Kiro also reads trust only when it starts, so a folder the user trusts afterward stays unchecked until Kiro is restarted.
>
> Cover this in your MDM:
>
> - Decide how to handle workspace trust. Setting Kiro's `security.workspace.trust.enabled` to `false` treats every folder as trusted, so the hooks always run, but it also turns off Kiro's protection against untrusted repositories, and users can change it back. Obot Sentry does not change this setting.
> - Tell users to restart Kiro after they trust a new folder.
>
> The Kiro CLI runs these hooks only on its v3 agent engine. Sessions on the v2 engine are neither checked nor audited. Recent CLI versions use v3 for interactive sessions by default, but use v2 for `--no-interactive` or piped sessions, when resuming a v2 session, or when the user chooses it with `--v2` or the `chat.agentEngine` setting. Obot Sentry does not change the engine setting. If you set `chat.agentEngine` to `v3` through your MDM, users can still choose v2 for a single session with `--v2`.

> **IMPORTANT**
>
> If a device receives server-managed settings, an MDM policy, or a policy helper for Claude Code, set `managedSourcesBehavior` to `merge`. Otherwise Claude Code ignores Obot Sentry's hooks. See [Managed settings sources](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-claude-code-managed-settings-sources).

<a id="obot-doc-configure-enforcement"></a>

### Configure enforcement

In **Administration > Device Management > Devices**, open the **Configuration** view and find **Tool Call Enforcement**.

1. Review the rules under **Allow**. When you turn on enforcement with an empty allowlist, Obot starts with Obot-hosted MCP servers, built-in agent tools, and built-in agent MCP servers allowed.
2. Add any other MCP servers and tools your users need.
3. Turn on **Enforce tool calls on enrolled devices**, then save the configuration.
4. Download the updated install package and follow its included `INSTRUCTIONS.md` to apply the change to devices. The included instructions contain the setup steps for the selected operating system and deployment method.

Consider starting with a few devices, then fill in the allowlist from their [enforcement decisions](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-review-enforcement-decisions) before rolling out more widely.

Changing the allowlist takes effect on devices that already have enforcement set up without reinstalling Obot Sentry. Turning enforcement off in Obot makes Obot allow every call immediately and stops recording new enforcement decisions.

Each device also has a device enforcement setting, which Obot builds into the install package from **Enforce tool calls on enrolled devices**. The device enforcement setting decides whether Obot Sentry installs the enforcement hook and the Claude Code [plugin settings](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-claude-code-plugin-settings). To change it on enrolled devices, deliver the new value as described in [Settings and updates](https://docs.obot.ai/v0.29.0/device-management/enroll.md#obot-doc-settings-and-updates). Until a device receives the new value, it keeps running the enforcement hook. Obot allows every call the hook checks, but the hook still blocks calls when it can't get an answer from Obot, as described in [Fail-closed behavior and client support](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-fail-closed-behavior).

<a id="obot-doc-allow-rules"></a>

### Allow rules

The broad allow rules are:

| Rule                           | What it allows                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| All Obot-hosted MCP servers    | Any MCP server hosted by this Obot instance.                                                                                                                                                                                                                                                                                                                                    |
| All built-in agent tools       | The client's own tools, such as reading and writing files, running shell commands, and starting tasks.                                                                                                                                                                                                                                                                          |
| All built-in agent MCP servers | MCP servers that ship as part of a supported AI client. These include Claude Code's built-in servers and the servers the Claude desktop app runs in its Claude Code sessions, such as its browser, terminal, and device simulators. They also include the JavaScript REPLs that the Codex app's built-in browser and computer use run on, including in the ChatGPT desktop app. |
| Everything                     | Every call that Obot Sentry can identify. All other allow rules are ignored while this is selected.                                                                                                                                                                                                                                                                             |

You can also allow an individual MCP server by:

| Identity  | Matching behavior                                                                                                                                                                                                                                                                                   |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| URL       | Matches the scheme, hostname, port, and URL path. A path also covers paths beneath it.                                                                                                                                                                                                              |
| Hostname  | Matches every MCP server on that hostname, regardless of path or port.                                                                                                                                                                                                                              |
| Package   | Matches an npm package launched with `npx` or a Python package launched with `uvx`. You can allow any version or require a specific version.                                                                                                                                                        |
| Connector | Matches a connector by display name, such as a claude.ai connector. A connector rule can't match connectors in the Claude desktop app. See [Claude Code calls Obot Sentry can't identify](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-claude-code-unidentifiable-calls). |

For each server, leave **Tools** empty to allow all of its tools, or list the specific tool names to allow. Enforcement matches tool names, not the arguments passed to a tool.

Turn off **All built-in agent MCP servers** if users run Agent SDK apps you don't trust. See [What a determined user can get around](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-what-a-determined-user-can-get-around).

When a Claude release adds a desktop app server, Obot Sentry blocks the server until you install an Obot Sentry release that recognizes it.

A local MCP server launched directly from an executable or script path does not provide a supported identity for the allowlist. Obot Sentry blocks calls to a server it cannot identify rather than treating its local command as trusted.

<a id="obot-doc-claude-code-managed-settings"></a>

### Claude Code managed settings

Obot Sentry installs Claude Code's hooks in Claude Code's [managed settings](https://code.claude.com/docs/en/settings) file. The file is `/Library/Application Support/ClaudeCode/managed-settings.json` on macOS and `C:\Program Files\ClaudeCode\managed-settings.json` on Windows.

Enforcement of Claude Code MCP calls requires Claude Code 2.1.274 or later. Obot Sentry blocks every MCP tool call from earlier releases. Calls to built-in agent tools are unaffected.

<a id="obot-doc-claude-code-plugin-settings"></a>

#### Plugin settings

When enforcement is on, Obot Sentry writes two plugin settings to the managed settings file:

- `disableSideloadFlags` set to `true`. This stops Claude Code from loading a plugin for a single session through `--plugin-dir`, `--plugin-url`, `CLAUDE_CODE_PLUGIN_DIRS`, or the Agent SDK. It also makes Claude Code refuse `--agents` and `--mcp-config`.
- A `{"source": "skills-dir"}` entry in `blockedMarketplaces`. This stops Claude Code from loading plugins from `.claude/skills` folders. Skills in those folders still load, and the entry blocks no marketplace.

Without these settings, Obot Sentry could check an installed plugin's servers while Claude Code runs a different plugin with the same name. If someone removes either setting from the managed settings file, Obot Sentry puts it back at its next hook check.

Obot Sentry leaves both settings in place when you turn off the device enforcement setting or uninstall Obot Sentry, because it can't tell whether an administrator set them. To allow those plugins and flags again, first stop Obot Sentry from restoring them. Either turn off **Enforce tool calls on enrolled devices**, deliver the change as described in [Settings and updates](https://docs.obot.ai/v0.29.0/device-management/enroll.md#obot-doc-settings-and-updates), and wait for the next hook check, or uninstall Obot Sentry. Then remove both settings from the managed settings file.

<a id="obot-doc-claude-code-managed-settings-sources"></a>

#### Managed settings sources

Claude Code ranks its managed settings sources from highest to lowest:

1. A policy helper, which is a program an administrator configures to supply settings.
2. Server-managed settings.
3. An MDM policy. This is the `com.anthropic.claudecode` preference domain on macOS and `HKLM\SOFTWARE\Policies\ClaudeCode` on Windows.
4. The managed settings file and its `managed-settings.d` folder.

On Windows, Claude Code also reads `HKCU\SOFTWARE\Policies\ClaudeCode`. It ranks below the managed settings file and can't override it.

A higher source is any source ranked above the managed settings file. By default, Claude Code applies only the highest-ranked source that sets anything besides `managedSourcesBehavior`. If a device receives a higher source, Claude Code ignores the managed settings file, including Obot Sentry's hooks. Obot Sentry then neither checks nor audits Claude Code calls on that device, and it still reports the hooks as installed.

To check a device for server-managed settings or an MDM policy, start Claude Code with `--debug-file <path>`. In the log, an `MDM settings found` line lists the keys Claude Code found in an MDM policy. A `Remote settings` line says whether Claude Code loaded server-managed settings. Claude Code also caches a user's server-managed settings in `remote-settings.json` in the user's Claude configuration folder. You configure a policy helper yourself, so check your own deployment for one.

If your organization deploys a higher source, set `managedSourcesBehavior` to `merge` in the highest-ranked source that contains other settings. Claude Code then also applies the managed settings file. With `merge`, these rules apply:

- A higher source can't override the [plugin settings](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-claude-code-plugin-settings) that Obot Sentry writes. It can still turn the hooks off with `"disableAllHooks": true`, so don't set that in any managed source.
- Obot Sentry reads MCP servers from the managed settings file and not from higher sources. It blocks calls to a server that only a higher source defines.
- If a higher source and the managed settings file define a server under the same name, Claude Code runs the higher source's definition and Obot Sentry checks the file's definition. Don't define a server under the same name in both.

Server-managed settings follow the claude.ai organization the user signs in to. If a user signs in to another organization, Claude Code can apply that organization's settings and ignore the managed settings file.

To limit which organizations users can sign in to, set `forceLoginOrgUUID` in the highest-ranked source you deploy on the device. Claude Code reads it from the managed settings file only when no higher source contains other settings, or when the highest one sets `merge`. Don't rely on server-managed settings for this, because a user signed in to another organization never receives them. It is not known whether `forceLoginOrgUUID` stops another organization's settings from replacing the managed settings file.

<a id="obot-doc-review-enforcement-decisions"></a>

### Review enforcement decisions

Open **Administration > Device Management > Enforcement Decisions** to review calls checked while enforcement was enabled. The view shows allowed and blocked totals for the selected date range and supports searching and filtering by result, device, agent, tool type, MCP server, and tool.

Open a decision to see:

- Why the call was allowed or blocked.
- The client, tool, and MCP server involved.
- The server identity Obot Sentry found, when available.
- The device that made the call.

For an identified, blocked MCP call, an administrator can add an allow rule directly from the decision. Depending on the identity available, the rule can allow the hostname, all tools on that server, or only the tool in that decision. The new rule applies to matching calls from every device using the configuration; it does not change the historical decision.

<a id="obot-doc-claude-code-unidentifiable-calls"></a>

### Claude Code calls Obot Sentry can't identify

Claude Code's hook reports the scope Claude Code loaded each MCP server from, such as `user`, `project`, or `plugin`, and Obot Sentry reads the server's definition only from that scope. Obot Sentry can't identify these Claude Code MCP calls, so it blocks them:

- Calls from Claude Code releases before 2.1.274.
- Calls to servers passed with `--mcp-config`, registered by an Agent SDK app, or defined in an agent definition. The exception is a server whose name and scope match a [built-in agent MCP server](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-allow-rules). Obot Sentry identifies that server as a built-in agent MCP server, and the **All built-in agent MCP servers** and **Everything** rules decide the call.
- Calls to claude.ai connectors in the Claude desktop app. The desktop app gives Claude Code each connector under a generated ID, not its name, so a connector allow rule can't match it. In the Claude Code CLI, Obot Sentry identifies the same connectors by name.
- Calls to plugin servers when the managed settings lack one or both of the [plugin settings](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-claude-code-plugin-settings), or when Obot Sentry can't read the managed settings file or a file in its `managed-settings.d` folder. If someone removes a setting from the managed settings file, this lasts until the next hook check restores it. A `managed-settings.d` file that sets `disableSideloadFlags` to `false` overrides the managed settings file, and hook checks don't correct it, so plugin calls stay blocked until you remove that setting.
- Calls to a plugin server that two installations of the plugin define differently. A copy of the plugin synced from claude.ai counts as an installation.
- Calls to plugin servers when a plugin file exists but Obot Sentry can't read it.
- Calls to `local` and `project` servers when Claude Code doesn't give the hook the folder the session started in.
- Calls to `user` and `local` servers when `CLAUDE_CONFIG_DIR` is set. Claude Code's `env` setting can run hooks with a different `CLAUDE_CONFIG_DIR` than Claude Code used, so Obot Sentry can't tell which `.claude.json` defined the server. Obot Sentry still reads `plugin` servers from `$CLAUDE_CONFIG_DIR/plugins`. Calls to `project`, `enterprise`, `managed`, and `claudeai` servers are unaffected.
- All MCP calls, except calls to built-in agent MCP servers, from a session whose `CLAUDE_CONFIG_DIR` is empty or a relative path. Claude Code resolves a relative path against the folder it was started in, and Obot Sentry can't determine that folder. Set `CLAUDE_CONFIG_DIR` to an absolute path.
- Calls to a server, other than a `managed` server, with a `${VAR}` reference in one of these places: its URL before any `?` or `#`, its command, its `npx` or `uvx` arguments up to and including the package, the command after `-p` or `--from`, or the name of an `env` variable. Claude Code expands these references from its own environment when it loads the server, and Obot Sentry can't see those values. Obot Sentry accepts references in other places, such as an `env` value, a header, or an argument after the package. For plugin servers, Obot Sentry substitutes `${CLAUDE_PLUGIN_ROOT}` itself.

<a id="obot-doc-check-server-identification"></a>

### Check how a server is identified

`obot-sentry enforce resolve` uses the same logic as the hook. It prints each configuration source it reads and what it found there. To run it:

1. Sign in to the device as the user who made the call. Don't use `sudo`.
2. Change to the folder where the session started. You can pass that folder instead, with `--project-dir` for Claude Code or `--cwd` for other clients.
3. Run `obot-sentry enforce resolve` with the client in `--agent` and the server name from the decision in `--server`.
4. For Claude Code, also pass the scope in `--server-source`. The decision has no scope field, but the reason for an unidentified server often names the scope. If it doesn't, run the command once for each of `user`, `local`, `project`, `plugin`, `enterprise`, and `managed`.

For example:

```sh
obot-sentry enforce resolve --agent claude-code --server linear --server-source project
```

<a id="obot-doc-limitations"></a>

## Limitations

<a id="obot-doc-what-a-determined-user-can-get-around"></a>

### What a determined user can get around

Enforcement depends on files and settings that the user can change on their own device. A user who means to use an unapproved MCP server can do so in ways that include:

- **Removing the hooks.** Kiro hooks are installed in the user's home directory, so the user can edit or delete them, or turn them off in Kiro's Agent Hooks panel, until Obot Sentry's next hook check restores them. See [Hook maintenance](https://docs.obot.ai/v0.29.0/device-management/enroll.md#obot-doc-hook-maintenance). Claude Code, Codex, and Cursor hooks are installed in machine-wide files, so they are only as protected as those files' permissions. Use your MDM to check that the hook files are in place and to report devices where they're missing as out of compliance.
- **Relocating Kiro's configuration.** When the `KIRO_HOME` environment variable is set, Kiro reads its settings, sessions, agents, and hooks from that directory. A user who starts Kiro with `KIRO_HOME` pointing at another directory loads neither the enforcement hook nor the audit hook, so the session's tool calls run unchecked and are not logged.
- **Shadowing an allowed server.** A client can load MCP configuration from places Obot Sentry doesn't read, and a user can define a server there under an allowed server's name. Obot Sentry then checks the allowed server while the client runs the other. Claude Code reports each server's scope, so Obot Sentry blocks scopes it can't read, such as `dynamic`. With enforcement on, Claude Code also refuses `--mcp-config`. Codex, Cursor, and Kiro don't report the scope, so a user can still shadow an allowed server in those clients.
- **Replacing the package runner.** Obot Sentry treats a configuration entry that changes `PATH` or other package-resolution settings as unidentifiable and blocks it. It can't see which `npx` or `uvx` the user's own shell finds first, so a different executable earlier on the user's `PATH` can run anything under an allowed package name. Tools such as asdf, mise, Volta, and Corepack can also change which `npx` or `uvx` runs.
- **Replacing an allowed package with local code.** Obot Sentry identifies an `npx` or `uvx` server by the package name in its configuration. It doesn't check the folder the server starts in, which for Claude Code is the folder where the session started. Allowing a server by URL avoids the cases below. Obot Sentry can't detect these ways of running local code under an allowed package name:
  - npm prefers files in the project over the registry package. In the start folder or any folder above it, these include an executable in `node_modules/.bin`, a copy of the package in `node_modules`, a `bin` entry in `package.json`, and a `.npmrc` that changes the registry.
  - A project's agent settings can pass `PREFIX`, `DESTDIR`, or an `npm_config_*` variable to the server.
  - Some version specifiers point to local files, such as `pkg@.` or `pkg@local.tgz` for npm, or `pkg@x` for `uvx` when `x` is not a version.
  - A `uvx -p` value that isn't a version, such as `venv` or `python3.11`, can name a local interpreter.
  - On Windows, a command can run an executable from the start folder before one on `PATH`. This case is untested.
- **Registering a built-in server name.** An Agent SDK app can register a server under the name of a Claude desktop app server, and Obot Sentry can't tell the two apart. If **All built-in agent MCP servers** or **Everything** is on, Obot allows that server's calls.
- **Changing configuration around the check.** Anything that runs as the user, including the user's own hooks, can change a client's configuration files between the time Obot Sentry reads them and the time the client uses them.

<a id="obot-doc-what-it-can-block-by-mistake"></a>

### What it can block by mistake

Enforcement fails closed, so anything Obot Sentry can't identify is blocked, including servers you want to allow:

- Servers defined only in configuration Obot Sentry doesn't read.
- The cases in [Claude Code calls Obot Sentry can't identify](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-claude-code-unidentifiable-calls), such as releases before 2.1.274, claude.ai connectors in the Claude desktop app, and calls to `user` and `local` servers in sessions with `CLAUDE_CONFIG_DIR` set.
- Local servers launched from an executable or script path rather than `npx` or `uvx`.
- Packages with a version that is an alias or a URL, such as `pkg@npm:other`, `file:`, or `github:`.
- Package version ranges that need a space, such as `>=1.2 <2` or `1 || 2`. Write the range without spaces, such as `1||2`, or pin a version.
- `npx -p <package> <command>` and `uvx --from <package> <command>` when `<command>` isn't the package's own name.
- `uvx -p` or `--python` with a path to an interpreter.
- A server name that is defined differently in more than one configuration file.

The Enforcement Decisions view shows the reason for each block. Use it to find and fix these cases.

<a id="obot-doc-strengthen-enforcement"></a>

## Strengthen enforcement

The limitations above come from enforcement running on a device the user controls and working from the client's own configuration. The strongest option is to move the work somewhere the user doesn't control:

- **Run Claude sessions in Claude Environments.** [Claude Environments](https://docs.obot.ai/v0.29.0/claude-environments/overview.md) runs Claude cloud sessions in isolated sandboxes on your own Kubernetes cluster. Obot decides who can start a session and which vMCPs it can use, and an egress gateway outside the sandbox controls which hosts the session can reach, injects credentials, and audits every request. See [Network access, secrets, and auditing](https://docs.obot.ai/v0.29.0/claude-environments/security.md). These controls sit outside the sandbox, so changing the agent's configuration inside a session doesn't get around them.
- **Host MCP servers in Obot.** Instead of letting each device run its own `npx` or `uvx` servers, [host them in Obot](https://docs.obot.ai/v0.29.0/concepts/mcp-hosting.md) as isolated containers or Kubernetes workloads, with [egress rules](https://docs.obot.ai/v0.29.0/configuration/mcp-server-egress-control.md) applied, and give users access through a vMCP.

On devices, use enforcement as one of several layers:

- **Use the client's own managed settings.** Some clients can be locked down directly, and those controls don't depend on reading configuration files. For example, Claude Code can be given a [managed MCP configuration](https://code.claude.com/docs/en/managed-mcp) that users can't override. Claude Code enforces it, and Obot Sentry reads servers in the `enterprise` scope from it. Because Obot Sentry's Claude Code hooks are in managed settings, you can also set `allowManagedHooksOnly` so that Claude Code ignores hooks the user adds, without turning off Obot Sentry's. Deliver these settings through your MDM, and set `managedSourcesBehavior` as described in [Managed settings sources](https://docs.obot.ai/v0.29.0/device-management/enforcement.md#obot-doc-claude-code-managed-settings-sources) if you deliver them through a source ranked above the managed settings file.
- **Send remote MCP traffic through Obot.** A remote MCP server reached through an Obot gateway is governed by gateway access controls, filters, and audit logs on the server side, where the user can't change them. Network egress controls that block direct connections to remote MCP servers close the path around the gateway.
- **Manage the device with your MDM.** Keep the client settings that enforcement depends on in place, such as Kiro's hook and workspace trust settings, and keep the machine-wide hook files for Claude Code, Codex, and Cursor writable only by administrators.
- **Review enforcement decisions.** Repeated blocks show which servers people need. A device that keeps submitting scans but no longer reports enforcement decisions may have lost its hooks.
