# Rules (/docs/reference/mcp/rules)

<p>
  {rule}
</p>

Refer to [Rules](/govern/rules) for how to write, validate, simulate, and apply Cedar bundles. All tools require workspace context.

## Rules [#rules]

### dome_rules_deploy [#dome_rules_deploy]

Deploy a bundle of Cedar authorization rules. Each file has a name and Cedar policy content. Defaults to workspace scope if `scope_kind`/`scope_id` are omitted. Use `dome_agents_assign_policy` for agent-scoped rules.

| Parameter    | Type   | Required | Description                                                                                           |
| ------------ | ------ | -------- | ----------------------------------------------------------------------------------------------------- |
| `files`      | array  | Yes      | Array of `{name, content}` objects — Cedar rule files                                                 |
| `name`       | string | No       | Optional friendly display name for this rule bundle                                                   |
| `scope_kind` | string | No       | Scope kind: `tenant`, `workspace`, `agent` (defaults to `workspace` if a workspace context is active) |
| `scope_id`   | string | No       | Scope ID (workspace or agent UUID)                                                                    |

> **Note**: Requires `rules.deploy`.

```json title="Example tool call"
{
  "name": "dome_rules_deploy",
  "arguments": {
    "files": [
      {
        "name": "allow-code-search.cedar",
        "content": "permit(\n  principal,\n  action == Dome::Action::\"mcp:call\",\n  resource == Dome::MCPTool::\"code-search\"\n);"
      }
    ],
    "name": "allow-code-search"
  }
}
```

> **Note**: Cedar policies use a declarative syntax. Use `dome_rules_validate` to check syntax before deploying.

The response includes an advisory `warnings` array. After a successful
deploy, the control plane walks every policy for `Dome::MCPTool`
references and cross-checks each `(connection, tool)` pair against the
workspace's persisted MCP tool catalog. Mismatches surface as
`ValidationWarning` entries (file + message) — a typo or rename is
flagged, but the deploy still succeeds. Warnings are only emitted for
`workspace`- and `agent`-scoped bundles; `tenant`-scoped deploys skip
this check because the catalog is workspace-keyed.

### dome_rules_get_active [#dome_rules_get_active]

Get the currently active rule bundle at the specified scope. Defaults to workspace scope. For agent-specific rules, use `scope_kind="agent"` and `scope_id=<agent-id>`, or use `dome_agents_get_policies`.

| Parameter    | Type   | Required | Description                                |
| ------------ | ------ | -------- | ------------------------------------------ |
| `scope_kind` | string | No       | Scope kind: `tenant`, `workspace`, `agent` |
| `scope_id`   | string | No       | Scope ID                                   |

> **Note**: Requires `rules.view`.

### dome_rules_validate [#dome_rules_validate]

Validate Cedar rule files without deploying. Returns errors and warnings.

| Parameter | Type  | Required | Description                                           |
| --------- | ----- | -------- | ----------------------------------------------------- |
| `files`   | array | Yes      | Array of `{name, content}` objects — Cedar rule files |

> **Note**: Requires `rules.view`.

```json title="Example tool call"
{
  "name": "dome_rules_validate",
  "arguments": {
    "files": [
      {
        "name": "draft.cedar",
        "content": "permit(\n  principal,\n  action == Dome::Action::\"mcp:call\",\n  resource\n);"
      }
    ]
  }
}
```

### dome_rules_generate [#dome_rules_generate]

Generate starter Cedar authorization rules. Returns a Cedar policy with blanket `mcp:discover` permit and comments explaining how backend tool availability works.

| Parameter | Type | Required | Description   |
| --------- | ---- | -------- | ------------- |
| —         | —    | —        | No parameters |

> **Note**: Requires `rules.view`.

## Simulate [#simulate]

### dome_rules_simulate [#dome_rules_simulate]

Simulate an authorization decision against the active rules without actually performing the action.

