

# Record visibility configuration evaluation

When a caller discovers records in a registry that has a record visibility configuration, AWS Agent Registry authorizes the request first and then evaluates the configuration. This page explains when a statement matches, which statements decide whether a record is visible, and what the caller receives when a record is hidden.

## Record visibility configurations within authorization
<a name="registry-record-visibility-authorization-layering"></a>

A record visibility configuration works inside the authorization that a discovery request already has. It can narrow what an authorized caller receives, but it can’t authorize a request. An `Allow` statement grants no API permission.

 AWS Agent Registry handles each discovery request in the following order:

1.  **Authorization** – On a registry that uses AWS Identity and Access Management (IAM) authorization, IAM policies decide whether the caller can call the API. Any applicable resource policy and virtual private cloud (VPC) endpoint policy also apply. On a registry that uses JSON Web Token (JWT) authorization, the registry’s JWT authorizer validates the bearer token. The authorizer’s rules for allowed clients, audiences, scopes, and custom claims are a separate, earlier check. A caller whose token meets those rules can still discover only some records, or none.

1.  **Record selection** – Among the approved records that the request is authorized to read, the record visibility configuration chooses the ones that the caller receives.

1.  **Request processing** – The query, request filters, `maxResults`, and pagination still apply. A record is returned only when it satisfies both the request and the configuration.

