

# Record visibility configuration examples

The following recipes show record visibility configurations for common access needs. Each primary recipe states the need and the metadata fields and caller attributes that it relies on. It then shows a complete configuration and explains the result. A fragment shows only the statement or field test that changes.

A record visibility configuration chooses among the approved records that a caller is already authorized to discover. It grants no API permission. To set a configuration, see [Add or replace a configuration](registry-record-visibility-configure.md#registry-record-visibility-configure-api). Validation doesn’t show which records a caller receives, so test each configuration with real callers before you rely on it. For a procedure, see [Test a configuration](registry-record-visibility-configure.md#registry-record-visibility-configure-test).

In every recipe, the callers already have API authorization for discovery, and AWS Identity and Access Management (IAM) callers have permission to get each record that they request with BatchGet. In the outcome tables, **Records returned** lists the records that Search and List return. BatchGet returns the same records, and it reports each other requested record as `RESOURCE_NOT_FOUND`.

## Department access
<a name="registry-record-visibility-examples-department"></a>

These recipes label records with a `department` metadata field and compare it with a department value that the caller carries.

### Grant records of the caller’s department
<a name="registry-record-visibility-examples-same-department"></a>

Each team needs to see the MCP servers labeled with its own department, through one statement that serves every department. This recipe requires a registry that uses IAM authorization. It uses a schema that declares `department` as a Text field. Each caller needs a `department` principal tag that it can’t change. For more information, see [Prevent callers from setting their own principal tags](registry-record-visibility-security.md#registry-record-visibility-security-tags).

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "same-department-mcp",
      "effect": "Allow",
      "principal": {"iam:principalTag/department": {"Exists": true}},
      "resource": {
        "recordType": {"StringEquals": "MCP"},
        "customMetadata/department": {"StringEquals": {"ref": "iam:principalTag/department"}}
      }
    }
  ]
}
```

The statement applies only to callers that have a `department` tag. For each of them, it grants the MCP records whose `department` label equals the tag value. Tag keys match without regard to case, but tag values and labels match exactly.

The following table shows the result for four of the approved records in [Worked example](registry-record-visibility-evaluation.md#registry-record-visibility-evaluation-example), which lists each record’s type and custom metadata. `finance-mcp` and `restricted-finance-mcp` are MCP servers labeled `finance`. `legal-agent` is an agent labeled `legal`, and `unlabeled-mcp` has no labels.


| Caller’s principal tags | Records returned | Why | 
| --- | --- | --- | 
|  `department=finance`, or `Department=finance`  |  `finance-mcp`, `restricted-finance-mcp`  | Both are MCP records labeled `finance`. Tag keys match without regard to case. | 
|  `department=Finance`  | None | Values match exactly, and none of these four records is labeled `Finance`. | 
|  `department=legal`  | None |  `legal-agent` is an agent record, and the statement grants only MCP records. | 
| No `department` tag | None | The statement doesn’t apply. | 

On a registry that uses JSON Web Token (JWT) authorization, the following statement replaces the one in the preceding configuration. For authorizer setup, see [Set up a JWT manually with your own identity provider](registry-supported-auth-types.md#registry-jwt-manual).

 **Example – The same rule on a JWT registry** 

```json
{
  "sid": "same-department-mcp",
  "effect": "Allow",
  "principal": {"jwt:claim/department": {"Exists": true}},
  "resource": {
    "recordType": {"StringEquals": "MCP"},
    "customMetadata/department": {"StringEquals": {"ref": "jwt:claim/department"}}
  }
}
```

Claim names are case-sensitive, so this statement doesn’t read a `Department` claim. If the claim arrives as an array, such as `["finance", "legal"]`, the reference matches a label that equals any of its values. For more information, see [Compare labels with caller values](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-normalization). To control who can change the claim, see [Base JWT grants on claims your IdP administrators control](registry-record-visibility-security.md#registry-record-visibility-security-claims).

### Allow only listed label values
<a name="registry-record-visibility-examples-allowlist-values"></a>

To grant a fixed set of departments rather than the caller’s own, replace the reference with a list of values, as in the following field entry.

 **Example – A list of permitted department values** 

```json
"customMetadata/department": {"StringEquals": ["finance", "legal"]}
```

In the configuration from [Grant records of the caller’s department](#registry-record-visibility-examples-same-department), this test grants every tagged caller the MCP records labeled `finance` or `legal`. This statement doesn’t grant records with another value or no label. The list limits only the statement that holds it, so another `Allow` statement can still grant other values. To keep unlisted and new values hidden from every grant, use a `Deny` statement, as shown in [Outcomes by form](#registry-record-visibility-examples-unlabeled-outcomes).

## Group and scope membership
<a name="registry-record-visibility-examples-groups"></a>

These recipes grant records based on the groups and scopes in a caller’s JWT. They require a registry that uses JWT authorization, with tokens that carry the claims that the configuration tests. For authorizer setup, see [Set up a JWT manually with your own identity provider](registry-supported-auth-types.md#registry-jwt-manual).

### Grant by any of several groups, plus a required scope
<a name="registry-record-visibility-examples-jwt-groups-any"></a>

Members of either finance group need to see finance MCP servers, but only through a client that holds the `discover:finance` scope. This recipe uses a schema that declares `department` as a Text field, and it requires tokens with `groups` and `scope` claims.

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "finance-groups",
      "effect": "Allow",
      "principal": {
        "jwt:claim/groups": {"ForAnyValue:StringEquals": ["finance-readers", "finance-ops"]},
        "jwt:scopes": {"ForAnyValue:StringEquals": "discover:finance"}
      },
      "resource": {
        "recordType": {"StringEquals": "MCP"},
        "customMetadata/department": {"StringEquals": "finance"}
      }
    }
  ]
}
```

