Access boundaries
Context Control Center (CCC) applies separate access checks in different parts of the UI and selection pipeline. Site builders and integrators should not assume that one CCC permission grants access to unrelated entities or admin routes.
This page documents the security model enforced in code. It complements the authoring trust model in Configuration — Permissions.
Three independent checks
Context item view access
Controls whether a user can view a context item in the admin UI, in revision history, and in AI selection or context tools for that user.
Published items are viewable when the account has View AI Context Items in CCC or Use Published AI Context in AI Features. Unpublished items require View any unpublished AI Context Item, or ownership plus View AI Context Items in CCC.
If none of these rules allows view of an unpublished item, CCC denies access. Other permissions and access hooks cannot change this result. For example, core's View any unpublished content permission from Content Moderation does not give access to unpublished context items.
The revision history, the revision pages, and the Diff pages need more access. See Revision and Diff pages.
Selection and function-call plugins enforce the same view access for the current user. Unpublished or inaccessible items are excluded from injected context and from tool responses.
Revision history and individual revision pages additionally require View all AI Context Item revisions, unless the account has Administer AI Context. Revision permissions do not replace view access to the context item; the revision access checks require both.
Usage record access
Controls whether a user can open the usage listing and individual usage
records at /admin/config/ai/context/usage.
Requires View AI Context Usage and (for the listing) usage tracking to be enabled in settings. Usage entities have their own access handler; holding this permission does not bypass context item or target-entity checks on linked data (see below).
Referenced target-entity access
When a usage record stores a target entity (for example the node an agent was editing), CCC checks that entity's normal Drupal view access before linking to it or showing its label.
If the user cannot view the target entity, the usage UI shows a type-and-ID fallback with (no access) instead of a link.
AiContextItem::getEntityItems() stays unfiltered; it is for matching and
storage, not display. Admin labels for Specific Entities go through the
scope plugin and honor the same view-access check: inaccessible entities
are omitted from labels and links (not shown as (no access)).
Revision and Diff pages
Older revisions can contain text that editors removed on purpose. For this reason, revision pages need more than view access to the item:
- The revision history page and the revision pages need View all AI Context Item revisions or Administer AI Context. They also need view access to the item and to each revision that the user opens.
- The Diff module's revision
comparison pages (route
entity.ai_context_item.revisions_diff) need the same access. Diff also checks view access to each of the two revisions. - The Diff pages are not cached (route option
no_cache). Diff adds no cache metadata for its access checks on each revision.
Use Published AI Context in AI Features alone does not give access to revision pages or Diff pages.
Diff 8.x-1.x, 2.0.0, and 2.1.0 give the comparison route only view access
to the item. CCC changes the route requirement, so the revision permission
applies with all Diff versions. Diff 2.0.1 and 2.1.1 have the same
requirement upstream. On those versions, the requirement change has no
effect. The no_cache option still applies, because upstream Diff does not
set it.
Usage permission does not grant item access
View AI Context Usage allows observability pages only. It does not grant permission to view the associated context item, its content, or referenced target entities.
On usage listing and detail pages, CCC redacts inaccessible references:
- Context items the user cannot view show
Context item {id} (no access)instead of a label link. - The Context item content section on a usage record is omitted when view access is denied.
- Target entities the user cannot view show
{type}:{id} (no access)or a plain type-and-ID label when the entity cannot be loaded.
Grant View AI Context Items in CCC or Use Published AI Context in AI Features (and unpublished permissions when needed) separately for users who must follow links into context items from usage data.
Target entities control applicability, not access
The Target entities field on a context item and the Target Entity scope control when an item is considered relevant (hard filtering and auto-inclusion during selection). They do not grant the current user permission to view those referenced entities in Drupal.
Selection may include a context item because the user is working on a particular node, but that does not expose the node's full content through CCC unless the user already has entity view access elsewhere on the site.
Request entities the user cannot view
Entity Types and Taxonomy Terms read the bundle and terms from the request entity only when the current user can view it. If the user cannot view it, these scopes treat the request as having no entity, the same as an ID that does not exist. A caller therefore cannot use Entity Types or Taxonomy Terms matching to find out whether a passed entity ID exists or which bundle it has.
This guarantee covers the scopes that read the request entity. Specific Entities compares the passed entity type and ID with the references configured on each item and does not load the request entity. Any caller can also send a bundle hint, for example for an add form or a background operation. The hint is used only for string matching and does not load the entity, so it reveals nothing that the caller did not supply.
Because the match depends on view access, the selection result carries the
cacheability of that access check, including a denied one. When access
depends on ownership, for example with View own unpublished content,
the result varies by user, so two users with the same permissions do not
share a cached result. The access cacheability is added even when Entity
Types and Taxonomy Terms are disabled, because other scopes can also read
the request entity through the same check.
For an entity from the route, the check runs on the revision or
translation that the route upcasts, not on the default revision. An
entity passed by type and ID, through setEntity(), request metadata,
the request body, or the requestEntity argument of the selection
factory, is loaded by ID. The check then runs on its default revision
and default translation.
Context item tokens
The token [ai_context:item:TOKEN_NAME] gives the content of the context
item with that token name. See Token
name.
- The token uses the same view check as the push path. It gives only a published translation that the current user can view, with the fallback to the original language. In all other cases it gives an empty string.
- The token does not apply the Roles hard filter or the other scope rules. Any user who has view access to the published item gets its content when the text contains the token. Roles is not an access boundary on this path.
- The token works in every module that replaces Drupal tokens, not only in AI prompts. The user who gets the replaced text is the current user of that request. For example, a Webform email that a visitor sends gets the content only when the visitor can view the item.
- Only users with Administer AI Context can set a token name. Field
access on
token_nameapplies this rule also outside the item form. - Users who can edit text that supports tokens, such as an agent system prompt or a Pathauto pattern, can put any item token into that text. They do not need a CCC permission for this. The view check for the user who gets the replaced text still applies.
- Drupal tokens in the value are neutralized: the item and its required
children are neutralized as one text. Each token is replaced on its own,
so a value that ends with the start of a token, such as
[current-user:, could be completed by the text after it, for example by a second item token next to it. The neutralizer therefore adds a space after an open bracket at the end of the value, as on the other delivery paths. See Authoring trust. Text that the person who edits the prompt writes before the token is not changed: do not write the start of a token directly before an item token.
Imported and copied content lifecycle
Content loaded through Content importers is copied into the context item editor. After import:
- The text lives on the context item entity and follows context item publication and access rules.
- Source-entity or source-file permissions do not continue to protect that copied text once it is saved on the item.
- Sanitization protects the editor from unsafe markup; it does not establish semantic safety for AI prompts. See Review imported content.
Treat published context as potentially visible to every user and consumer configuration that can select it, regardless of where the text originated.
Generic entity APIs
Context items and usage records are not available through core JSON:API.
- Usage records (
ai_context_usage) are an internal entity type. JSON:API, REST resource discovery, and other modules that skip internal entity types do not offer them. - Context items (
ai_context_item) are not internal, because Content Moderation and Workspaces do not apply to internal entity types. CCC disables their JSON:API resource type instead.
JSON:API checks only entity view access. For a published context item, that is Use Published AI Context in AI Features, a permission that sites give to broad roles. With the resource on, every account with that permission could page through all published items and read their raw fields, without CCC delivery rules and without usage records. Usage records would also lose the "(no access)" labels of the CCC usage page.
CCC has no supported way to enable these resources again. An opt-in for context items can be added in a later release without a break.
Core REST skips only internal entity types, so a site builder can still enable a REST resource for context items. That resource, and other modules that load context items through the Entity API, apply the context item view access described above, not CCC selection rules.
Earlier releases allowed a core REST resource for usage records. If your site
enabled one, delete it before you rebuild the router, that is before you run
drush cr or drush updatedb: run
drush config:delete rest.resource.entity.ai_context_usage, and remove
rest.resource.entity.ai_context_usage.yml from config sync. Otherwise the
router rebuild fails, because the REST plugin for usage records no longer
exists.
Authoring trust (prompt influence)
Roles that can create, edit, publish, or administer context items are trusted with prompt-level influence. Published context — especially Global items — can be injected verbatim into AI consumer system prompts for other users.
Permissions that confer authoring or administration are marked
restrict access: true in ai_context.permissions.yml for that reason.
Drupal tokens in item text are not replaced on any delivery path. On the
agent path, AI Agents runs token replacement on the whole system prompt
after context is appended, and it also replaces tokens in default
information tool output. CCC therefore neutralizes item text on every
path: agent push, generic chat, the List, Load, and Get Relevant tools,
the public selection API, and the [ai_context:item:TOKEN_NAME] token.
It puts a space on both sides of the colon of every token whose type the
token service knows, for example [user:mail] becomes [user : mail].
Bracketed text whose type does not look like a token type, such as
["user:read"] or a[1:3], is not changed.
A literal token in prose, code, or JSON is changed intentionally. The
item-text token budget is checked on the neutralized text. To read item
text with its tokens as written, load the context item entity. See Drupal
tokens in returned text.
The Context prefix setting is site configuration and is not changed, so
tokens in the prefix are still replaced on the agent path.
The token service knows a type when a module declares it in
hook_token_info(). Core token replacement calls hook_tokens() also for
types that no module declares. For example, ECA replaces
[current_user:mail] with the email of the user who runs the agent. CCC
therefore also neutralizes tokens of undeclared types when the type has only
lowercase letters, digits, _, . or -, starts with a letter or _, and
the first part of the name, before the next colon, has no whitespace, / or
@. So [current_user:mail] becomes [current_user : mail], a custom date
format such as [current_user:created:custom:d/m/Y] is also broken, and
other text such as [note:intro] or items[i:j] changes in the same way.
Times ([10:30]), some IPv6 addresses ([fe80::1]), JSON, URLs
([https://example.com]), email links ([mailto:team@example.com]), and
notes with a space ([note: read this]) are not changed. A module that
replaces undeclared tokens whose types or names do not follow these rules
is not covered. Do not put such tokens in item text.
Other IPv6 forms, such as [fd12:3456::1], are changed to
[fd12 : 3456::1], including when the address appears inside a URL.
Some modules, for example ECA, also replace root-level tokens without a
type, such as [list]. CCC does not neutralize most of those, because
text such as [optional], [1], or a one-word Markdown link would also
change. For example, with ECA, [current_user] is not changed and
becomes the ID of the user who runs the agent. ECA also reads data paths
such as [current_user.mail.value]. CCC therefore breaks a root-level token
with a dot when the part before the first dot is a declared token type or
current_user, for example [current_user . mail.value]. Text such as
[readme.md] is not changed.
A dotted Markdown link can change when its first part is a declared token
type: [node.js](https://nodejs.org) becomes
[node . js](https://nodejs.org) when node is declared.
CCC neutralizes each output on its own: the pushed context block, the
output of each tool, and the value of each item token. AI Agents joins them
before it replaces tokens. So that an output that ends with an unclosed
token, such as [user:created:custom:Y, cannot be completed by the next
output, CCC puts a space after an open bracket at the end of each output:
[ user:created:custom:Y. A token type cannot start with whitespace, so the
joined text contains no token. Only the last open bracket needs this,
because a token type or name cannot contain an open bracket. Text that is
not from CCC, such as an agent system prompt that ends with the start of a
token, is not changed.
Receiving published context in AI features is governed separately by Use Published AI Context in AI Features and view permissions, as described above.
Outside the site
CCC 1.0.x delivers context only to AI features running inside the site: agent runs, the generic chat path for consumer types, and its own three Context Tools function calls. It has no supported channel of its own for AI tools outside the site, such as MCP clients, coding agents, or remote automation. CCC ships no MCP server, no Tool API tools, and no HTTP API.
That is about CCC's own surface. Other modules can still expose CCC data beyond the site, and the permissions above are what governs it.
So treat Use Published AI Context in AI Features as a read grant over the whole published catalog, wherever the caller is. Do not give it to the anonymous role, to roles used by API, OAuth, or MCP clients, or to service accounts for external tools, unless that caller may read every published item. There is no per-item grant.
Core JSON:API and REST
Core JSON:API does not expose context items or usage records. A site builder can still enable a core REST resource for context items, and that resource applies context item view access only. See Generic entity APIs.
The permission is the boundary, not the page. Use Published AI Context in AI Features reads as an in-site AI permission, which it is, but on a site with a REST resource for context items it also grants read access to that content over HTTP. Grant it with that in mind.
drupal/mcp
Checked against drupal/mcp 1.2.3.
The AI Function Calling MCP plugin (aif) in drupal/mcp lists and
runs every AI function call plugin for remote MCP clients, which
includes CCC's three Context Tools.
That plugin is on as soon as the module is installed. drupal/mcp
ships no aif entry in mcp.settings, and its plugin manager falls
back to enabled, for the authenticated role. The plugin needs no
separate enable step.
To turn it off or narrow it, open MCP Plugins
(/admin/config/mcp/plugins), go to the AI Function Calling
settings, and either clear Enable plugin or set Allowed roles to
the roles that may use it. Single tools can be switched off in the same
form. Reaching the MCP endpoint also requires the Use MCP Server
permission.
On a site that leaves it on, CCC cannot distinguish those calls from in-site calls; they run with the permissions of the account the MCP request authenticates as.
The item page
/admin/config/ai/context/items/{ai_context_item} renders the full item
to any account that passes ai_context_item.view, which is the same
check described above. The revision pages under
/admin/config/ai/context/items/{ai_context_item}/revisions also show
the full content of an item, to accounts that pass the revision access
in Context item view access.
Related documentation
- Permissions — permission list and brief trust note
- Context selection — accessible and published filters in the pipeline
- Usage tracking — usage UI and redaction
- API stability — public versus internal APIs
- Supported AI modules — which AI modules receive pushed context