Skip to content
2 changes: 1 addition & 1 deletion .changeset/35442-mcp-app-docs-tools.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
'@objectstack/mcp': patch
'@objectstack/runtime': patch
Expand All @@ -13,7 +13,7 @@

- **`search_package_docs({ terms, package? })`** finds the pages whose title, a heading or text contains one of the terms (case aside, in the page's base text or a translation). Pages that contain more of the terms come first, then pages where the terms sit higher (the sum of title 3, heading 2, text 1), then by title; at most 10, each with an excerpt, its manual and, where the page has one, its console address (`/_console/apps/<package>/docs/<book>/<page>`) to cite. The heading parse is line-based and linear.
- **`read_package_doc({ name, package?, locale? })`** reads one page: its title, manual, Markdown content and, where the page has one, its console address (cut at 60,000 characters, and the answer says so).
- **Who sees what.** Both tools read the `doc` items through the `/meta/doc` docs-audience gate (ADR-0046 §6.7) with the request's execution context as the caller: a page the caller may not read is neither found nor read, and answers as not found. On an OAuth grant that caller is the agent, so the docs audience is judged on the token's grant (its scope-derived permission sets), not on the person's own permission sets: a manual whose audience is a permission set the person holds stays hidden on that connection. Both tool descriptions say so. Both are read tools: they register for an API key, a session, or a token granted `data:read`. The runtime's HTTP bridge carries them where the protocol serves the `/meta` list read; the stdio bridge does not.
- **Who sees what.** Both tools read the `doc` items through the `/meta/doc` docs-audience gate (ADR-0046 §6.7) with the request's execution context as the caller: a page the caller may not read is neither found nor read, and answers as not found. On an OAuth grant the request is an agent acting for the person who consented, and a permission-set audience is read against that person's own permission sets (ADR-0090 D10), never the token's scope-derived sets. Both are read tools: they register for an API key, a session, or a token granted `data:read`. The runtime's HTTP bridge carries them where the protocol serves the `/meta` list read; the stdio bridge does not.
- **The answer order.** Where both tools register, the HTTP `initialize` instructions say: read the manuals first; answer a concept from the manual, and label a general explanation as one when no page covers it; for a process or rule, also read its real definition, which wins where the two differ; end with each page's title and url. The rule names a definition reader only where the connection lists one (`describe_metadata`, else `get_metadata_item`, both under `metadata:write`); without one it says to answer from the manual and state that the configured process was not checked. A host's own instructions and a configured `instructions` option are served unchanged.

The two names are the ones the cloud AI runtime already registers, so `MCP_DOOR_TOOL_NAMES` (`@objectstack/spec/system`) now lists them too; `PLATFORM_PROVIDED_TOOL_NAMES` is unchanged. No metadata key, value or default changes.
20 changes: 20 additions & 0 deletions .changeset/35584-delegated-docs-audience.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@objectstack/mcp': patch
'@objectstack/runtime': patch
---

Clause-②: yes — widening: on a delegated agent token whose scope reaches the docs tools, a permission-set-gated package doc is now found and read when the delegating person holds that set (ADR-0090 D10, ceiling ∩ delegator); nothing served today is refused, a non-holder and a token without docs-tool access still see nothing. Seat runs a contract read before ready; security#2 checks the head read-only before merge.
Metadata-protocol: none

fix(runtime): on an OAuth MCP connection, `search_package_docs` and `read_package_doc` judge a manual's permission-set audience by the delegating person's own permission sets

An OAuth token makes the request an agent acting on behalf of the person who consented (ADR-0090 D10). The two app-docs tools used to judge a manual whose audience is `{ permissionSet }` against the token's scope-derived permission sets, so a person who holds that set could not find or read the manual from their own AI client, while the Console showed it to them.

Now, on such a connection:

- The token's scope still decides whether the docs tools are reached at all (`data:read`). A token without it is served neither tool, whatever the person holds.
- The audience reads the person's own permission sets, resolved by the same grant resolution a request uses, in the organization the request runs in: the one the token's consent bound, while the person's membership there is current. A person with no user row holds no set here. A person whose membership there has ended is read with no active organization, as their own session is, so no grant stored in an organization applies.
- The token's own permission sets are never added to the person's: a manual whose audience is one of the token's scope sets stays closed unless the person holds it.
- Manuals with the default audience answer as before. API keys, signed-in sessions and AI service accounts keep their own permission sets.

Both tool descriptions now say so: on an OAuth connection, the person's own permission sets decide, never more.
5 changes: 3 additions & 2 deletions packages/mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ analytics service serves its dataset executor), and `search_package_docs` /
`readPackageDoc` (the runtime's HTTP bridge does where the protocol serves the
`/meta` list read; it reads every page through the `/meta/doc` docs-audience
gate as the caller, so a page the caller may not read is neither found nor
read; on an OAuth grant the caller is the agent, judged on the token's grant
rather than the person's own permission sets; the stdio bridge carries neither); a bridge without those seams
read; on an OAuth connection whose grant reaches the docs tools, a
permission-set audience is read against the delegating person's own permission
sets, never wider; the stdio bridge carries neither); a bridge without those seams
serves the rest and advertises nothing it cannot do.