Both caller tests must hold. The `groups` claim must include `finance-readers` or `finance-ops`, and the token’s scopes must include `discover:finance`. `ForAnyValue:StringEquals` reads a string claim as a one-element set, so the test works whether your identity provider sends `groups` as a string or an array. `jwt:scopes` reads the `scope` claim, never `scp`. For more information, see [jwt:scopes](registry-record-visibility-fields.md#registry-record-visibility-jwt-scopes).

The following table shows the result for `finance-mcp` and `restricted-finance-mcp`, two MCP records labeled `finance`.


| Validated token attributes | Records returned | Why | 
| --- | --- | --- | 
|  `"groups": ["finance-ops"]`, `"scope": "openid discover:finance"`  |  `finance-mcp`, `restricted-finance-mcp`  | Both caller tests hold. | 
|  `"groups": "finance-ops"`, with the same scope |  `finance-mcp`, `restricted-finance-mcp`  | The string is read as a one-element set. | 
|  `"groups": ["finance-readers"]` without the `discover:finance` scope, or no `groups` claim | None | One of the caller tests fails. | 
| A token that the authorizer doesn’t accept | The request fails | The authorizer rejects the token before the configuration is evaluated. | 

### Require membership in all listed groups
<a name="registry-record-visibility-examples-jwt-groups-all"></a>

Unrestricted finance records must be visible only to callers in both the `finance` and `reader` groups. Finance managers and directors also need the restricted finance records. This recipe uses a schema that declares `department` as a Text field and `restricted` as a Boolean field.

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "finance-readers",
      "effect": "Allow",
      "principal": {"jwt:claim/groups": {"ContainsAll": ["finance", "reader"]}},
      "resource": {
        "customMetadata/department": {"StringEquals": "finance"},
        "customMetadata/restricted": {"Bool": false}
      }
    },
    {
      "sid": "finance-managers",
      "effect": "Allow",
      "principal": {
        "jwt:claim/groups": {"ContainsAll": ["finance"], "ForAnyValue:StringEquals": ["managers", "directors"]}
      },
      "resource": {
        "customMetadata/department": {"StringEquals": "finance"},
        "customMetadata/restricted": {"Bool": true}
      }
    }
  ]
}
```

 `ContainsAll` holds when the caller’s `groups` claim includes every listed value, and extra groups don’t matter. The second statement combines `ContainsAll` and `ForAnyValue:StringEquals` on the same claim. So a caller must be in `finance` and in `managers` or `directors`.

The following table shows the result for `finance-mcp`, labeled `restricted=false`, and `restricted-finance-mcp`, labeled `restricted=true`. With only the first statement, the first two callers receive `finance-mcp`, and no caller receives `restricted-finance-mcp`.


|  `groups` claim | Records returned | Why | 
| --- | --- | --- | 
|  `["finance", "reader"]`  |  `finance-mcp`  |  `finance-readers` applies. | 
|  `["finance", "reader", "managers"]`  |  `finance-mcp`, `restricted-finance-mcp`  | Both statements apply. | 
|  `["finance", "managers"]`  |  `restricted-finance-mcp`  | Only `finance-managers` applies. | 
|  `["finance"]`, or the string `"finance"`  | None | The caller lacks `reader`, and lacks both `managers` and `directors`. A string is read as a one-element set. | 
|  `["reader", "managers"]`, or no `groups` claim | None | The caller lacks `finance`, so neither statement applies. | 

### Grant records labeled with any of the caller’s groups
<a name="registry-record-visibility-examples-jwt-group-reference"></a>

Each record’s `department` label names a group, and callers need to see the unrestricted records labeled with any of their groups. This recipe uses a schema that declares `department` as a Text field and `restricted` as a Boolean field. The `department` labels must equal group names exactly.

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "records-for-my-groups",
      "effect": "Allow",
      "principal": {"jwt:claim/groups": {"Exists": true}},
      "resource": {
        "customMetadata/department": {"StringEquals": {"ref": "jwt:claim/groups"}},
        "customMetadata/restricted": {"Bool": false}
      }
    }
  ]
}
```