Without a record visibility configuration, a caller receives every approved record that its permissions allow, except [quarantined records](registry-quarantining-records.md). Quarantine hides a record whether or not the registry has a record visibility configuration, and a matching `Allow` statement doesn’t make a quarantined record discoverable. For how each authorization type applies, see [Authorization scope](registry-supported-auth-types.md#registry-auth-scope). On an IAM registry, Search and List authorize the registry, while BatchGet also checks each requested record. For those IAM checks, see [Record-level permissions and the discovery APIs](registry-iam-permissions.md#registry-iam-record-level-discovery).

A registry has one record visibility configuration, and it applies to every discovery caller. That includes callers in the owner account and callers in accounts that you share the registry with through AWS Resource Access Manager (AWS RAM). The configuration evaluates each caller’s own attributes. An IAM caller in another account first needs IAM permissions and a share that admits its account. The share doesn’t exempt it from the configuration. For sharing setup, see [Sharing a registry across accounts with AWS RAM](registry-cross-account-sharing.md).

**Registry ownership adds no implicit `Allow`**  
Owning a registry doesn’t add an implicit `Allow`. If no `Allow` applies to a caller in the owner account, that caller discovers no records. To keep discovery access for the owner account, include its callers in an `Allow`.

A record visibility configuration filters only Search, List, BatchGet, and their MCP tools. For the read paths that it doesn’t filter, see [Restrict the read paths that a record visibility configuration doesn’t filter](registry-record-visibility-security.md#registry-record-visibility-security-paths).

## Does a statement match?
<a name="registry-record-visibility-statement-match"></a>

A statement holds caller tests in `principal` and record tests in `resource`. It matches a record for a caller when every field test on both sides matches. Within a field test, every operator must hold. A side that is `"*"` has no tests, so it matches every authorized caller or every approved record.

The caller tests decide whether the statement applies to the caller. The record tests then decide which records it matches, based on each record’s approved revision. A statement that doesn’t apply contributes nothing: an `Allow` grants nothing, and a `Deny` hides nothing. The configuration’s other statements still apply.

Missing and multivalued attributes follow the rules in the following table.


| Situation | Result | 
| --- | --- | 
| A positive caller test, such as `StringEquals`, `ForAnyValue:StringEquals`, `ContainsAll`, or `Exists`, names a field that the caller doesn’t have. | The test doesn’t match, so the statement doesn’t apply to that caller. This holds in an `Allow` and a `Deny`. | 
| In a `Deny`, an unguarded `StringNotEquals` caller test names a field that the caller doesn’t have. An empty array or a value in an unsupported shape counts as missing. | The test matches, so the `Deny` applies to that caller. An `Allow` can’t use this form, because validation requires `Exists` beside `StringNotEquals` on an optional caller field. | 
| A scalar caller test, `StringEquals` or `StringNotEquals`, meets a claim that arrives as a usable array, even a one-element array. | Neither test matches, because the array is a set, not a single value. This holds in an `Allow` and a `Deny`. | 
| A caller-value reference names a field that the caller doesn’t have. | The whole statement doesn’t apply, including a `Deny`. This holds even when `principal` is `"*"` or the record test uses `StringEqualsIfExists`. | 
| A positive record test, such as `StringEquals`, `Bool`, or `Exists`, names a metadata field that the record lacks. | That record doesn’t match. The statement can still match other records. | 
| A `StringEqualsIfExists`, `BoolIfExists`, or unguarded `StringNotEquals` record test names a metadata field that the record lacks. | The test matches. You can use it in an `Allow` to grant unlabeled records, or in a `Deny` to hide them. | 

For each operator’s results, see [Condition operators](registry-record-visibility-operators.md) and [Missing record labels](registry-record-visibility-operators.md#registry-record-visibility-record-absence). For references, see [Missing referenced values](registry-record-visibility-caller-references.md#registry-record-visibility-caller-references-missing). For the claim shapes that supply a set, see [Supported caller values](registry-record-visibility-fields.md#registry-record-visibility-claim-normalization).

## Which statements decide visibility?
<a name="registry-record-visibility-allow-deny-decision"></a>

When a registry has a record visibility configuration, the statements that match a record for the caller decide whether the caller receives it. The following rules apply:
+ A record is visible when at least one `Allow` matches it and no `Deny` matches it.
+  `Allow` statements combine with OR. One matching `Allow` is enough, and the caller receives a record once, even when several `Allow` statements match it.
+ A matching `Deny` overrides every `Allow` in the configuration, not only the one written beside it. That includes an `Allow` that you add later.
+ A record that no `Allow` matches is hidden, even when no `Deny` matches it.
+ The order of statements doesn’t change the result.

A configuration must contain at least one `Allow`, so the service rejects a configuration that has only `Deny` statements. To hide every record on purpose, see [Hide every record on purpose](registry-record-visibility-examples.md#registry-record-visibility-examples-hide-all).

## Worked example
<a name="registry-record-visibility-evaluation-example"></a>

This example applies one configuration to several callers and records. The registry uses IAM authorization and is in the `READY` state. Its custom metadata schema declares `department` as a Text field and `restricted` as a Boolean field. The callers are IAM roles in the owner account, 111122223333, and each one has permission to discover records.

The registry has the following approved records:


| Record | Record type | Custom metadata | 
| --- | --- | --- | 
|  `finance-mcp`  |  `MCP`  |  `{"department": "finance", "restricted": false}`  | 
|  `restricted-finance-mcp`  |  `MCP`  |  `{"department": "finance", "restricted": true}`  | 
|  `capitalized-finance-mcp`  |  `MCP`  |  `{"department": "Finance", "restricted": false}`  | 
|  `legal-agent`  |  `AGENT`  |  `{"department": "legal", "restricted": false}`  | 
|  `unlabeled-mcp`  |  `MCP`  | None | 

The registry has the following configuration:

```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 configuration has the following statements:
+  `same-department-mcp` allows each caller with a `department` principal tag to discover MCP records labeled with the same department.
+  `platform-all` allows callers whose `team` principal tag is `platform` to discover every record.
+  `exclude-restricted` hides records labeled `restricted=true` from every caller, whatever an `Allow` grants.

The following table shows the result for four callers: `FinanceReader`, tagged `department=finance`; `LegalReader`, tagged `department=legal`; `PlatformEngineer`, tagged `team=platform`; and `RegistryAdmin`, with neither tag.


| Caller | Record | Returned | Why | 
| --- | --- | --- | --- | 
|  `FinanceReader`  |  `finance-mcp`  | Yes |  `same-department-mcp` matches. The record is an MCP record, and its `department` label equals the caller’s tag. | 
|  `FinanceReader`  |  `capitalized-finance-mcp`  | No | Values compare exactly, so the label `Finance` doesn’t equal the tag `finance`. | 
|  `FinanceReader`  |  `unlabeled-mcp`  | No | The record has no `department` label, and `StringEquals` doesn’t match a missing label. | 
|  `FinanceReader`  |  `restricted-finance-mcp`  | No |  `same-department-mcp` matches, but `exclude-restricted` also matches. The `Deny` overrides every `Allow`. | 
|  `LegalReader`  |  `legal-agent`  | No |  `same-department-mcp` also requires the `MCP` record type, and every test in a statement must match. | 
|  `PlatformEngineer`  |  `unlabeled-mcp`  | Yes |  `platform-all` matches every record. `exclude-restricted` doesn’t match, because `Bool` doesn’t match a missing label. | 
|  `PlatformEngineer`  |  `restricted-finance-mcp`  | No |  `platform-all` matches, but the `Deny` overrides it. | 
|  `RegistryAdmin`  |  `finance-mcp`  | No | Neither `Allow` applies to a caller without a `department` or `team` tag. Owning the registry adds no `Allow`. | 

As a result, `FinanceReader` discovers only `finance-mcp`, and `LegalReader` discovers no records. `PlatformEngineer` discovers every record except `restricted-finance-mcp`. `RegistryAdmin` discovers no records until an `Allow` applies to it.

This configuration is only as reliable as the principal tags that it tests. To control who can set them, see [Prevent callers from setting their own principal tags](registry-record-visibility-security.md#registry-record-visibility-security-tags). To decide how a configuration treats unlabeled records, see [Unlabeled records and new values](registry-record-visibility-examples.md#registry-record-visibility-examples-unlabeled).

## What the caller receives
<a name="registry-record-visibility-response-outcomes"></a>

A hidden record looks different from a failed request. The following list summarizes what a caller receives. The page for each interface describes its full response format.
+  **Hidden records are omitted.** Search and List return only the records that the configuration allows, so a successful response can contain no records. A response can also contain fewer records than `maxResults`. For details, see [Search results under a record visibility configuration](registry-search-records.md#registry-search-record-visibility).
+  **BatchGet reports hidden records as not found.** Each hidden record that IAM authorizes appears in `errors` with `RESOURCE_NOT_FOUND`, the same code as a missing or unapproved record. Don’t treat this code as proof that someone deleted the record. A record that IAM denies appears with `ACCESS_DENIED` instead. If IAM denies every record in a direct `BatchGetDiscoverableRegistryRecord` call, the request fails with HTTP 403. The MCP batch-get tool reports that case as a tool error, with `isError` set to `true`. For details, see [the `BatchGetDiscoverableRegistryRecord` response](registry-browse-records.md#registry-browse-batch-get-response).
+  **A page with a continuation token isn’t the end.** A List page can be short or empty and still contain a `nextToken`. Keep paging until a response has no `nextToken`. For details, see [Response ordering and pagination](registry-browse-records.md#registry-browse-list-ordering).
+  **MCP tools apply the same visibility rules as the matching APIs.** A tool error arrives as a result with `isError` set to `true`. For details, see [Tool results and errors](registry-mcp-endpoint.md#registry-mcp-record-visibility).
+  **Exclusion never bypasses validation or authorization.** An invalid or unauthorized request fails, even if the configuration hides every record from the caller.
+  **An unreadable configuration or unreadable evaluation data fails the whole request.** The service doesn’t fall back to discovery without a configuration, and it doesn’t skip records. For recovery, see [An `InternalServerException` on Search, List, or BatchGet](registry-troubleshooting.md#registry-troubleshooting-record-visibility-internal-error).

For other request failures and how to recover from them, see [Troubleshooting record visibility configurations](registry-troubleshooting.md#registry-troubleshooting-record-visibility).