OAuth scopes narrow the families at consent time: `data:read` covers
Expand Down
14 changes: 7 additions & 7 deletions packages/mcp/src/mcp-http-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export interface McpDataBridge {
* `input.terms`, ranked and capped at `opts.maxResults`. Runs AS the
* principal: the host reads the docs through the ADR-0046 §6.7 docs-audience
* gate, so a page the caller may not read is never searched. On an OAuth
* grant the principal is the agent envelope, judged on the token's grant.
* grant the audience is the delegating person's own permission sets.
*
* OPTIONAL: a host that cannot read docs for the caller omits both doc
* members ({@link searchPackageDocs}, {@link readPackageDoc}) and neither
Expand Down Expand Up @@ -3315,10 +3315,10 @@ export function packageDocToolsServed(
* - **No second gate.** Neither tool judges what the caller may read: the
* host's members read the `doc` items through the `/meta/doc` docs-audience
* gate (ADR-0046 §6.7) as the principal, so a page the caller may not read
* is neither found nor read, and reads as not found. On an OAuth grant the
* principal is the agent envelope, so the docs audience is judged on the
* token's grant, not the person's own permission sets; both descriptions
* say so.
* is neither found nor read, and reads as not found. On an OAuth grant that
* reaches these tools (the gate above), the docs audience is the delegating
* person's own permission sets, never wider (ADR-0090 D10); both
* descriptions say so.
* - **The search is a substring match**, stated in the description: no
* server-side doc search exists, so the honest search is a term found in a
* page's title, a heading or its text (case aside). Pages that contain more
Expand Down Expand Up @@ -3348,7 +3348,7 @@ export function registerPackageDocTools(
+ 'aside. Pages that contain more of the terms come first, then pages where the terms sit higher (title, '
+ `then heading, then text), then by title; at most ${PACKAGE_DOC_SEARCH_MAX_RESULTS}, each with an excerpt `
+ 'and, where the page has one, the url to cite. Only pages this connection may read are searched; on an '
+ 'OAuth connection that is judged on the connection\'s grant, not on the person\'s own permission sets. '
+ 'OAuth connection, those the person\'s own permission sets open, never more. '
+ `Read a page with ${READ_PACKAGE_DOC_TOOL_NAME}.`,
inputSchema: strictToolInput(
{
Expand Down Expand Up @@ -3382,7 +3382,7 @@ export function registerPackageDocTools(
'Read one page of an installed app\'s manual by its name (the name search_package_docs answers): its '
+ 'title, its manual, its Markdown content and, where the page has one, its url to cite. Send package when '
+ 'two apps ship a page of that name. A page this connection may not read answers as not found; on an OAuth '
+ 'connection that is judged on the connection\'s grant, not on the person\'s own permission sets.',
+ 'connection, the person\'s own permission sets decide, never more.',
inputSchema: strictToolInput(
{
surface: `this ${READ_PACKAGE_DOC_TOOL_NAME} call`,
Expand Down
Loading
Loading