The reference reads the caller’s `groups` claim as a set of values. A record matches when its `department` label equals any of them and its `restricted` label is `false`. A caller without a usable `groups` claim gets nothing from this statement.

The following table shows the result for four approved records. `finance-mcp` and `legal-agent` are labeled `restricted=false`, and `restricted-finance-mcp` is labeled `restricted=true`. `unlabeled-mcp` has no labels.


|  `groups` claim | Records returned | Why | 
| --- | --- | --- | 
|  `["finance", "legal"]`  |  `finance-mcp`, `legal-agent`  | Both are unrestricted and labeled with one of the caller’s groups. | 
|  `"finance"`  |  `finance-mcp`  | The string is read as a one-element set. | 
|  `["managers"]`  | None | No record is labeled `managers`. | 
| Missing, or `[]`  | None | The referenced value is missing, so the statement doesn’t apply. | 
| More distinct values than the reference limit allows | The request fails | Search, List, and BatchGet return a `ValidationException`. The service doesn’t truncate the values. For more information, see [Reference limits and overflow](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-overflow). | 

## Account, role, and organization audiences
<a name="registry-record-visibility-examples-audiences"></a>

These recipes grant records by the caller’s account, IAM role, or organization. They require a registry that uses IAM authorization. A caller in another account also needs an AWS Resource Access Manager (AWS RAM) share of the registry. For more information, see [Sharing a registry across accounts with AWS RAM](registry-cross-account-sharing.md).

### Allow specific accounts, including a shared account
<a name="registry-record-visibility-examples-account"></a>

