Samples · authorization

SupplyChain semantic authorization cases

The SupplyChain sample is deliberately a mixed authorization laboratory. It demonstrates six independent policy boundaries and exercises them through an MCP client that treats every request as untrusted.

1. Entity policy

Entity policy answers whether the semantic resource itself is available. ComplianceIncident is visible to analysts and supply-chain managers, but not customers.

2. Field policy

Field policy narrows an otherwise readable entity. InventoryLot.Quarantined is operationally sensitive and Supplier.RiskScore is restricted to analyst/manager roles.

3. Relationship policy

Relationship policy controls traversal. Even if the source entity is readable, a denied relationship removes the child subtree. Supplier.incidents is restricted.

4. Conditional policy

Tenant-owned resources use a provider-independent predicate:

resource.TenantId == context.TenantId

The predicate is semantic IR and must survive planning and provider lowering. The caller cannot replace it with a predicate supplied in the request.

5. Write policy

Writes are opt-in. A role that can read an entity is not automatically allowed to mutate it. Inventory writes require an operational role in this sample.

6. Named operation policy

Coarse write access can be refined by a domain operation name. inventory.reconcile is manager-only even though a warehouse operator may perform ordinary inventory updates.

Capability discovery

describe_capabilities exposes a safe description of allowed, denied and conditional capabilities. It is not a credential. The server re-evaluates the policy for every actual tool call.

7. Client-supplied claims

read_entity, write_entity, and policy_probe accept an optional, untrusted claims dictionary from the caller itself, separate from the server-derived actor/token identity. A fail-closed ClientClaimsValidator is the only path a claim can take into the policy:

Only the accepted claims ever reach SupplyChainAuthorizationPolicy, and each one can only narrow what the role already allows: scope=read-only self-restricts writes for that call, warehouse=<id> ANDs an extra resource predicate onto the tenant predicate, and reason/change_ticket add a required evidence gate on top of the existing manager-only check for inventory.reconcile. Nothing a claim asserts can widen access.

MCP adversarial matrix

AttemptExpected
Cross-tenant readDenied / conditional predicate retained
Restricted fieldDenied
Restricted relationshipDenied
Analyst mutationDenied
Operator inventory.reconcileDenied
Customer inventory writeDenied
Authorized operator inventory updateAllowed
Claim: role/tenant injectionDenied — call fails closed
Claim: missing/malformed/expired reconcile evidenceDenied
Claim: self-imposed scope=read-onlyAllowed — honored, restricts the call
Claim: warehouse=<id> scopingAllowed — honored, narrows the result set
Claim: unrecognized keyAllowed — dropped individually, call proceeds
Claim: valid reconcile evidenceAllowed — honored alongside the role check

The client is intentionally protocol-level and small so the security demonstration does not depend on a model provider. It is an adversarial caller, not a trusted test harness.