Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/34766-mcp-open-draft-door-read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@objectstack/runtime': patch
---

feat(runtime): the open MCP server lists metadata and pending drafts for an OAuth client with `metadata:write` whose user holds `manage_metadata`

Clause-②: yes (widening)
Metadata-protocol: none

An AI client connected over MCP with an OAuth token that carries `metadata:write` now gets three read tools on a self-hosted runtime, the first half of the open draft door (design `docs/design/mcp-local-first-door.md`, Design A):

- `list_metadata_items({ type, state? })` lists one metadata type's items as summaries (name, label, package). A pending draft is listed in place of its published version and marked `draft: true`; `state: "active"` lists the published items only, `state: "draft"` the pending drafts only. A type the platform does not declare is refused with `400 INVALID_REQUEST`, as the `/meta` list refuses it.
- `get_metadata_item({ type, name, state? })` reads one item's full definition: the pending draft where one exists, unless `state` selects the draft or the published version. An item that does not exist answers `404 RESOURCE_NOT_FOUND`.
- `list_drafts({ package? })` lists the pending drafts, optionally for one package.

The tools are served only where both halves hold: the token consents (`metadata:write`) and the user the token was issued to holds `manage_metadata` in the organization the token bound. The user's capability is read from their own grants on each request, because an OAuth agent's envelope carries no system permission without `actions:execute`. A token whose user lacks the capability is listed none of the three tools, and a call that reaches them anyway is refused `403 PERMISSION_DENIED`. A token without `metadata:write`, an API key and a session see none of them, as before. When the user's grants cannot be read, the tools are not served on that request and the runtime logs one warning.

The reads withhold what every `/meta` door withholds from that user, judged by the same read gates with the user as the caller: a dashboard, a list view or an app whose `requiredPermissions` the user does not hold, and a book or doc outside their audience, are refused `403 PERMISSION_DENIED` by `get_metadata_item` and left out of `list_metadata_items`. Before either gate, both reads ask the type-level read admission every `/meta` read asks: a metadata type the user may not read is refused `403 PERMISSION_DENIED` on both, whatever its spelling or `state`. Holding `manage_metadata` does not lift these refusals. A gate that cannot evaluate refuses the read.

The read tools are named `list_metadata_items` and `get_metadata_item`, not `list_metadata` and `get_metadata`, because `list_metadata` is a hosted platform tool. Nothing here writes: saving and discarding drafts, and the publish verdict a save answers with, come in a later change.
2 changes: 2 additions & 0 deletions docs/design/mcp-local-first-door.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Tools, registered by a new open registry behind `metadata:write`, each checking
| `delete_metadata_draft({ type, name })` | Discards a pending draft | |
| `list_drafts({ package? })` | Pending drafts with their verdicts | The review queue, as the client sees it |

> **Note (2026-11-17):** the two read tools are named `list_metadata_items` and `get_metadata_item`, because `list_metadata` is a cloud platform tool (`packages/spec/src/system/constants/platform-tool-names.ts:97`) and the open registry must not collide with it (seat ruling D3 on #34766, 2026-11-17).

- No publish tool, no `force`: a draft executes nothing, and the destructive-change confirmation stays at the human publish.
- `initialize` instructions and discovery state `Authoring contract: @objectstack/spec <version>` and the install line for `@objectstack/skills@<version>`.
- The open runtime serves `GET /api/v1/discovery/restriction-profile` (mount what the CLI already reads).
Expand Down
26 changes: 26 additions & 0 deletions packages/mcp/src/skill-md-surface-guard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,29 @@ describe('SKILL.md ↔ native tool surface drift guard', () => {
expect(taughtButUnregistered, `the Build section teaches a tool this grant does not register: ${taughtButUnregistered.join(', ')}`).toEqual([]);
});
});

/**
* [#34766] The open draft door's read tools, named as the runtime registry
* names them (`OPEN_AUTHORING_READ_TOOL_NAMES` in
* `@objectstack/runtime`, `src/domains/mcp-authoring.ts`; this package cannot
* import it). The SDK refuses a second registration under a name already on
* the server by throwing, so a collision with any native tool would fail
* every `metadata:write` request the open runtime serves.
*/
const OPEN_DRAFT_DOOR_READ_TOOLS = ['list_metadata_items', 'get_metadata_item', 'list_drafts'];

describe('[#34766] the open draft door\'s read tools collide with no native tool', () => {
it('registers beside the full native surface under every scope', async () => {
const native = await listRegisteredToolNames({ grantedScopes: EVERY_SCOPE });
for (const name of OPEN_DRAFT_DOOR_READ_TOOLS) expect(native, name).not.toContain(name);

const registry: McpAuthoringToolRegistry = {
getAll: () => OPEN_DRAFT_DOOR_READ_TOOLS.map((name) => ({ name, description: name, parameters: { type: 'object', properties: {} } })),
async execute(toolCall): Promise<ToolExecutionResult> {
return { type: 'tool-result', toolCallId: toolCall.toolCallId, toolName: toolCall.toolName, output: { type: 'text', value: '' } } as ToolExecutionResult;
},
};
const withDoor = await listRegisteredToolNames({ grantedScopes: EVERY_SCOPE, registry });
expect(withDoor.sort()).toEqual([...native, ...OPEN_DRAFT_DOOR_READ_TOOLS].sort());
});
});
Loading
Loading