You share the registry with a partner account through AWS RAM, and the partner must not see restricted records. This recipe requires a schema that declares `restricted` as a Boolean field. It also requires an AWS RAM share with account `444455556666`, with a managed permission that grants discovery. Partner callers use the registry’s full Amazon Resource Name (ARN) in Search, List, and BatchGet.

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "owner-and-partner",
      "effect": "Allow",
      "principal": {"iam:accountId": {"StringEquals": ["111122223333", "444455556666"]}},
      "resource": "*"
    },
    {
      "sid": "partner-no-restricted",
      "effect": "Deny",
      "principal": {"iam:accountId": {"StringEquals": "444455556666"}},
      "resource": {"customMetadata/restricted": {"Bool": true}}
    }
  ]
}
```

The `Allow` statement gives callers in both accounts every approved record. The `Deny` statement removes records labeled `restricted=true` for callers in the partner account only. The configuration lists the owner account, because owning the registry gives no implicit `Allow`. Partner callers are evaluated against the owner’s single configuration, with their own attributes.

The following table shows the result for four approved records: `finance-mcp`, `restricted-finance-mcp` (labeled `restricted=true`), `legal-agent`, and `unlabeled-mcp` (no labels).


| Caller | Records returned | Why | 
| --- | --- | --- | 
| A caller in `111122223333`, the owner account | All four | Only the `Allow` statement applies. | 
| A caller in `444455556666`  |  `finance-mcp`, `legal-agent`, `unlabeled-mcp`  | The `Deny` statement removes `restricted-finance-mcp`. `Bool` doesn’t match the missing label on `unlabeled-mcp`. | 
| A caller in another account that you share the registry with | None | No statement applies. | 

A record visibility configuration doesn’t filter control-plane record reads. A share that grants those read permissions lets the partner read records regardless of the configuration. For more information, see [Restrict the read paths that a record visibility configuration doesn’t filter](registry-record-visibility-security.md#registry-record-visibility-security-paths).

### Allow a specific role
<a name="registry-record-visibility-examples-role"></a>

A catalog review role needs to see every MCP server, whichever session uses the role. Use the following statement in a configuration.

 **Example – One role sees every MCP record** 

```json
{
  "sid": "catalog-reviewer-mcp",
  "effect": "Allow",
  "principal": {"iam:principalArn": {"StringEquals": "arn:aws:iam::111122223333:role/discovery/CatalogReviewer"}},
  "resource": {"recordType": {"StringEquals": "MCP"}}
}
```

For a caller that assumed a role, `iam:principalArn` is the IAM role ARN, including its path, and not the session ARN. So every session of the role matches, whatever its session name. The comparison is exact, so a literal without the path `discovery/` doesn’t match this role. A session ARN isn’t a valid literal, and ARNs compare exactly, with no wildcards. For more information, see [iam:principalArn](registry-record-visibility-fields.md#registry-record-visibility-iam-principal-arn).

### Allow callers from your organization
<a name="registry-record-visibility-examples-org"></a>

Any caller from your organization in AWS Organizations needs to see records that aren’t restricted. This recipe requires a schema that declares `restricted` as a Boolean field. Use the following statement in a configuration.

 **Example – One organization sees unrestricted records** 

```json
{
  "sid": "my-organization-unrestricted",
  "effect": "Allow",
  "principal": {"iam:organizationId": {"StringEquals": "o-a1b2c3d4e5"}},
  "resource": {"customMetadata/restricted": {"Bool": false}}
}
```

A caller in an account in `o-a1b2c3d4e5` receives the records labeled `restricted=false`. It doesn’t receive a record without a `restricted` label, because `Bool` doesn’t match a missing label. A caller in another organization receives nothing. So does a caller whose account isn’t in an organization, because it has no organization ID. For the literal format, see [iam:organizationId](registry-record-visibility-fields.md#registry-record-visibility-iam-organization-id).

## Combined grants and Deny precedence
<a name="registry-record-visibility-examples-combined"></a>

These recipes combine statements. A caller receives the records of every `Allow` statement that matches, each record once. A matching `Deny` statement hides a record from every `Allow` statement. For the full rules, see [Which statements decide visibility?](registry-record-visibility-evaluation.md#registry-record-visibility-allow-deny-decision).

### Give one team every record
<a name="registry-record-visibility-examples-platform-all"></a>

A platform team needs every record, while other callers keep the department rule. Add the following statement to the configuration in [Grant records of the caller’s department](#registry-record-visibility-examples-same-department). Callers need `department` or `team` principal tags.

 **Example – One team sees every record** 

```json
{
  "sid": "platform-all",
  "effect": "Allow",
  "principal": {"iam:principalTag/team": {"StringEquals": "platform"}},
  "resource": "*"
}
```

With this statement, callers tagged `team=platform` receive every approved record. A caller with both tags receives the union of both grants, and each record appears once. A caller with only a `department` tag receives what the department rule grants. A caller with neither tag receives nothing. The following recipe shows the complete configuration.

### Hide restricted records from every grant
<a name="registry-record-visibility-examples-exclude-restricted"></a>

No `Allow` statement, however broad, can show restricted records. This recipe requires a registry that uses IAM authorization. It uses a schema that declares `department` as a Text field and `restricted` as a Boolean field. Callers carry `department` or `team` principal tags.

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "same-department-mcp",
      "effect": "Allow",
      "principal": {"iam:principalTag/department": {"Exists": true}},
      "resource": {
        "recordType": {"StringEquals": "MCP"},
        "customMetadata/department": {"StringEquals": {"ref": "iam:principalTag/department"}}
      }
    },
    {
      "sid": "platform-all",
      "effect": "Allow",
      "principal": {"iam:principalTag/team": {"StringEquals": "platform"}},
      "resource": "*"
    },
    {
      "sid": "exclude-restricted",
      "effect": "Deny",
      "principal": "*",
      "resource": {"customMetadata/restricted": {"Bool": true}}
    }
  ]
}
```

The first two statements are the department rule and the platform grant from the preceding recipes. The `Deny` statement tests `"customMetadata/restricted": {"Bool": true}` for every caller, and it overrides both `Allow` statements. The following table shows which records each caller receives. A caller with neither tag receives nothing, because no `Allow` statement applies.


| Record |  `restricted` label | Caller tagged `team=platform`  | Caller tagged `department=finance`  | 
| --- | --- | --- | --- | 
|  `finance-mcp`, an MCP record labeled `finance`  |  `false`  | Yes | Yes | 
|  `restricted-finance-mcp`, an MCP record labeled `finance`  |  `true`  | No. The `Deny` statement hides it. | No. The `Deny` statement hides it. | 
|  `legal-agent`, an agent labeled `legal`  |  `false`  | Yes | No | 
|  `unlabeled-mcp`  | Absent | Yes. `Bool` doesn’t match a missing label. | No | 

