> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connector Access Control

> Control who can use which connectors, tools, and resources with access policies.

## Managing Access Policies

![Permissions](https://mintcdn.com/anysource/Ej18r8lFyFGBNupo/images/permissions.png?fit=max\&auto=format\&n=Ej18r8lFyFGBNupo\&q=85\&s=492a63adf7b36b5fc8403a718121f7ae)

After approving MCPs, you control who can access them through access rules. Runlayer's policy system combines fine-grained permissions with ease of use, achieving both **accuracy** and **least privilege** by default.

This page covers connectors. The same policies can also control who uses and manages agents, skills, plugins, artifacts, agent accounts, teams, and organization permissions. That is in early access; see [Agents, Skills, and More](https://docs.runlayer.com/access-control-resources.md).

***

## How Access Rules Work

Access rules grant permissions to users, groups, roles, or agent accounts for specific MCP servers. Each rule can include **multiple principals** of the same type — for example, several users or several groups in one rule.

**Applies To** (Who gets access):

* **User**: One or more individual employees by email/ID
* **Group**: One or more teams synced from your SSO (Engineering, Marketing, etc.)
* **Role**: One or more job functions or custom roles
* **Agent Account**: One or more machine-to-machine identities (see [Agent Accounts](https://docs.runlayer.com/platform-agent-accounts.md))
* **Attributes**: Match users or agent accounts by identity attributes (e.g., department, environment). User attributes sync from your IdP; agent account attributes are admin-managed. Attribute rules are subject-type-agnostic — assigning an attribute to an agent account makes it inherit every existing rule scoped to that attribute
* **Everyone**: Wildcard principal that matches all subjects, including users and agent accounts (typically used in global deny policies). An **Everyone** allow reaches every agent account too, even ones the connector was never added to; to grant only people, use groups. See [What an agent account can reach](https://docs.runlayer.com/platform-agent-accounts.md#org-wide-allows)

**Access Scope** (What they can access):

* **Entire Server**: Full access to all tools in the MCP
* **Specific Tools & Resources**: Fine-grained selection of individual tools

**Conditions** (Advanced - Optional):

* Add runtime rules based on tool arguments (e.g., restrict SQL queries to specific tables)
* Enforce network restrictions (e.g., corporate IP ranges only)
* Validate OAuth session properties (e.g., require verified accounts)
* Block specific MCP clients

This design ensures you can easily grant appropriate access while maintaining security through least privilege.

### How rules combine

Access rules aren't an ordered list like firewall rules. Runlayer doesn't read them top to bottom or stop at the first match:

* **No access by default.** Apart from a connector's creator and holders of the connector-management capability, who skip the policy check, a user or agent account reaches a connector or tool only when at least one allow rule matches them.
* **Allows add up.** Every matching allow rule counts, so a subject gets everything any of them grants. A broad rule, for example **Everyone** on the **Entire Server**, gives everyone full access, and narrower allow rules on the same connector stop restricting anyone.
* **Deny wins.** A matching deny rule, server-level or global, blocks the request even when an allow rule also matches.

To give one group less access than everyone else, don't add a narrow allow next to a broad one. Scope the broad allow to the groups that need it, or add a deny rule for the tools that group shouldn't use.

> [!NOTE]
>
> Policy conditions evaluate **runtime context** — tool arguments (`payload.*`), request metadata like IP and client, OAuth session state, tool annotations, and session history (`meta.session.*`). They do not perform semantic analysis of what the user is *trying* to accomplish. For intent-level monitoring — detecting when an agent's behavior diverges from the user's intent across a session — see [AgentGuard](https://docs.runlayer.com/agentguard.md).

***

## How Runlayer Enforces Least Privilege

Policies are one of several enforcement layers that work together. A request must pass all of them:

1. **Platform roles (FGA)** — control who can use platform features at all, like creating policies or managing connectors. See [Roles & Permissions](https://docs.runlayer.com/platform-roles.md).
2. **Access policies (PBAC)** — server-level allow/deny rules and global deny rules, evaluated by the proxy on every tool invocation (this page).
3. **Identity-scoped tokens** — [Agent Accounts](https://docs.runlayer.com/platform-agent-accounts.md) authenticate with their own credentials; M2M tokens enforce agent-account policies, and OBO tokens enforce the **intersection** of the agent's and the delegating user's policies.
4. **Runtime conditions** — argument, network, OAuth, annotation, and session-history checks applied at invocation time.

**Example — support agent using Slack:** an admin's Super Admin role lets them create the rule; a server-level rule grants the agent account access to only `list_channels`, `read_messages`, and `search_messages` on the Slack MCP; the agent's OBO token limits it to what the delegating user is also allowed; and a global deny with `meta.tool.annotations.destructiveHint EQUALS true` backstops everything. See also [Agents](https://docs.runlayer.com/platform-agents.md) for scoping agent workloads.

***

## Policy Types

Runlayer supports allow and deny permission policies, plus approval rules that layer on top. Agent configuration uses those same permissions for defaults, exceptions and hard blocks:

### Agent configuration policies

In the agent configuration beta, **Agent defaults** allows settings across the
workspace. Removing a setting makes it off by default; an explicit allow can
enable it for selected agents or owners. A deny blocks it even when an allow
exists. Only policy admins can write these rules.

Configuration actions use the `config:` prefix. An ordinary `*` grant, including
an owner's or super admin's grant, does not cover them. `config:*` explicitly
allows every setting; model and connector lists allow only the entries they name.

### Session content policies

A policy with the target **Sessions** decides who reads the prompts and tool calls of other people's sessions, by group, client or connector. See [Session content access](https://docs.runlayer.com/platform-session-content-access.md).

### Server-Level Policies

Manage access to specific MCP servers. Navigate to **Connectors → \[Server Name] → Policies** tab.

* **Scope**: One or more specific servers
* **Action**: Allow or Deny
* **Use for**: Granting access, fine-grained tool restrictions
* **Example**: Allow Finance group to use database query tools

### Global Policies

Organization-wide restrictions that apply everywhere. Navigate to **Settings → Policies**.

* **Scope**: All servers, tools, and resources (\*)
* **Action**: Deny only
* **Use for**: IP blocks, client restrictions, compliance requirements
* **Example**: Block all access from outside corporate network

> [!TIP]
>
> Use global policies for organization-wide security controls, and server-level policies for granting and managing access to specific resources.

### Human approval rules

> [!NOTE]
>
> Human approval rules are in **beta**. Contact your Runlayer account team to enable them.

Approval rules are a separate kind of policy. They do not grant access — they
add a human checkpoint on top of access a permission policy already granted. A
caller still needs an allow policy to reach a tool; the approval rule decides
whether a human has to sign off before the call runs.

* **Scope**: All connectors, or specific ones
* **Action**: Requires approval
* **Use for**: Sensitive tools that should stay available but never run unattended
* **Example**: Require approval before any tool annotated as destructive runs

Create them in **Settings → Policies → Add approval rule**, or per connector in
**Connectors → \[Server Name] → Policies → Add approval rule**. Conditions are optional: a
rule for Everyone with no conditions requires approval for every tool call in
its scope, which is the broadest form. Quick-start templates cover the common
cases (destructive tools, external network access, untrusted MCP clients).

By default the person the call runs for approves it themselves; you can't
route requests to an admin, a group or a backup approver yet. The one
alternative is to set the rule's **Approvers** to **External system**, which
hands its decisions to your own approval system (see
[External approval system](#external-approval-system)). See
[Who approves](https://docs.runlayer.com/platform-agents.md#hitl).

Approval rules match on tool calls only. Unlike permission policies they cannot
be narrowed to specific resources, because the approval prompt is raised from
the tool-call path.

For what happens once a rule matches — the run stopping at the call and the
requester being asked to decide — see
[human-in-the-loop approvals](https://docs.runlayer.com/platform-agents.md#hitl).

#### Unattended agents

Attended clients (Cursor, Claude Desktop, interactive Claude Code) get an
approval URL or an in-client card and wait. A run that nobody is watching
cannot act on either, so Runlayer treats it differently:

* No URL prompt or in-client card. The approver gets a **Slack DM** instead.
* The tool result is a **structured blocked payload** (see the contract below),
  not free text.
* The payload states the facts and the rules, and leaves the next step to
  the run's own instructions: wait and retry, or **end the turn** and report
  the `request_id` so an orchestrator can resume once a decision lands.

**How a run becomes unattended.** Any one of these is enough:

* The request carries the header `x-runlayer-unattended: true`. The value must
  be exactly `true` (case-insensitive); any other value counts as attended.
* The client is Claude Code `-p` or the Claude Agent SDK. These are detected
  automatically from their User-Agent; no header needed.
* The call uses an external [agent-account](https://docs.runlayer.com/platform-agent-accounts.md) token,
  standalone or on-behalf-of. Runlayer-hosted agent runs use agent-account
  tokens too but keep their own [approval flow](https://docs.runlayer.com/platform-agents.md#hitl).

**Sending the header.**

```toml Codex config.toml theme={null}
[mcp_servers.runlayer]
url = "https://<runlayer-host>/..."
http_headers = { "x-runlayer-unattended" = "true" }
# or per run, from an environment variable (unset variable = header not sent):
env_http_headers = { "x-runlayer-unattended" = "RUNLAYER_UNATTENDED" }
```

```json Claude Code MCP config (optional, auto-detected) theme={null}
{
  "mcpServers": {
    "runlayer": {
      "type": "http",
      "url": "https://<runlayer-host>/...",
      "headers": { "x-runlayer-unattended": "${RUNLAYER_UNATTENDED:-false}" }
    }
  }
}
```

```typescript OpenAI Agents SDK / Claude Agent SDK theme={null}
headers: {
  "x-runlayer-api-key": process.env.RUNLAYER_API_KEY!,
  "x-runlayer-unattended": "true"
}
```

In the Claude Code snippet an unset variable sends `false`, which is treated as
attended. SDK examples add the header next to `x-runlayer-api-key` in the same
`headers` map shown in [Agent frameworks](https://docs.runlayer.com/agent-frameworks.md).

**Payload contract.** The tool result is an error result whose single text
item is this JSON object. The **field names are the stable contract**; the
`message` and `guidance` prose may change at any time, so never match on it.

| Field | Values | Meaning |
| - | - | - |
| `code` | `approval_required` \| `approval_denied` \| `approval_unavailable` \| `approval_metadata_unavailable` | Present on every blocked result. Check this first: pending, denied, no approver could be reached, or the tool's metadata could not be verified (refresh the connector). |
| `message`, `guidance` | human text | Not stable. Show to humans, do not parse. `guidance` is present on pending results only. |
| `default_decision` | `deny` | What happens if nobody decides. |
| `retryable` | `false` | Retrying the call before a decision returns the same payload. |
| `type` | `user_action_required` | Pending only. Marks a request a human has to act on. |
| `request_id` | string or `null` | Pending only. Record it; you need it to resume. |
| `session_id` | string or `null` | Pending only. The session the call was held in, echoed from `x-runlayer-session-id`; `null` when the call had none. |
| `url` | string or `null` | Pending only. Approval page link for a human who wants to decide in the browser. |
| `expires_at` | ISO 8601 timestamp or `null` | Pending only. When the pending request lapses. |
| `mode` | `unattended` | Pending only. Which flow produced this payload. |
| `delivery` | `slack_dm` \| `url_only` \| `external` | Pending only. `slack_dm`: a Slack DM to the approver is confirmed. `url_only`: no DM is confirmed (it failed, or an earlier attempt is still sending it), so only the link is certain. `external`: your [external approval system](#external-approval-system) decides. |

"Pending only" fields appear when `code` is `approval_required`. Denied and
unavailable results carry just `code`, `message`, `default_decision` and
`retryable`.

**Resuming after a decision.** Runlayer matches the retry against the original
request by session id, client, and arguments, so resume the same session
rather than starting a new one. The session is the `x-runlayer-session-id`
header; send a UUID (any other value is canonicalised to one), and the payload
echoes it as `session_id` next to `request_id`:

1. One pattern for orchestrated runs: a hook spots `code == "approval_required"`,
   records `request_id` and the session id, and ends the run.
2. Wait for the decision: an [agent runtime webhook](#agent-runtime-webhook),
   the Slack DM, the webapp **Inbox**, or poll
   `GET /api/v1/approvals` with the approver's own user API key until the
   request leaves the pending list. Agent-account and on-behalf-of tokens
   cannot call this endpoint. The list only shows pending requests waiting on
   that user and does not say whether one was approved, denied, or expired;
   the retry result tells you (success, or `code` `approval_denied`).
   With `delivery` `external` the request is never in that list, so polling it
   would read a pending request as decided: wait for the agent runtime
   webhook's `approval.approved` or `approval.denied` event, or for your
   approval system to report its own decision.
3. Resume the same session and retry the identical call:

```bash theme={null}
codex exec resume <session_id> "Approval granted. Retry the exact same call."
# or
claude -p --resume <session_id> "Approval granted. Retry the exact same call."
```

**Windows.** A pending request lives 24 hours. An approval lets the identical
call through once within 1 hour. A denial blocks identical retries for 15
minutes.

**Who approves.** The requester; for on-behalf-of agent tokens, the delegating
user. They need a linked Slack account, otherwise `delivery` is `url_only` and
someone must open the link. Standalone agent-account (machine-to-machine) calls
cannot be approved today; use on-behalf-of tokens for approval-gated tools.
When the rule's approvers are your
[external approval system](#external-approval-system), that system decides:
no Runlayer user approves, so linked Slack and `url_only` don't apply, and
`delivery` is `external`.

#### Agent runtime webhook

Runlayer can POST the approval events of [unattended](#unattended-agents) runs
to an HTTPS endpoint you run, so your runtime manager resumes a session as soon
as someone decides instead of polling. It is a workspace-wide setting, reached
from any rule that requires approval: open the rule in **Settings → Policies**
and follow the **Approval settings** link under **Approvers** (requires
**Manage security policies**). There you set a public HTTPS URL and optional
custom headers, for example your receiver's API key. The signing
secret is shown once, when you add the endpoint or regenerate the secret.
Regenerating has no overlap: the old secret stops verifying at once and queued
retries are signed with the new one, so update your receiver right away.
**Send test** posts the endpoint's [request body](#webhook-request-body)
rendered over a sample request, signed, and shows your receiver's status code
and the body it sent.

**Who owns the endpoint.** The endpoint, its signing secret and its custom
headers belong to the workspace, not to the admin who saved them.
Deactivating or deleting that admin leaves the endpoint live: Runlayer keeps
posting events, with the stored headers, to the configured URL, and the secret
they were shown still verifies. Deleting the workspace deletes the endpoint.
When an admin with **Manage security policies** leaves, regenerate the secret
or delete the endpoint, and rotate any receiver key in the custom headers. The
organization-settings-updated audit event records who saved or changed it.

**Events.** `approval.requested` when an unattended call is held,
`approval.approved` and `approval.denied` when the approver decides. Attended
calls send nothing. A call made with an external agent-account token,
standalone or on behalf of a user, counts as unattended even without the
header, so it sends events too. Runlayer-hosted agent runs keep their own
approval flow and send none. Each event's body is the endpoint's
[request body](#webhook-request-body).

**Verifying.** Requests follow [Standard Webhooks](https://www.standardwebhooks.com/):
`webhook-id` (a stable event ID), `webhook-timestamp` and `webhook-signature`
(`v1,<base64 HMAC-SHA256>` of `<webhook-id>.<webhook-timestamp>.<body>`,
keyed with your `whsec_` secret), plus `Content-Type: application/json` and
your custom headers, which cannot replace these. The signature covers the
rendered body, so verify it over the raw bytes you receive. Verify with any
Standard Webhooks library and reject timestamps older than 5 minutes.

**Delivery.** A `2xx` response is success. Timeouts, connection errors, `408`,
`429` and `5xx` are retried after about 1, 5, 15 and 60 minutes (5 attempts);
other `4xx` responses are not retried. Redirects (`3xx`) are not followed
and not retried. Delivery is at-least-once and
unordered: retries reuse the same `webhook-id`. `approval.approved` and
`approval.denied` are retried on the full schedule even if the grant or
denial window has already lapsed. `approval.requested` is delivered only while
the request is still pending, so a late retry of a request that was already
decided is dropped. Dedupe on
`webhook-id` and reconcile on `status`. A retry renders the endpoint's
current template, under the same `webhook-id`. There is no expiry event: a
pending request lapses 24 hours after `approval.requested`, so run your own
timer. If every attempt fails, resume the session anyway: the retried call
returns the decision.

##### Request body

The agent runtime webhook has a body template: a JSON document with
`{{name}}` placeholders that Runlayer fills in for every request it sends. A
new endpoint starts from this default, which you can edit to match the
contract your receiver already has:

```json theme={null}
{
  "type": "{{event_type}}",
  "data": {
    "request_id": "{{request_id}}",
    "status": "{{status}}",
    "session_id": "{{session_id}}",
    "server_id": "{{server_id}}",
    "server_name": "{{server_name}}",
    "tool_name": "{{tool_name}}",
    "url": "{{url}}"
  }
}
```

| Variable | Value |
| - | - |
| `request_id` | Runlayer's ID for the approval request |
| `session_id` | The session from `x-runlayer-session-id` (canonical form), or `null` |
| `event_type` | `approval.requested`, `approval.approved` or `approval.denied` |
| `status` | `pending`, `approved` or `denied` |
| `server_id` | The connector's ID, the same one as in its `/servers/<id>` URL, or `null` |
| `server_name`, `tool_name` | The connector and tool of the held call |
| `url` | The approval page in Runlayer |

For example, a receiver that expects its own field names:

```json theme={null}
{
  "runtime_request_id": "{{session_id}}",
  "runlayer_request_id": "{{request_id}}",
  "approval_response": {
    "status": "{{status}}",
    "note": "{{tool_name}} on {{server_name}}"
  }
}
```

* A string that is exactly one placeholder, like `"{{session_id}}"`, takes the
  value as is: a missing value is JSON `null`. A placeholder inside a longer
  string, like `"{{tool_name}} on {{server_name}}"`, is replaced by its text,
  and a missing value by an empty string.
* Values are JSON-escaped, so they can never break the document. Placeholders
  only work in values, not in keys. There are no expressions or filters.
* Templates are checked when you save: invalid JSON, more than 16 KB, or an
  unknown variable is rejected with the JSON path at fault.
* **Header values** can use `{{request_id}}`, `{{session_id}}`,
  `{{event_type}}` and `{{status}}`, for example
  `X-Session-Id: {{session_id}}`. Other variables aren't allowed in headers.
* **Send test** renders the template over a sample request (`event_type` is
  `webhook.test`, `status` is `pending`) and shows the body it sent.

#### External approval system

> [!NOTE]
>
> External approval systems are in **beta**. They need [human approval
> rules](#human-approval) and the [unified policy engine](https://docs.runlayer.com/access-control-resources.md) on
> your workspace, and the **External system** option is in the new policy
> builder. If you don't see it under **Approvers**, contact your Runlayer
> account team.

An approval rule can hand its decisions to your own approval system (Okta
Workflows, Jira Service Management, ServiceNow, or a service you run) instead
of the requester. Set the rule's **Approvers** to **External system**, then add
the endpoint in **Approval settings**, next to the
[agent runtime webhook](#agent-runtime-webhook) (requires **Manage security
policies**). Only holds from a rule whose approvers are External system go to
it; every other hold, including one Runlayer requires on its own, stays with
the requester. No Runlayer user can decide these requests: the Runlayer
approval page is read-only for them. The Connection Tester's **Run tool**
refuses a tool these rules hold (`approval_connection_tester_unsupported`):
call it from a client instead.

**The request.** When a matching call is held, Runlayer POSTs one request to
your endpoint, signed and verified like the agent runtime webhook (Standard
Webhooks headers, your custom headers). **Send test** posts a `webhook.test`
event instead, so it checks delivery only.

```json theme={null}
{
  "id": "evt_5b1f0c2e9a4d4f7e8c3b2a1d0e9f8a7b",
  "type": "approval.requested",
  "occurred_at": "2026-10-26T12:00:00+00:00",
  "data": {
    "request_id": "3d6f1a2b-…",
    "session_id": "6f1c2d3e-4b5a-4c6d-8e7f-9a0b1c2d3e4f",
    "server_id": "9b2e4c6a-1d3f-4a5b-8c7d-0e1f2a3b4c5d",
    "server_name": "Linear",
    "tool_name": "create_issue",
    "url": "https://<runlayer-host>/approvals/3d6f1a2b-…",
    "expires_at": "2026-10-27T12:00:00+00:00",
    "requester_email": "dev@example.com",
    "arguments_preview": "{\"title\": \"Rotate the staging keys\"}",
    "arguments": { "title": "Rotate the staging keys" },
    "decision_url": "https://<runlayer-host>/api/v1/approvals/3d6f1a2b-…/external-decision?token=…",
    "approve_url": "https://<runlayer-host>/api/v1/approvals/3d6f1a2b-…/external-decision/approve?token=…",
    "deny_url": "https://<runlayer-host>/api/v1/approvals/3d6f1a2b-…/external-decision/deny?token=…"
  }
}
```

`server_id` is the connector's ID, as in its `/servers/<id>` URL.
`session_id`, `server_id`, `server_name`, `tool_name`, `requester_email` and
`arguments_preview` (the redacted preview the approval page shows, cut for
display such as a ticket title) can be `null`. `arguments` is the call's
arguments whole, as a JSON object, with credentials masked as in the preview:
decide on it, not on the preview. A call whose masked arguments are over
64 KiB of JSON is never sent: Runlayer refuses it with `approval_unavailable`
and keeps nothing. `url` is the Runlayer page for the request; only the
requester can open it. `decision_url`, `approve_url` and `deny_url`
carry the same token and are each a credential for this one request: keep
them in private flow state, never in a field the requester can read (a ticket
description, a request form), or the requester can decide their own call.

**Answering.** Within 20 seconds, answer `2xx` with a JSON body
(`Content-Type: application/json`, at most 16 KiB):

```json theme={null}
{ "approval_url": "https://approvals.example.com/requests/123" }
```

`approval_url` is your review page, shown to the requester. It is optional
(`{}` takes the request without a link) and must be a plain `https` URL of at
most 2,048 characters, with no credentials. Other keys are ignored. A `2xx`
whose body Runlayer can't use (not JSON, or an invalid `approval_url`) still
takes the request, as `{}`: no link is shown, and your decision still lands
through `decision_url`. Only these refuse the call with
`approval_unavailable` and keep nothing, so the next call asks again: a
timeout, a non-`2xx` status, a redirect (not followed), a connection error, a
body over 16 KiB or content-encoded, or no endpoint configured. The request
is not retried.

**Deciding.** POST to one of the request's URLs exactly as received, before
the request's `expires_at` (at most 24 hours). To `decision_url`, with the
decision in the body:

```json theme={null}
{
  "decision": "approve",
  "decided_by": { "email": "approver@example.com" },
  "reason": "Approved in ITSM-123"
}
```

Or, to wire one URL per button, to `approve_url` or `deny_url`: the URL is the
decision, and the body is optional (empty, or `{"decided_by": …, "reason": …}`
without `decision`).

`decision` is `approve` or `deny`. `decided_by` is optional: the approver's
login as your system knows it. Runlayer stores it as given, records it in the
audit log, and shows it with your approval system's name; it isn't linked to a
Runlayer user. `reason` is optional and kept in the audit log as part of the
body as received. A `decided_by` or `reason` Runlayer can't read is dropped
and the decision still counts; the audit log keeps the body as received. All
three URLs answer the same way:

```json theme={null}
{
  "request_id": "3d6f1a2b-…",
  "status": "approved",
  "decided_at": "2026-10-26T12:05:00+00:00"
}
```

| Status | Meaning |
| - | - |
| `200` | Decided, or the same decision repeated (a retried call). |
| `400` | Malformed `Content-Length`. |
| `401` | Missing, invalid or expired token, including a retry after `expires_at`. |
| `404` | Unknown request, or one not routed to your approval system. |
| `408` | Body not fully received within 60 seconds. |
| `409` | Already decided otherwise, expired or cancelled; `detail.status` says which. |
| `413` | Body over 16 KiB. |
| `422` | On `decision_url`, `decision` missing or not `approve`/`deny`; on `approve_url` or `deny_url`, any `decision` key; or an unknown top-level key. Never for attribution: a `decided_by` or `reason` Runlayer can't read is dropped and the decision still counts. |
| `429` | Rate limited; retry later. |

An approval lets the identical call through once, with no "Approve always":
the requester retries the same call. Deleting the endpoint refuses new calls
that need external approval; pending requests can still be decided until they
expire. Unattended runs get the usual
[blocked payload](#unattended-agents) with `delivery` `external`, and an agent
runtime webhook's events for these requests carry your `approval_url` as `url`
(or `null`).

***

## Creating Access Rules

**1. Navigate to MCP Policies**

Go to the MCP you want to grant access to → **Policies** tab

**2. Click 'New Access Rule'**

Opens the access rule creation dialog

**3. Select Who Gets Access**

Choose a principal type (**User**, **Group**, **Role**, **Agent Account**, or **Attributes**), then select one or more from the dropdown. A single rule can include multiple principals of the same type.

**4. Define Access Scope**

Choose between:

* **Entire Server**: Grant access to all tools (faster, simpler)
* **Specific Tools & Resources**: Select individual tools (more secure, granular)

**5. Add Rule**

Click "Add Rule" to save - takes effect immediately

### Through the API

`POST /api/v1/policies` creates the same rule. The example uses the `RUNLAYER_URL` and `API_KEY` conventions from the [access control recipes](https://docs.runlayer.com/cookbook-access-control.md#prerequisites), which also show how to look up the IDs.

```bash theme={null}
curl -s -X POST "$RUNLAYER_URL/api/v1/policies" \
  -H "x-runlayer-api-key: $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "principal": { "type": "group", "ids": ["'$GROUP_ID'"] },
    "kind": "permission",
    "action": "allow",
    "scope": { "servers": ["'$SERVER_ID'"], "tools": "*", "resources": "*" },
    "description": "Support group can use the Slack connector",
    "conditions": []
  }' | jq '{id, principal, action}'
```

`principal` accepts `user`, `group`, `role`, `agent` (an agent account), `attributes`, or `any` (shown as Everyone in the UI). `action` is `allow` or `deny`. `scope` names servers, tools, and resources (`*` for all).

***

## Access Rule Examples

### Team-Wide Server Access

**Scenario**: Give engineering and devops teams access to the GitHub MCP

```
Applies To: Group "Engineering", Group "DevOps"
Access Scope: Entire Server
Result: All members of both groups can use every tool in the GitHub MCP
```

**When to use:**

* Multiple teams need comprehensive access
* Server tools are all appropriate for the groups
* Simplicity is preferred over granularity

***

### Fine-Grained Tool Access

**Scenario**: Give finance analysts read-only access to the Database MCP

```
Applies To: Group "Finance"
Access Scope: Specific Tools & Resources
Selected Tools:
  - list_tables
  - query_database
  - read_schema
Result: Finance can only query and read, not modify data
```

**When to use:**

* Sensitive MCPs require least privilege
* Only specific tools are needed
* Different roles need different capabilities

> [!NOTE]
>
> This is how admins approve or deny **individual tools inside an already-approved connector**: [connector approval](https://docs.runlayer.com/platform-approvals.md) decides whether the server is available at all, then server-level rules with **Specific Tools** scope (allow or deny) control each tool, enforced at invocation time and effective immediately. For a human checkpoint on specific tool calls during agent runs, see [human-in-the-loop approvals](https://docs.runlayer.com/platform-agents.md#hitl).

***

### Annotation-Based Access (Read-Only Tools)

**Scenario**: Give data analysts access to all tools, but only allow read-only ones at invocation time

```
Applies To: Group "Data Analysts"
Access Scope: Entire Server
Conditions:
  - meta.tool.annotations.readOnlyHint EQUALS true
Result: Data Analysts can see all tools, but can only invoke
        tools annotated as read-only
```

**When to use:**

* Restrict access based on tool capabilities (read-only, destructive, etc.)
* Enforce safety boundaries at invocation time
* Works across any server with annotated tools

***

### Individual User Access

**Scenario**: Give a contractor temporary access to specific Slack tools

```
Applies To: User "contractor@company.com"
Access Scope: Specific Tools & Resources
Selected Tools:
  - list_channels
  - read_messages
  - search_messages
Result: Contractor can read but not post or manage Slack
```

**When to use:**

* Individual exceptions needed
* Temporary access for specific users
* Contractors or external collaborators
* Testing new MCPs with a single user first

***

### Conditional Access by Tool Arguments

**Scenario**: Allow finance team to query only sales and finance tables

```
Applies To: Group "Finance"
Access Scope: Specific Tools
Selected Tools: query_sql
Conditions:
  - payload.table BEGINS_WITH ["sales_", "finance_"]
Result: Finance can query sales_* and finance_* tables only
```

**When to use:**

* Database access needs table-level restrictions
* File systems need path-based access control
* APIs need parameter validation
* Sensitive data requires fine-grained control

***

### Global Policy: Block External IPs

**Scenario**: Require all users to access MCPs from corporate network

```
Location: Settings → Policies (Global)
Applies To: Everyone
Action: Deny
Scope: All servers, tools, resources (*)
Conditions:
  - meta.request.ip NOT_IN_IP_RANGE ["10.0.0.0/8", "172.16.0.0/12"]
Result: Any access from outside corporate IPs is blocked
```

**When to use:**

* Compliance requires network-based access control
* Remote work must use VPN
* Sensitive data needs IP restrictions
* Organization-wide security policy

***

### Restrict Gmail to Internal Recipients Only

**Scenario**: Prevent outgoing Gmail messages to external recipients, allowing only emails sent to your internal domain (e.g., `@runlayer.com`)

```
Location: MCP -> Connectors → Gmail → Policies tab
Applies To: Group "Everyone" (or specific teams)
Action: Deny
Access Scope: Specific Tools
Selected Tools:
  - send_email
  - send_draft
Conditions:
  - payload.to NOT_ENDS_WITH "@runlayer.com"
Result: Users can only send emails to @runlayer.com addresses;
        attempts to email external domains are blocked
```

> [!TIP]
>
> You can extend this policy to also check `payload.cc` and `payload.bcc` fields using additional condition rules to ensure internal-only communication across all recipient types.

**When to use:**

* Prevent data exfiltration via email in AI agent workflows
* Enforce internal-only communication for sandbox or development environments
* Provide guardrails for agents with Gmail access
* Meet compliance requirements for regulated data
* Test new AI workflows safely before allowing external communication

***

### Block Tools That Accept Sensitive Parameters

**Scenario**: Prevent any tool that requires a `password` parameter from being invoked

```
Location: Settings → Policies (Global)
Applies To: Everyone
Action: Deny
Scope: All servers, tools, resources (*)
Conditions:
  - meta.tool.input_schema.required LIST_CONTAINS password
Result: Any tool whose JSON Schema lists "password" as a
        required field is blocked at invocation time
```

**When to use:**

* Prevent credential-handling tools from running without approval
* Block tools with dangerous parameter shapes (e.g., `sql`, `command`)
* Works with any `meta.tool.input_schema.*` subfield (e.g., `type`, `required`)

> [!NOTE]
>
> `input_schema` is the tool's JSON Schema object. Use dot-path subfields
> like `meta.tool.input_schema.required` with the `list_contains` operator,
> or `meta.tool.input_schema.type` with `equals`.

***

### Block Destructive Tools Organization-Wide

**Scenario**: Prevent all users from invoking tools that may delete or overwrite data

```
Location: Settings → Policies (Global)
Applies To: Everyone
Action: Deny
Scope: All servers, tools, resources (*)
Conditions:
  - meta.tool.annotations.destructiveHint EQUALS true
Result: Any tool marked as destructive is blocked at invocation time
```

**When to use:**

* Enforce safety boundaries across the organization
* Protect production data from accidental deletion
* Compliance requirements for data preservation
* Gradual rollout (start with deny-all, grant exceptions)

**Where annotations come from:** `readOnlyHint`, `destructiveHint`, `idempotentHint`, and `openWorldHint` are standard MCP tool annotations declared by the MCP server author in each tool's definition. Runlayer reads them from the server's tool listing and exposes them as `meta.tool.annotations.*` at invocation time. An annotation-based policy only matches tools whose server actually declares the annotation — for unannotated or untrusted servers, combine with name-based conditions (e.g., `meta.tool.name REGEX "(?i).*(delete|remove|drop).*"`; a condition regex must match the whole name, so `delete|remove|drop` alone only matches a tool named exactly `delete`) or explicit **Specific Tools** scoping.

***

### Dynamic Value References (`$meta.*` / `$payload.*`)

Condition values can reference runtime context dynamically by prefixing with `$`. This enables policies that compare one context field against another — for example, comparing a tool argument against values recorded earlier in the session.

**Supported prefixes:**

* `$payload.<field>` — Resolves to the current tool call's argument value
* `$meta.<path>` — Resolves to any `meta.*` context field

A reference is the whole value. Nothing is filled into a longer string: `$meta.server.id:tool:create_issue` looks for a field with that literal name and never matches.

**Behavior when a reference cannot be resolved:**

* If the referenced path doesn't exist (e.g., the tool argument isn't present), the rule **fails** (does not match) — even for negated operators like `not_equals` or `list_not_contains`. This prevents accidental allows when data is missing.

**Example:**

```
Condition rule:
  field: meta.session.payload_values_used.repo
  operator: list_not_contains
  value: $payload.repo
```

This rule matches when the current `repo` argument has **not** been used earlier in the session.

***

### Session Payload Tracking

Runlayer can track which distinct tool argument values an agent uses during a session. Combined with deny policies and dynamic value references, this enables **session isolation** — once an agent accesses a resource (e.g., a specific repository), it cannot access different ones for the rest of the session.

**How it works:**

1. A deny policy references `$payload.<field>` in its value — this tells Runlayer to track that field
2. On each allowed tool call, the argument's value is recorded for the current session
3. On subsequent calls, `meta.session.payload_values_used.<field>` contains all previously-used distinct values
4. The deny policy evaluates against that list to block divergent values

> [!NOTE]
>
> Tracking is limited to the argument names your active policies reference, and records distinct values only (no counts or ordering).
> Only top-level scalar arguments are tracked. Nested references such as `$payload.folder.id` resolve for the current call, but are not recorded in session history; `meta.session.payload_values_used.folder.id` cannot enforce isolation across calls.

***

### Repository Isolation (Need-to-Know)

**Scenario**: Once an agent accesses a repository, block all other repositories for the rest of the session. Prevents context leakage across repos in shared agent sessions.

```
Location: MCP → [GitHub Server] → Policies tab
Applies To: Agent Account "Code Agent" (or Everyone)
Action: Deny
Access Scope: Entire Server
Conditions (all rules in one group — AND logic):
  - meta.session.payload_values_used.repo LIST_NOT_CONTAINS $payload.repo
  - meta.session.payload_values_used.repo LIST_REGEX ".+"
Result: After the first tool call with a "repo" argument, any call
        with a different "repo" value is denied
```

**How the two rules work together:**

| Rule | Purpose |
| - | - |
| `list_not_contains $payload.repo` | Current repo is not in the set of previously-used repos |
| `list_regex ".+"` | At least one repo has been used before (prevents blocking the very first call) |

Both rules must match (AND) for the deny to activate. On the first call, the second rule fails (no previous values), so the call is allowed and the repo is recorded. On subsequent calls with the *same* repo, the first rule fails (it IS in the list), so the deny doesn't activate. On calls with a *different* repo, both rules match and the call is denied.

> [!NOTE]
>
> For [Runlayer agents](https://docs.runlayer.com/platform-agents.md), each run is its own session: every connector call in a run carries the run's session ID, and continuing a conversation keeps the session of the run it continues. A new run starts with no repository recorded, so one agent can work on a different repository in each run while every single run stays on one.

> [!TIP]
>
> Edit the field name (`repo`) to match your MCP server's argument name — common alternatives include `repository`, `project`, or `owner/repo`. The same pattern works for any field: `database`, `account_id`, `workspace`, etc.

***

### Limit bulk actions and runaway agents

**Scenario**: Stop an assistant or agent from sending a message to many Slack channels or people, or from deleting Jira issues in a loop, while normal use keeps working.

> [!WARNING]
>
> Connector rules don't count calls. [Rate-limit policies](https://docs.runlayer.com/access-control-resources.md#approvals-and-rate-limits), in early access, cap calls per user, session, or organization in a minute, hour, or day. There's still no cap of "N actions, then ask a human", and no limit on how many items one bulk call touches. Without rate-limit policies, the only rate limit is the platform abuse ceiling of 600 MCP requests a minute per credential (see [Rate Limiting](https://docs.runlayer.com/mcp-troubleshooting.md)). Use the rules below to make each risky call need a person, or to keep it inside a known set.

**Require a person for every destructive call.** Approval allows one retry of that exact call, so an agent in a delete loop needs a new approval for each issue. The Atlassian connector sends deletes through `executeDestructive`, which declares `destructiveHint`.

```
Location: Settings → Policies → Add approval rule (or Deny rule to block outright)
Applies To: Everyone
Conditions:
  Group 1:
    - meta.tool.annotations.destructiveHint EQUALS true
    - meta.actor.id REGEX ".+"
  Group 2 (OR), for servers that don't annotate their tools:
    - meta.tool.name REGEX "(?i).*(delete|remove|drop).*"
    - meta.actor.id REGEX ".+"
Result: destructive calls made by an agent account pause for approval;
        people calling the same tools directly, and read-only tools, are unaffected
```

Drop the `meta.actor.id` rules to cover people too. [Approval rules](#human-approval) are in beta. An agent account calling with no user behind it (M2M) has no one to approve, so its call is refused.

**Keep Slack messages inside known destinations.** These rules read the `channel_id` argument of `slack_send_message` and `slack_schedule_message` ([Slack connector](https://docs.runlayer.com/servers/slack-official.md)), so scope them to those two tools. A DM is a `channel_id` that starts with `D`, `U` or `W`.

```
Block DMs:              payload.channel_id REGEX "[DUW].*"
Only approved channels: payload.channel_id NOT_REGEX "C0AAAAAAA|C0BBBBBBB"
```

**One destination per session.** This Deny rule lets an agent message one channel or person per session and blocks the next new one, like [repository isolation](#repository-isolation):

```
Conditions (one group, AND):
  - meta.session.payload_values_used.channel_id LIST_NOT_CONTAINS $payload.channel_id
  - meta.session.payload_values_used.channel_id LIST_REGEX ".+"
```

Session rules only see calls that carry a session ID. Runlayer agents send one on every call (each run is one session). Calls without one, for example Claude or ChatGPT connected straight to a connector URL, never match, so use the approval or destination rules for those clients. Use a Deny rule here: approval rules don't record argument values.

**Stop it while it runs.** Stop the session, cancel the run, or turn off the agent account, as in [Respond to a compromised agent](https://docs.runlayer.com/platform-agent-accounts.md#compromised-agent). Agent [run limits and cost budgets](https://docs.runlayer.com/platform-agents.md#usage-limits) only reject new runs.

**Close other paths.** Rules apply only to calls that go through Runlayer. Native connectors that Claude or ChatGPT host in their own cloud skip them; restrict those at the vendor and in the client, as in [Lock down other paths](https://docs.runlayer.com/cross-app-access#lock-down-other-paths).

***

## Condition Field Reference

Every field you can use in a condition, with sample values. Fields marked **invoke-only** are evaluated at tool-invocation time and are not available during tool discovery (listing).

### Tool Arguments (`payload.*`)

| Field | Description | Example |
| - | - | - |
| `payload.<arg>` | Any top-level argument of the tool being called, referenced by name. | `payload.table` = `users`, `payload.path` = `/etc/passwd` |
| `payload.<arg>.<field>` | A field inside an object argument. `payload.folder.id` reads `id` inside `folder` for a call like `{"folder": {"id": 37009}}`. Numbers compare as text, so the rule value is `37009`. If the call has `folder` but no `id` inside it, the field is missing: a separate `"folder.id"` argument isn't read. List items aren't reachable. | `payload.folder.id` = `37009` |

> [!NOTE]
>
> Server-scoped payload conditions cannot be used with connectors that have **Skip Tool Input Validation** enabled (global wildcard policies can still use them).

### Request Context (`meta.request.*`)

| Field | Description | Example |
| - | - | - |
| `meta.request.ip` | Client IP address as your deployment's own proxy saw it: the `X-Forwarded-For` entry it appended (or `CLIENT_IP_HEADER` when configured), never an earlier entry the caller sent. Behind a corporate forward proxy this is the proxy's egress address, not the workstation's | `203.0.113.42` |
| `meta.request.user_agent` | HTTP User-Agent header for client identification | `claude-code/1.2.0` |
| `meta.request.method` | HTTP request method | `POST` |
| `meta.request.path` | Request URL path | `/mcp/github` |

### Subject Attributes (`meta.subject.*`)

| Field | Description | Example |
| - | - | - |
| `meta.subject.type` | Subject type (`user` or `agent`) | `user` |
| `meta.subject.id` | Subject UUID (user or agent ID) | `8f14e45f-ceea-467f-a7ce-16f5f8ab1c2d` |
| `meta.subject.email` | Email (users only, null for standalone agents) | `jane@acme.com` |
| `meta.subject.name` | Subject display name | `Jane Doe` |
| `meta.subject.roles` | Assigned roles | `Super Admin` |
| `meta.subject.groups` | Group memberships | `Engineering` |
| `meta.subject.organization_id` | Subject's organization UUID | `1c9a7e6b-2d3f-4a5b-8c7d-9e0f1a2b3c4d` |
| `meta.subject.attributes` | Identity attributes — IdP-synced for users, admin-managed for agent accounts. For standalone agents this is the agent's own attribute bag | `attributes.department` = `Finance` |
| `meta.user.*` | Deprecated alias for `meta.subject.*` (backward compatibility) | — |

### Acting Agent (`meta.actor.*`)

Set only when an [Agent Account](https://docs.runlayer.com/platform-agent-accounts.md) is making the call. For OBO (on-behalf-of) tokens, `meta.subject.*` stays the delegating user while `meta.actor.*` is the agent — so one rule can constrain both identities (e.g., require `meta.actor.attributes.environment` = `production` AND `meta.subject.attributes.department` = `Finance`). For non-agent subjects these fields are absent: positive operators (`equals`, `contains`, ...) never match, but negative operators treat the absent value as satisfied — a deny with `meta.actor.attributes.environment` `not_equals` `production` fires for every plain-user call too. Pair negative `meta.actor.*` rules with `meta.subject.type` = `agent` to scope them to agent traffic.

| Field | Description | Example |
| - | - | - |
| `meta.actor.id` | Agent account UUID | `8f14e45f-ceea-467f-a7ce-16f5f8ab1c2d` |
| `meta.actor.name` | Agent account display name | `Support Agent` |
| `meta.actor.organization_id` | Agent's organization UUID | `1c9a7e6b-2d3f-4a5b-8c7d-9e0f1a2b3c4d` |
| `meta.actor.attributes` | Admin-managed identity attributes of the agent account | `attributes.environment` = `production` |

### Client Provenance (`meta.client.*`)

How the MCP client obtained its Runlayer credentials. Set only for [connector OAuth clients](https://docs.runlayer.com/connector-oauth-clients.md); absent for dashboard sessions, API keys and agent-account tokens (same absent-value semantics as `meta.actor.*`).

| Field | Description | Example |
| - | - | - |
| `meta.client.kind` | Proxy OAuth client kind: `dcr`, `cimd`, `pre_registered`, `manual`, `ema`, `agent` | `dcr` |

The per-connector DCR / CIMD switches govern **direct** connections only. A self-registered client can still reach the connector through a plugin's `execute_tool`. To apply the same restriction on every path, write a deny on the connector with `meta.client.kind` `regex` `dcr|cimd`. Pre-registered clients and agent accounts are unaffected.

### Access Path (`meta.plugin.*`)

Whether the connector is reached directly or through an aggregate endpoint — a plugin (`execute_tool`), the Runlayer Plugin, or an agent account's aggregate endpoint. Absent when the connector is called directly.

| Field | Description | Example |
| - | - | - |
| `meta.plugin.id` | Aggregate (plugin or agent-account) UUID when accessed via one | `3f2b1c0d-9e8a-4b7c-a6d5-e4f3a2b1c0d9` |

| Intent | Rule | |
| - | - | - |
| Self-registered clients blocked from a connector only via plugins | `meta.client.kind` `regex` \`dcr | cimd`AND`meta.plugin.id` `regex` `.+\` |
| Block connector via **any** plugin, for everyone | `meta.plugin.id` `regex` `.+` | |
| Block connector via one plugin | `meta.plugin.id` `equals` `<plugin uuid>` | |
| Allow **direct** access only | `meta.plugin.id` `not_regex` `.+` | |

> [!WARNING]
>
> Absent satisfies every negated operator, so a deny on `meta.plugin.id` `not_equals` `<A>` also fires for **direct** calls, and one on `meta.client.kind` `not_equals` `pre_registered` fires for dashboard and agent traffic too. Prefer positive `regex` matches, or AND with a `regex` `.+` presence check.

### Server Attributes (`meta.server.*`)

| Field | Description | Example |
| - | - | - |
| `meta.server.id` | MCP server UUID | `5a2b8c1d-7e4f-4a6b-9c8d-0e1f2a3b4c5d` |
| `meta.server.name` | MCP server display name | `GitHub` |
| `meta.server.deployment_mode` | Server deployment mode | `hosted` |
| `meta.server.auth_type` | Authentication type | `oauth` |
| `meta.server.url` | Server URL | `https://api.githubcopilot.com/mcp/` |

### OAuth Context (`meta.oauth.*`)

| Field | Description | Example |
| - | - | - |
| `meta.oauth.provider` | OAuth identity provider | `google` |
| `meta.oauth.scopes` | Granted OAuth scopes (list) | `repo`, `read:user` |
| `meta.oauth.token_expires_at` | OAuth token expiry timestamp | `2026-08-04T12:00:00Z` |

### Tool Context (`meta.tool.*`) — invoke-only

| Field | Description | Example |
| - | - | - |
| `meta.tool.id` | Tool identifier | `send_email` |
| `meta.tool.name` | Tool name being invoked | `send_email` |
| `meta.tool.description` | Tool description from the MCP spec | contains `delete` |
| `meta.tool.annotations.readOnlyHint` | Tool is read-only (no side effects) | `true` |
| `meta.tool.annotations.destructiveHint` | Tool may delete or overwrite data | `true` |
| `meta.tool.annotations.idempotentHint` | Calling the tool multiple times has the same effect | `true` |
| `meta.tool.annotations.openWorldHint` | Tool interacts with systems outside the user's account | `true` |
| `meta.tool.input_schema.<subfield>` | Tool input JSON schema (use subfields) | `meta.tool.input_schema.required` list\_contains `password` |

### Session Context (`meta.session.*`) — invoke-only

| Field | Description | Example |
| - | - | - |
| `meta.session.servers_used` | Server IDs accessed earlier in this session (list) | `$meta.server.id` |
| `meta.session.tools_used` | Tools called earlier in this session (list, format: `server_id:tool:tool_name`) | `<server-uuid>:tool:create_issue` with `list_contains`, or `.*:tool:create_issue` with `list_regex` |
| `meta.session.scopes_used` | Read/write scopes accessed earlier (list, format: `server_id:scope:read\|write`) | `<server-uuid>:scope:write` with `list_contains`, or `.*:scope:write` with `list_regex` |
| `meta.session.payload_values_used.<arg>` | Distinct top-level scalar argument values used earlier in session (list, per argument name). Nested fields are not tracked. | `$payload.repo` |
| `meta.session.session_id` | Canonical session identifier (UUID) for the current MCP session — the id Runlayer uses internally. Prefer this for session matching. | `3d7f9b2a-6c1e-4d8f-a5b9-7c0e2f4a6b8d` |
| `meta.session.external_session_id` | Raw client-supplied session id before normalization. Use only to match the exact value a client sent; otherwise prefer `meta.session.session_id`. | `claude_web:session-abc123` |

### Resource Context (`meta.resource.*`)

| Field | Description | Example |
| - | - | - |
| `meta.resource.uri` | Resource URI | `file:///reports/q3.pdf` |
| `meta.resource.name` | Resource name | `q3.pdf` |

> [!TIP]
>
> Values starting with `$` are [dynamic value references](#dynamic-value-references): `$meta.<path>` and `$payload.<field>` resolve against the current call at evaluation time, so one rule can compare session history against whatever server or argument the call targets.

**Common recipes:**

* Block access from outside the corporate network: `meta.request.ip` `not_ip_range` `10.0.0.0/8`
* Only allow read-only tools: `meta.tool.annotations.readOnlyHint` `equals` `true`
* Restrict a connector to one Claude client: `meta.request.user_agent` `contains` `claude`
* Read-only from one client, read-write from the others: see [Plugins and security](https://docs.runlayer.com/platform-plugins.md#plugins-and-security)
* Deny tools that accept credentials: `meta.tool.input_schema.required` `list_contains` `password`
* Pin an agent session to a single repo: see [Repository Isolation](#repository-isolation)

***

## Available Operators

Conditions use operators in **snake\_case**. All operators are listed below:

| Category | Operator | Description |
| - | - | - |
| **Equality** | `equals` | Exact match |
| | `not_equals` | Does not match |
| **String** | `contains` | Value contains substring |
| | `not_contains` | Value does not contain substring |
| | `begins_with` | Value starts with prefix |
| | `not_begins_with` | Value does not start with prefix |
| | `ends_with` | Value ends with suffix |
| | `not_ends_with` | Value does not end with suffix |
| **Regex** | `regex` | Matches a regular expression (RE2 syntax) |
| | `not_regex` | Does not match a regular expression (RE2 syntax) |
| **IP Range** | `ip_range` | IP is within CIDR range(s) |
| | `not_ip_range` | IP is outside CIDR range(s) |
| **List** | `list_equals` | Deep equality between lists (order-sensitive) |
| | `list_not_equals` | Lists are not deeply equal |
| | `list_contains` | List contains value; if rule value is a list, all values must be present (subset check) |
| | `list_not_contains` | List does not contain value; if rule value is a list, none of its values can be present |
| | `list_regex` | List field entry matches regex |
| | `list_not_regex` | No list entry matches regex |
| | `list_any_not_regex` | At least one list entry does not match regex |
| | `list_ip_range` | List IP entry is within CIDR range(s) |
| | `list_not_ip_range` | No list IP entry is within CIDR range(s) |

> [!NOTE]
>
> String operators (`contains`, `begins_with`, `ends_with`, and their negations) accept a single string or a list of strings. With a list, positive operators match if **any** pattern matches; negated operators match only if **none** do.

> [!NOTE]
>
> Negated operators (`not_*` and `list_not_*`) evaluate to **true** when the field is missing or unavailable, following the principle that an absent value cannot satisfy the positive condition.

> [!NOTE]
>
> The regex operators (`regex`, `not_regex`, `list_regex`, `list_not_regex`, `list_any_not_regex`) use [RE2](https://github.com/google/re2/wiki/Syntax) syntax. RE2 is linear-time and immune to ReDoS, but does not support lookahead (`(?=...)`), lookbehind (`(?<=...)`), or backreferences (`\1`). **Literal** patterns with unsupported syntax are rejected at save time; a **dynamic** pattern (e.g. `$payload.pattern`) is only checked at evaluation time; if it can't compile the condition is indeterminate, so a deny or approval rule built on it enforces restrictively and an allow rule does not grant — see [Condition Value Matching](#condition-value-matching). Existing policies that used lookahead patterns from the Quick Start templates continue to work during a transition period — they are automatically rewritten to equivalent RE2 patterns. If you have custom patterns with unsupported syntax, update them to use RE2-compatible alternatives (e.g., replace a negative lookahead deny with a `list_any_not_regex` complement).
>
> See [Regular Expression Syntax](https://docs.runlayer.com/policy-regex-syntax.md) for the full set of supported features and the differences from Python `re` (notably that `\d`, `\w`, `\s` are ASCII-only — use `\p{Nd}` / `[\p{L}\p{N}_]` for Unicode).

***

## Condition Value Matching

When writing conditions, keep these matching rules in mind:

| Behavior | Details |
| - | - |
| **String comparisons are case-sensitive** | `equals`, `contains`, `begins_with`, `ends_with`, and `regex` all match exact casing. `"Cursor"` does not match `"cursor"`. |
| **Boolean values are case-insensitive** | Fields like `meta.tool.annotations.readOnlyHint` or `meta.tool.annotations.destructiveHint` accept `true`, `True`, or `TRUE` interchangeably. |
| **Numbers match their plain text form** | `equals` and `not_equals` compare a numeric field with the value as text: a field of `5` matches `"5"`. Other spellings of the same number, such as `"5.0"` or `"1e4"` for `10000`, do not match. |
| **Tool and resource names are case-sensitive** | Scope entries (`tools`, `resources`) must match the exact name from the MCP server. |
| **IP ranges use CIDR notation** | `ip_range` / `not_ip_range` operators accept single or comma-separated CIDRs (e.g., `10.0.0.0/8, 172.16.0.0/12`). |
| **Regex uses RE2 syntax** | `regex`, `not_regex`, `list_regex`, `list_not_regex`, and `list_any_not_regex` use a linear-time engine (RE2). Character classes, anchors, quantifiers, alternation, `\b`, and named groups work; **lookahead** (`(?=…)`, `(?!…)`), **lookbehind** (`(?<=…)`, `(?<!…)`), and **backreferences** (`\1`) are not supported. A **literal** pattern using an unsupported construct is rejected when the policy is saved. A **dynamic** pattern (a reference like `$payload.pattern` resolved at evaluation time) can only be checked when it runs: if the resolved value fails to compile, the condition **cannot be evaluated** and is treated restrictively — a deny rule built on it **blocks** the request, an approval rule **requires approval**, and an allow rule does **not** grant. A server-side warning is logged. Prefer literal patterns, or validate dynamic sources upstream. Note also that `\d`, `\w`, `\s`, and `\b` are **ASCII-only** — use an explicit range or a Unicode property class (`\p{L}`, `\p{Nd}`) for non-ASCII text. |

***

## Best Practices

> [accordion] Start with Specific Tools, Not Entire Server
>
> When in doubt, grant access to specific tools first. You can always expand later if needed.
>
> **Why?**
>
> * Easier to add permissions than remove them
> * Users won't miss tools they didn't know existed
> * Reduces attack surface if credentials are compromised

> [accordion] Use Groups, Not Individual Users
>
> Create access rules for groups whenever possible, even if the group only has one member initially.
>
> **Why?**
>
> * Scales better as teams grow
> * Easier to audit (who's in "Engineering" vs 50 individual rules)
> * Syncs automatically with SSO changes
> * Simplifies onboarding/offboarding

> [accordion] Leverage SCIM for Automatic Group Sync
>
> Runlayer automatically syncs groups from your identity provider (IDP) via SCIM, mirroring your org structure.
>
> **What this means:**
>
> * Groups from Okta, Azure AD, or Google Workspace sync automatically
> * New employees added to groups get access immediately
> * Employees removed from groups lose access instantly
> * No manual group management needed
>
> **Best practice:**
>
> * Create access rules using your existing IDP groups
> * Engineering, Sales, Finance groups work out of the box
> * Changes in your IDP reflect in Runlayer instantly

> [accordion] Regularly Audit Access
>
> Review access rules quarterly:
>
> * Who has access to sensitive MCPs?
> * Are there users who no longer need access?
> * Can we tighten tool permissions?
>
> **Why?**
>
> * Prevents scope creep
> * Maintains least privilege
> * Required for compliance

> [accordion] Use Conditions for Fine-Grained Control
>
> Add conditions when scope alone isn't enough:
>
> **Good use cases:**
>
> * Restrict database queries to specific tables
> * Limit file access to certain paths
> * Validate API parameters
> * Enforce network restrictions
>
> **Available context:** tool arguments (`payload.*`), request metadata (`meta.request.*`), subject identity (`meta.subject.*`), server and OAuth attributes, tool annotations, and session history (`meta.session.*`). See the [Condition Field Reference](#condition-field-reference) for every field with sample values.
>
> **Start simple:** Begin without conditions, add them only when needed for sensitive data or compliance.

> [accordion] Use Global Policies for Organization-Wide Rules
>
> Apply security controls across all resources:
>
> **Common use cases:**
>
> * Block access from outside corporate network
> * Restrict access to approved clients only (e.g., allow only Cursor)
> * Require OAuth verification
> * Enforce compliance requirements
>
> **Remember:**
>
> * Global policies can only DENY (not allow)
> * They apply to all servers, tools, and resources
> * Manage them in Settings → Policies
> * Test with small groups before applying to everyone
>
> **Combine with server policies:** Use global denies for security, server-level allows for access grants.

***

## Agents, Skills, and More

Policies can also control who uses and manages agents, skills, plugins, artifacts, agent accounts, teams, and organization permissions. For example, you can let a group run an agent without editing it, or let one person rotate an agent account's credentials. They follow the same rules as connector policies: no access by default, allows add up, and deny wins.

> [!NOTE]
>
> Policies beyond connectors are in early access and are not enabled for workspaces by default. Contact your Runlayer team to turn them on.

> [card] [Agents, Skills, and More](https://docs.runlayer.com/access-control-resources.md)
>
> Every resource type, its actions, and who can write policies

> [card] [Access Control Cookbook](https://docs.runlayer.com/cookbook-access-control.md)
>
> Copy-paste recipes for every resource type

***

## Related Resources

> [card] [Approvals](https://docs.runlayer.com/platform-approvals.md)
>
> Review MCP requests

> [card] [Security Best Practices](https://docs.runlayer.com/mcp-security-best-practices.md)
>
> Security guidelines

> [card] [Roles & Permissions](https://docs.runlayer.com/platform-roles.md)
>
> Built-in roles and the permissions they carry

> [card] [Teams](https://docs.runlayer.com/platform-teams.md)
>
> Team ownership and sharing


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.