| Parameter       | Type   | Required | Description                                                      |
| --------------- | ------ | -------- | ---------------------------------------------------------------- |
| `agent_id`      | string | Yes      | agent ID (or name — resolved to UUID) to simulate as the caller  |
| `action`        | string | Yes      | Action to evaluate (e.g., `mcp:call`, `mcp:discover`)            |
| `resource`      | string | Yes      | Resource identifier                                              |
| `resource_type` | string | Yes      | Resource type: `mcp_tool`, `llm_model`, `resource`               |
| `context`       | object | No       | Additional context key-value pairs                               |
| `actas_sub`     | string | No       | Act-as subject identifier (end-user the agent acts on behalf of) |
| `actas_email`   | string | No       | Act-as email                                                     |
| `actas_roles`   | string | No       | Act-as roles (comma-separated)                                   |
| `actas_groups`  | string | No       | Act-as groups (comma-separated)                                  |

> **Note**: Requires `rules.view`.

```json title="Example tool call"
{
  "name": "dome_rules_simulate",
  "arguments": {
    "agent_id": "code-reviewer",
    "action": "mcp:call",
    "resource": "mcp_tool/code-search",
    "resource_type": "mcp_tool"
  }
}
```

### dome_rules_simulate_result [#dome_rules_simulate_result]

Get the result of a rule simulation run. If the simulation is still running, the status is `pending` or `running` — call again after a moment to check for completion.

| Parameter | Type   | Required | Description   |
| --------- | ------ | -------- | ------------- |
| `id`      | string | Yes      | Simulation ID |

> **Note**: Requires `rules.view`.

## Versions [#versions]

### dome_rules_list_versions [#dome_rules_list_versions]

List historical rule bundle versions at the specified scope. Defaults to workspace scope.

| Parameter    | Type   | Required | Description                                |
| ------------ | ------ | -------- | ------------------------------------------ |
| `scope_kind` | string | No       | Scope kind: `tenant`, `workspace`, `agent` |
| `scope_id`   | string | No       | Scope ID                                   |
| `limit`      | number | No       | Maximum results (default: 20)              |

> **Note**: Requires `rules.view`.

Returns each version with its bundle ID, name, deploy timestamp, and deployer.

### dome_rules_rollback [#dome_rules_rollback]

Rollback to a previously deployed rule bundle by its ID. The server reads the bundle's scope from the stored row — no `scope_kind`/`scope_id` needed.

| Parameter   | Type   | Required | Description                                      |
| ----------- | ------ | -------- | ------------------------------------------------ |
| `bundle_id` | string | Yes      | Bundle ID (UUID) from `dome_rules_list_versions` |

> **Note**: Requires `rules.rollback`.

> **Warning**: Rollback immediately changes the active rules. All subsequent authorization decisions use the rolled-back bundle.

## Agent policies [#agent-policies]

### dome_agents_assign_policy [#dome_agents_assign_policy]

Deploy Cedar rules scoped to a specific agent. These rules are evaluated in addition to workspace-level rules. Cedar `forbid` at workspace scope overrides `permit` at agent scope.

| Parameter  | Type   | Required | Description                                           |
| ---------- | ------ | -------- | ----------------------------------------------------- |
| `agent_id` | string | Yes      | agent ID to assign rules to                           |
| `files`    | array  | Yes      | Array of `{name, content}` objects — Cedar rule files |

> **Note**: Requires `rules.deploy`.

```json title="Example tool call"
{
  "name": "dome_agents_assign_policy",
  "arguments": {
    "agent_id": "code-reviewer",
    "files": [
      {
        "name": "agent-policy.cedar",
        "content": "permit(\n  principal,\n  action == Dome::Action::\"mcp:call\",\n  resource == Dome::MCPTool::\"code-search\"\n);"
      }
    ]
  }
}
```

### dome_agents_get_policies [#dome_agents_get_policies]

Get the Cedar rules currently assigned to a specific agent (agent-scope only; does not include inherited workspace/tenant/org rules). To see workspace rules, use `dome_rules_get_active`.

| Parameter  | Type   | Required | Description |
| ---------- | ------ | -------- | ----------- |
| `agent_id` | string | Yes      | agent ID    |

> **Note**: Requires `rules.view`.

## Next steps [#next-steps]

Write and simulate from Govern. Evaluation semantics and Cedar catalogs sit under Concepts and Reference:

* [Authorize Access](/govern/rules)
* [Authorization Model](/concepts/architecture/authorization-model) concept
* [Rules](/reference/controls/rules) reference