To hide records without a `restricted` label too, test `{"BoolIfExists": true}` in the `Deny` statement instead. It then also hides every record of a type whose schema doesn’t declare `restricted`, unless you add a `recordType` test. For more information, see [Unlabeled records and new values](#registry-record-visibility-examples-unlabeled).

### Everyone except one department
<a name="registry-record-visibility-examples-everyone-except"></a>

Every caller needs to see every record, except callers in the legal department. Pair the following `Deny` statement with an `Allow` statement whose `principal` and `resource` are both `"*"`, as in [Allow every record under an active configuration](#registry-record-visibility-examples-allow-all).

 **Example – Exclude callers tagged with one department** 

```json
{
  "sid": "except-legal",
  "effect": "Deny",
  "principal": {"iam:principalTag/department": {"StringEquals": "legal"}},
  "resource": "*"
}
```

A caller tagged `department=legal` receives nothing. Every other caller receives every approved record, including callers without a `department` tag. Tag values match exactly, so a caller tagged `department=Legal` isn’t excluded. If the value can appear in another case, list each spelling, such as `["legal", "Legal"]`.

A `Deny` statement on a caller attribute is only as strong as the controls on that attribute. A caller who can remove or change their own tag escapes it. For more information, see [Prevent callers from setting their own principal tags](registry-record-visibility-security.md#registry-record-visibility-security-tags). To grant nothing to untagged callers instead, use an `Allow` statement with the guarded tag test `{"Exists": true, "StringNotEquals": "legal"}`.

A `Deny` statement whose `principal` is `"*"` can also hide the records whose label equals a caller value, such as an `excluded-department` principal tag. Use the following field entry in the `resource` of such a statement.

 **Example – In a Deny statement, hide the department that a caller’s tag names** 

```json
"customMetadata/department": {"StringEquals": {"ref": "iam:principalTag/excluded-department"}}
```

A caller tagged `excluded-department=legal` doesn’t receive records labeled `legal`. A caller without the tag receives every record, because a missing referenced value makes the whole `Deny` statement inapplicable. If every caller must carry the tag before seeing anything, require it in the `Allow` statement. Set its `principal` to `{"iam:principalTag/excluded-department": {"Exists": true}}`. For the rule, see [Missing referenced values](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-missing).

### Everyone except members of a group
<a name="registry-record-visibility-examples-everyone-except-group"></a>

On a registry that uses JWT authorization, every caller needs to see every record, except members of the `contractors` group. Pair the following `Deny` statement with an `Allow` statement whose `principal` and `resource` are both `"*"`.

 **Example – Exclude members of one group** 

```json
{
  "sid": "except-contractors",
  "effect": "Deny",
  "principal": {"jwt:claim/groups": {"ForAnyValue:StringEquals": "contractors"}},
  "resource": "*"
}
```

The `Deny` statement applies when any of the caller’s groups is `contractors`, whether the claim is the string `"contractors"` or an array such as `["engineering", "contractors"]`. A caller in `["engineering"]` receives every record. A `StringNotEquals` test doesn’t work here, because a scalar operator never matches an array claim, even a one-element array. For each claim shape, see [Supported caller values](registry-record-visibility-fields.md#registry-record-visibility-claim-normalization).

A caller with no `groups` claim, an empty list, or an unsupported claim shape passes the broad `Allow` statement. If every caller must present usable groups, set the `Allow` statement’s `principal` to `{"jwt:claim/groups": {"Exists": true}}`. Then a caller without groups receives nothing.

### Make one record visible to everyone
<a name="registry-record-visibility-examples-pinned"></a>

One onboarding record must be visible to every caller, alongside narrower grants. Add the following statement to a configuration, such as the one in [Grant by any of several groups, plus a required scope](#registry-record-visibility-examples-jwt-groups-any). In this recipe, the record `onboarding-agent` has the ID `XyZ987LmNo12`.

 **Example – Pin one record for every caller** 

```json
{
  "sid": "pinned-for-all",
  "effect": "Allow",
  "principal": "*",
  "resource": {"recordId": {"StringEquals": "XyZ987LmNo12"}}
}
```

The statement has no caller tests, so it works on either authorization type. It applies to every caller that passes API authorization, including callers without the groups or scope that the other statement requires. Those callers receive only `onboarding-agent`. A caller whose token the authorizer rejects still receives no result, because the request fails before the configuration is evaluated.

Pin a record by `recordId`, not by `name`, because one name can match several records. Validation checks the format of a record ID, but not whether the record exists. With `StringEquals`, a mistyped but well-formed ID matches no record, so the statement pins nothing. For more information, see [recordId](registry-record-visibility-fields.md#registry-record-visibility-record-id).

### Hide every record on purpose
<a name="registry-record-visibility-examples-hide-all"></a>

You need to stop discovery through a registry’s Search, List, and BatchGet operations and their MCP tools without deleting the registry. For example, you might need this while you relabel its records. A configuration must contain at least one `Allow` statement, so pair one with a `Deny` statement that covers every caller and record.

```json
{
  "version": "1",
  "statements": [
    {"sid": "required-allow", "effect": "Allow", "principal": "*", "resource": "*"},
    {"sid": "hide-everything", "effect": "Deny", "principal": "*", "resource": "*"}
  ]
}
```

No caller, including the registry owner’s roles, discovers any record through the registry’s Search, List, or BatchGet operations or their MCP tools. Search and List return no records, and BatchGet reports each record that IAM authorizes as `RESOURCE_NOT_FOUND`. The configuration doesn’t apply to public search, so a record that you promoted to the public discovery plane stays discoverable there. To take such a record out of public search, disassociate its Publisher. For more information, see [Remove a record from public discovery](registry-promote-to-public.md#registry-promote-disassociate).

Don’t remove the configuration to hide records, because removal restores discovery without a configuration. For more information, see [Remove a configuration](registry-record-visibility-configure.md#registry-record-visibility-configure-remove).

### Allow every record under an active configuration
<a name="registry-record-visibility-examples-allow-all"></a>

You want callers to see every approved record now, with a configuration in place that you can narrow later.

```json
{
  "version": "1",
  "statements": [
    {"sid": "everything", "effect": "Allow", "principal": "*", "resource": "*"}
  ]
}
```

Every caller discovers every approved record that its permissions allow, except quarantined records, as if the registry had no record visibility configuration. This configuration has the same effect as the console’s starting statement for a new configuration. Adding or removing the configuration is still a configuration update. Switching between no configuration and this configuration can make a caller’s earlier tokens stop working. For more information, see [How a configuration change takes effect](registry-record-visibility-configure.md#registry-record-visibility-configure-effect).

### Combine a record visibility configuration with IAM resource-tag conditions
<a name="registry-record-visibility-examples-with-iam-tags"></a>

IAM decides whether a caller can call discovery at all, by comparing team tags. The record visibility configuration from [Grant records of the caller’s department](#registry-record-visibility-examples-same-department) then chooses records by department. The registry and each record carry the AWS tag `team=finance`, which is separate from metadata fields. Callers carry `team` and `department` principal tags. In the following IAM identity policy, replace `<registryId>` with your registry ID.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "agent-registry:SearchDiscoverableRegistryRecords",
        "agent-registry:ListDiscoverableRegistryRecords",
        "agent-registry:InvokeRegistryMcp"
      ],
      "Resource": "arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>",
      "Condition": {"StringEquals": {"aws:ResourceTag/team": "${aws:PrincipalTag/team}"}}
    },
    {
      "Effect": "Allow",
      "Action": "agent-registry:GetDiscoverableRegistryRecord",
      "Resource": "arn:aws:agent-registry:us-east-1:111122223333:registry/<registryId>/record/*",
      "Condition": {"StringEquals": {"aws:ResourceTag/team": "${aws:PrincipalTag/team}"}}
    }
  ]
}
```

Search and List check the registry’s tags, and BatchGet checks each record’s tags, so the registry and each record need the `team` tag. A caller tagged `team=finance` and `department=finance` passes IAM and receives the MCP records labeled `finance`.

IAM denies a caller tagged `team=engineering`. Search and List return `AccessDeniedException`, and BatchGet returns HTTP 403 when IAM denies every requested record. A caller tagged `team=finance` without a `department` tag passes IAM but receives no records. For the IAM actions, see [Registry data plane actions](registry-iam-permissions.md#registry-iam-data-plane).

## Unlabeled records and new values
<a name="registry-record-visibility-examples-unlabeled"></a>

A record can lack a label because its approved revision doesn’t carry the field, or because its record type’s schema doesn’t declare it. A positive test doesn’t match a missing label, but an unguarded negated test or an `IfExists` test does. A value that you introduce after you write the configuration behaves like any other unlisted value.

The recipes in this section use a registry whose schema declares a `classification` Text field for agent records only. The values that most audiences can see are `public` and `internal`. The statements test no caller field, so they work on either authorization type. The registry holds the following approved records:
+  `internal-agent` and `secret-agent`, agents labeled `internal` and `secret` 
+  `unlabeled-agent`, an agent whose approved revision doesn’t carry the field
+  `unlabeled-mcp`, an MCP record, which can’t carry the field because the schema doesn’t declare it for MCP records
+  `partner-agent`, an agent labeled `partner`, a value that you introduce after you write the configuration

### The strict form and the permissive form
<a name="registry-record-visibility-examples-unlabeled-forms"></a>

The strict form lists the values that callers can see.

```json
{
  "version": "1",
  "statements": [
    {
      "sid": "listed-values",
      "effect": "Allow",
      "principal": "*",
      "resource": {"customMetadata/classification": {"StringEquals": ["public", "internal"]}}
    }
  ]
}
```

 `StringEquals` matches only a present label with a listed value. Unlabeled records and new values stay hidden until you label them or add the value to the list.

The permissive form replaces the field entry in the preceding configuration with the following one. It grants every record whose `classification` isn’t `secret`.

 **Example – The permissive form** 

```json
"customMetadata/classification": {"StringNotEquals": "secret"}
```

 `StringNotEquals` also matches a missing label. So this form grants both unlabeled records: `unlabeled-agent`, and `unlabeled-mcp`, whose schema can’t hold the field. It also grants `partner-agent`, whose value didn’t exist when you wrote the configuration.

### Other forms
<a name="registry-record-visibility-examples-unlabeled-other"></a>

The following blocks show the remaining forms, each for a statement whose `principal` is `"*"`. The first two are field entries for the `resource` of an `Allow` statement. The last two each replace the whole `resource` member of a `Deny` statement. Pair each `Deny` statement with an `Allow` statement that grants every record, so that the `Deny` statement alone decides. A `Deny` statement with the positive test `{"StringEquals": "secret"}` hides only the records that carry that value.

 **Example – In an Allow statement, a listed value or no label** 

```json
"customMetadata/classification": {"StringEqualsIfExists": ["public", "internal"]}
```

 **Example – In an Allow statement, any label except one value** 

```json
"customMetadata/classification": {"Exists": true, "StringNotEquals": "secret"}
```

 **Example – In a Deny statement, hide one value and unlabeled agents** 

```json
"resource": {"recordType": {"StringEquals": "AGENT"}, "customMetadata/classification": {"StringEqualsIfExists": "secret"}}
```

 **Example – In a Deny statement, hide every agent outside the permitted values** 

```json
"resource": {"recordType": {"StringEquals": "AGENT"}, "customMetadata/classification": {"StringNotEquals": ["public", "internal"]}}
```

In the last two blocks, the `recordType` test keeps the `Deny` statement from hiding record types that don’t declare the field.

### Outcomes by form
<a name="registry-record-visibility-examples-unlabeled-outcomes"></a>

The following table shows which records each form returns. **Yes** means that every caller receives the record. For each `Deny` form, the configuration also contains an `Allow` statement that grants every record.


| Form |  `internal-agent`  |  `secret-agent`  |  `unlabeled-agent`  |  `unlabeled-mcp`  |  `partner-agent`  | 
| --- | --- | --- | --- | --- | --- | 
|  `Allow`, `StringEquals` with `public` and `internal` (strict) | Yes | No | No | No | No | 
|  `Allow`, `StringNotEquals` with `secret` (permissive) | Yes | No | Yes | Yes | Yes | 
|  `Allow`, `StringEqualsIfExists` with `public` and `internal`  | Yes | No | Yes | Yes | No | 
|  `Allow`, `Exists` and `StringNotEquals` with `secret`  | Yes | No | No | No | Yes | 
|  `Deny`, `StringEquals` with `secret`  | Yes | No | Yes | Yes | Yes | 
|  `Deny`, `StringEqualsIfExists` with `secret`, limited to `AGENT`  | Yes | No | No | Yes | Yes | 
|  `Deny`, `StringEqualsIfExists` with `secret`, without a `recordType` test | Yes | No | No | No | Yes | 
|  `Deny`, `StringNotEquals` with `public` and `internal`, limited to `AGENT`  | Yes | No | No | Yes | No | 

A positive metadata test in a `Deny` statement never matches an unlabeled record. Without a `recordType` test, the `StringEqualsIfExists` `Deny` statement hides `unlabeled-mcp` and every other MCP record.

The strict form and the last `Deny` form both keep `partner-agent` hidden. However, they differ when another statement grants more. A list in an `Allow` statement limits only that statement. Another `Allow` statement, such as one that grants a security team every record, still shows `partner-agent` to that team. The last `Deny` form hides it from every caller, because a `Deny` statement overrides every `Allow` statement.

### Choosing a form
<a name="registry-record-visibility-examples-unlabeled-choose"></a>

Use the following guidance to choose a form. For the full rules, see [Missing record labels](registry-record-visibility-operators.md#registry-record-visibility-record-absence).
+  **List the permitted values with `StringEquals` for records that some audiences must not see.** Unlabeled records and new values stay hidden from that statement’s grant until you decide otherwise. Another `Allow` statement can still grant them.
+  **Use unguarded `StringNotEquals` or an `IfExists` test in an `Allow` statement only when you want unlabeled records to be visible.** To require a label with `StringNotEquals`, add `Exists`. To limit the statement to types that declare the field, add a `recordType` test.
+  **Use a `Deny` statement to hide unlabeled records or new values from every grant.** A `StringEqualsIfExists` test hides the listed values and unlabeled records, but not new values. To hide unlabeled records and every value outside the permitted list, including new values, use a `StringNotEquals` list of the permitted values. Limit either test with a `recordType` test.
+  **Don’t rely on the schema to add labels.** A newly declared field is absent on revisions approved earlier. Making a field required doesn’t change approved revisions. A missing label stays missing, and a present label stays present. For more information, see [Changing the schema](registry-custom-metadata-schema.md#registry-custom-metadata-schema-change).
+  **Control who labels and approves records.** Labels decide which records match. For more information, see [Control who can label and approve records](registry-record-visibility-security.md#registry-record-visibility-security-labels).

### Caller fields follow a stricter rule
<a name="registry-record-visibility-examples-unlabeled-caller"></a>

In an `Allow` statement, a negated test on a caller field that can be missing must include `Exists`. Validation rejects the unguarded test, because it matches callers that lack the attribute. An `Allow` statement with the guarded test `"iam:principalTag/department": {"Exists": true, "StringNotEquals": "legal"}` grants nothing to a caller without the tag.

Record-side negation has no such requirement. An unlabeled record reaches discovery only after your approval workflow approves it, including any automatic approval that you configure. So the choice of form for records is yours, and the strict `StringEquals` form is the safe default.

## Common mistakes
<a name="registry-record-visibility-examples-mistakes"></a>

The following table lists mistakes that are easy to make.


| Mistake | What happens | Fix | 
| --- | --- | --- | 
| A scalar test on a claim that can arrive as an array, such as `"jwt:claim/groups": {"StringEquals": "finance"}`  | It never matches an array, even `["finance"]`, in an `Allow` or a `Deny` statement. | Use `ForAnyValue:StringEquals`. A claim has one cardinality across the configuration. For more information, see [Combining operators and choosing claim cardinality](registry-record-visibility-operators.md#registry-record-visibility-combining-operators). | 
| A quoted Boolean, such as `{"Bool": "true"}`  | Validation rejects the configuration. | Use the JSON value `true`. | 
| Elements from an IAM policy, such as `Version`, `Statement`, `Action`, or `Condition`  | Validation rejects the configuration. | Use the lowercase elements `version`, `statements`, `sid`, `effect`, `principal`, and `resource`, and group tests by field. For more information, see [Document elements](registry-record-visibility-language-reference.md#registry-record-visibility-elements). | 
| A negated test on an optional caller field, such as a tag, in an `Allow` statement without `Exists`  | Validation rejects the configuration. | Add `"Exists": true`. To include untagged callers, use the pattern in [Everyone except one department](#registry-record-visibility-examples-everyone-except). | 
| A positive `Deny` test, such as `{"Bool": true}`, meant to hide unlabeled records | The `Deny` statement hides only records that carry the value. | Use `BoolIfExists` or `StringEqualsIfExists`, limited with a `recordType` test. | 
| An unguarded `StringNotEquals` test on a metadata field in an `Allow` statement | The statement grants unlabeled records and values that you introduce later. | List the permitted values with `StringEquals`, or add `Exists`. For more information, see [Unlabeled records and new values](#registry-record-visibility-examples-unlabeled). | 
| A `Deny` statement that relies on a positive caller test or a reference to hide records from everyone | The `Deny` statement doesn’t exclude a caller who lacks the attribute. | To hide records from every caller, use a `principal` of `"*"` with no references. To require the attribute, add `Exists` to every `Allow` statement. | 
| An account test that omits the owner account | The owner’s callers receive nothing from that statement, because ownership adds no implicit `Allow`. | List the owner account too, as in [Allow specific accounts, including a shared account](#registry-record-visibility-examples-account). | 
| A role ARN without its path, or an assumed-role session ARN | A role ARN without its path doesn’t match a role that has one. Validation rejects a session ARN. | Use the role ARN with its path. For more information, see [iam:principalArn](registry-record-visibility-fields.md#registry-record-visibility-iam-principal-arn). | 
| A misspelled tag key, claim name, or value | Validation can accept a well-formed misspelling, and the test then doesn’t match what you intended. Validation rejects an undeclared metadata field instead. | Test with the attributes that your callers present. For more information, see [Exact comparisons and author-supplied names](registry-record-visibility-fields.md#registry-record-visibility-field-comparison). | 
| The search filter spelling `customMetadata.department`  | Validation rejects the field name. | Use `customMetadata/department` in a configuration. | 
| Removing the configuration to hide records | Every caller again discovers every approved record that its permissions allow, except quarantined records. | Keep a configuration that hides every record, as in [Hide every record on purpose](#registry-record-visibility-examples-hide-all). | 