Skip to content

Commit c2cabce

Browse files
feat(spec, mcp): a skill written for the in-product agents only opts out of MCP prompts with mcpPrompt: false (#34236)
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoSLDKWQ8v7cxY9uDGijfncD)_ Fixes #34167 Clause-②: yes (widening) Metadata-protocol: added Skills-docs: follow-up #34237 ## 维护者速读 - **改了什么:** `SkillSchema` 新增可选布尔键 `mcpPrompt`。设为 `false` 的技能永远不会作为 MCP 提示词出现:`prompts/list` 不列出,`prompts/get` 按未知名称回答,HTTP 与 stdio 两条路径、任何连接、无论绑定哪些工具都一样(stdio 的列表在启动时取一次,运行中改成 `false` 的技能列表里留到重启,但 get 立即按未知回答)。 - **为什么改:** 工具绑定只能回答"这个连接能不能跑这份剧本",回答不了"这份剧本是不是写给 MCP 的"。cloud 的 `record_writing`、`actions_executor` 绑定的工具 MCP 也同名提供,却教模型调用产品内工具、等待产品内审批卡片;cloud 现在靠代理过滤,有了这个键就能删掉代理(cloud#4337 的后半)。 - **风险与回滚:** 纯加法:键没有默认值,不设置的技能解析结果与投影都和之前逐字节一致;产品内智能体不读这个键。回滚即 revert 本 PR,无需迁移。 - **先看:** `packages/mcp/src/skill-prompts.ts` 的 `projectSkillPrompt`(主判断点)和 `mcp-server-runtime.ts` 里 stdio get 回调的撤回分支;`packages/spec/src/ai/skill.zod.ts` 的新键与 `tools` 说明;`packages/mcp/src/skill-prompts.test.ts` 末尾的新 describe。 - **两分钟验证:** `pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2 src/skill-prompts.test.ts`,预期 36 个用例全绿,其中 9 个是本卡新增(含 stdio 四例)。 - **需要你做的:** 无,席位落地(合同档复核通过后)。 ## What changes **The key.** `SkillSchema.mcpPrompt?: boolean`, no default. `false` declares the skill written for the in-product `ask` / `build` agents only. Absent or `true`: offered exactly as before, where the server serves every tool the skill binds (#32767's binding test, unchanged). **Where it is enforced.** In `projectSkillPrompt`, beside `active: false`. That is the one function both MCP doors read, so a declared skill is withheld: - by `registerSkillPrompts`, the per-request HTTP prompt surface (`/api/v1/mcp`) and any host server that calls it: not in `prompts/list`, and `prompts/get` answers it with the same `-32602` "Prompt not found" an unknown name gets, even on a connection that serves every tool it binds; - by `MCPServerRuntime.bridgePrompts`, the long-lived stdio server, which applies no binding filter at all. Before this, an in-product skill reached stdio clients whatever its tools. **The stdio window.** The stdio server registers its prompt list once, at boot, and each registered prompt's get re-reads the store, falling back to the boot snapshot when the skill is no longer found. A skill saved with `mcpPrompt: false` while the server runs would have stayed gettable from that snapshot. The get now asks `skillPromptWithdrawn` on the same re-read: a row of that name and holder that declares `mcpPrompt: false` is answered with the SDK's own unknown-prompt error (`-32602`, `Prompt NAME not found`). The list stays the boot snapshot until restart, as it already is for any skill saved after boot; the docs and the JSDoc say so. A skill that is simply gone, or deactivated after boot, keeps the snapshot fallback exactly as before: folding `active: false` into the same branch would change an existing stdio answer outside this card. **Why not `surface`.** `ask` / `build` / `both` are all in-product affinities read by the cloud runtime's skill resolution; any new member would change that read. A separate key changes nothing the in-product runtime reads. **Docs.** The key's JSDoc and `describe` text, plus the `instructions` and `tools` describe text (the binding answers "can it run", not "is it written for MCP"). `content/docs/ai/connect-mcp.mdx` (prompts section, with an example) and `content/docs/ai/agents.mdx` (the two-halves table and the binding paragraph). The generated `references/ai/skill.mdx` follows. **Form.** The skill form does not offer the key; the form-reconciliation ledger carries an `omit` row with the reason. Unset means offered and the key has no default, so its meaning lives in its absence. The form's boolean control is a switch that draws unset as off (`checked={!!value}`), so every offered skill would read as withheld; a select writes its option value as a string, which the boolean key refuses. Authors set it in source or through the metadata API. **Ledgers.** `liveness/skill.json` gains a `mcpPrompt` row on in-repo evidence (`projectSkillPrompt`); no cloud row is touched or re-stamped. The `/meta/types` count pin moves `skill` 16 → 17. `packages/mcp/src/skill-md.ts` and its console mirror do not teach skill prompts (one code comment), so they are unchanged. **Consumer.** objectstack-ai/cloud#4337: cloud marks its in-product skill rows `mcpPrompt: false`, drops its `mcp-skill-prompts.ts` proxy, and widens its e2e to `data:write` / `actions:execute` tokens. That is cloud's own change, not this PR. ## Tests In `packages/mcp/src/skill-prompts.test.ts`, a new top-level `describe` in the existing harness, driven through the real JSON-RPC wire: - CONTROL (the card's reproduction): undeclared, `record_writing` (binds `create_record`, `update_record`) is listed on a `data:read` + `data:write` connection, and `actions_executor` (binds `action_*`) on an `actions:execute` connection. - Declared, `record_writing` is not listed on that `data:write` connection or on one serving everything; same for `actions_executor` on `run_action`. - `prompts/get` answers a declared skill exactly as it answers an unknown name (code, no data, same message). - CONTROL: `mcpPrompt: true` projects exactly as undeclared, beside a declared row. - stdio (`bridgePrompts`): CONTROL, an undeclared skill binding `open_record` (a tool no MCP family serves) is listed and got, which proves the binding filter is not what could hide it; declared, the same skill is neither listed nor got, beside an undeclared sibling that is. - stdio window: a skill listed at boot and then saved `mcpPrompt: false` is answered by `prompts/get` exactly as a never-registered name (code and message), while its sibling still serves. CONTROL: a skill gone from the store since boot is still served from the snapshot, as before. In-product unchanged: the in-product resolution lives in cloud, and this repo has no runtime reader of it. The in-repo readers of the skill's wiring half are the authoring checks: `validateAiSurfaceAffinity` and `validateAiToolReferences` each get a pin that `mcpPrompt: false` yields findings equal to the undeclared skill's. `skill.test.ts` pins that the key accepts booleans and refuses others, that an undeclared skill parses with no `mcpPrompt` key, and that `surface` / `tools` / `triggerConditions` / `active` parse the same with it. The #32767 binding tests are unchanged and green. <details><summary>Ablation (both doors, one mutation each run)</summary> The check is one line in `projectSkillPrompt`, so each door was ablated by deleting it through `scripts/ablation-replace.mjs` (anchor hit 1 → 0, blob `f2ceb1ef77ae` → `a036269c28c7`) and running that door's pins, then restored (blob back to HEAD, `git diff HEAD` empty). The mcp tests import `src/`, so no build sits between the mutation and the run. - HTTP (`registerSkillPrompts`): 4 failed, 1 passed. Red: record_writing on `data:write`, actions_executor on `run_action`, the `prompts/get` parity pin, the `mcpPrompt: true` control (its declared sibling leaked). Green: the reproduction control, as predicted. - stdio (`bridgePrompts`): 1 failed, 1 passed. Red: the declared skill is listed. Green: the undeclared control. - stdio window (round 2, head `c53ea9d14`): the withdrawal branch disabled (`if (false && skillPromptWithdrawn(…))`, anchor 1 → 0, blob `9dbcf68fc246` → `d26192d35f8b`), `-t bridgePrompts`: 1 failed, 3 passed. Red: the opted-out get. Green: both controls and the boot-time declared case. Restored, blob == HEAD, `git diff HEAD` empty. </details> ## Verification Round 2 at head `c53ea9d14` (round 1 at `50ccfc48f`). <details><summary>Package tests and typecheck</summary> - Round 2: `pnpm --filter @objectstack/mcp test` 65/65 files, 1195 tests; spec `src/ai/skill.test.ts` + `src/system/metadata-form-zod-reconciliation.test.ts` 94/94; platform-objects `src/apps/translations` 26/26 files, 587 tests (catalogs back to main); `pnpm --filter @objectstack/mcp typecheck` exit 0; `pnpm lint` exit 0. - Round 1: spec 844 files (26994 tests), lint 212 (9032), mcp 65 (1193), metadata-protocol 343 + 9 skipped (22937); `typecheck` on spec, mcp, lint, metadata-protocol, platform-objects exit 0. Round 2 changed no lint or metadata-protocol file, and spec only in a JSDoc comment and a ledger row. </details> <details><summary>Derived gates</summary> - Round 2, `node scripts/pm/dispatch-gates.mjs --commands` against this diff: 114 families, every one run at `c53ea9d14` with its exit code recorded, all exit 0. `--ran` reconciliation: "114 derived, 114 run, 0 NOT-MEASURED, 0 UNRUN", a derived zero. - Round 1 needed a fetched pinned fixture sha and a full `pnpm build` for four prerequisite gates; both still stand in this worktree. </details> ## Acceptance notes - The changeset is `minor` on `@objectstack/spec` and `@objectstack/mcp` (Metadata-protocol `added`). - The skill form leaves `mcpPrompt` out (see Form above). A form control that shows the unset state needs a tri-state boolean control in the metadata form renderer under `ui/`; noted here, not filed. - Deactivating a skill (`active: false`) after the stdio server booted still leaves its get serving the boot snapshot. That predates this card and is left as it was. - `Skills-docs:` #34237 teaches `mcpPrompt` in the published `skills/objectstack-ai/SKILL.md`. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qiby4dRyeuWrpDd4sZKx)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 04e7b90 commit c2cabce

16 files changed

Lines changed: 377 additions & 11 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/mcp': minor
4+
---
5+
6+
feat(spec, mcp): a skill written for the in-product agents only opts out of MCP prompt projection with `mcpPrompt: false`
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: added
10+
11+
`SkillSchema` gains an optional boolean, `mcpPrompt`. A skill that sets `mcpPrompt: false` is never offered as an MCP prompt: `prompts/list` leaves it out and `prompts/get` answers it exactly as it answers an unknown prompt name. This holds on every MCP connection, the per-request HTTP endpoint and the long-lived stdio server alike, and whatever the skill's `tools` binding, including on a connection that serves every tool it binds.
12+
13+
The binding test (a skill is offered only where the connection serves every tool it binds) answers whether a connection can run a playbook. It cannot tell whether the playbook is written for MCP. A skill can bind tools MCP serves under the same names, such as `create_record` and `update_record`, or `action_*` through `run_action`, and still tell the model to call in-product tools and wait for the in-product approval card, which an MCP client does not have. The skill's owner now says so on the skill.
14+
15+
The stdio server takes its prompt list once, at boot. A skill saved with `mcpPrompt: false` while it runs stays on that list until restart, as any skill saved after boot is missing from it, but its `prompts/get` answers it as unknown at once.
16+
17+
A skill without the key, or with `mcpPrompt: true`, is offered exactly as before, and nothing parses differently: the key has no default. The key changes nothing on the in-product agent runtime, which resolves, binds and activates the skill as it did, and the authoring checks on `tools` and `surface` report the same findings. The skill form does not offer the key: unset means offered, and the form's boolean switch would draw every offered skill as off, so `mcpPrompt` is authored in source or through the metadata API.
18+
19+
Nothing to migrate.

‎content/docs/ai/agents.mdx‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ itself (a different LLM-facing description, fewer exposed parameters).
252252

253253
| Half | Keys | Where it runs |
254254
|---|---|---|
255-
| **Judgment** | `instructions` | **Both editions.** On the open framework `@objectstack/mcp` serves it as an MCP **prompt** — a connected client can `prompts/list` it by name and `prompts/get` the text ([Connect an MCP client](/docs/ai/connect-mcp#prompts-your-skills-served-to-the-client)), on a server that serves the tools the skill binds (below). On **ObjectOS** it is injected into the active agent's system prompt. |
255+
| **Judgment** | `instructions`, `mcpPrompt` | **Both editions.** On the open framework `@objectstack/mcp` serves it as an MCP **prompt** — a connected client can `prompts/list` it by name and `prompts/get` the text ([Connect an MCP client](/docs/ai/connect-mcp#prompts-your-skills-served-to-the-client)), on a server that serves the tools the skill binds (below), unless the skill sets `mcpPrompt: false`. On **ObjectOS** it is injected into the active agent's system prompt. |
256256
| **Wiring** | `tools`, `surface`, `triggerConditions` | **Bound on ObjectOS only.** Composing an agent's tool set and deciding when a skill activates are properties of an in-product agent loop. Over MCP the model lives in the client and drives one flat tool list, and your AI-exposed Actions already reach it through `list_actions` / `run_action`. `surface` and `triggerConditions` are inert there; `tools` is read, and decides whether the skill is offered. |
257257

258258
**Over MCP, `tools` decides whether the skill is offered.** The prompt surface
@@ -270,6 +270,18 @@ applies no such filter. So bind a skill only to tools its intended connections
270270
serve: one that names a tool no MCP tool family serves is offered on no such
271271
connection unless a host registers that tool.
272272

273+
**A skill written only for the in-product agents opts out of MCP with
274+
`mcpPrompt: false`.** Its instructions may assume the in-product tool set or
275+
the in-product approval card even when every tool it binds is one MCP serves
276+
too. With `mcpPrompt: false` the skill is never listed by `prompts/list` and is
277+
unknown to `prompts/get`, on every MCP connection, stdio included, whatever its
278+
`tools`. The stdio server takes its list once, at boot: a skill switched to
279+
`false` while it runs stays listed until restart, but `prompts/get` answers it
280+
as unknown at once.
281+
Absent or `true`, it is offered as described above. ObjectOS reads the
282+
skill exactly as before: the key decides MCP projection and nothing else
283+
([Connect an MCP client](/docs/ai/connect-mcp#prompts-your-skills-served-to-the-client)).
284+
273285
Both halves are still **validated everywhere** — a skill naming a tool that
274286
does not exist is an authoring error in either distribution. So a skill written
275287
against the open framework keeps its full meaning when the app runs on

‎content/docs/ai/connect-mcp.mdx‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,31 @@ offered as before. When a prompt you expect is missing, connect with a grant
499499
that registers the skill's tools, or bind the skill only to tools its intended
500500
connections serve.
501501

502+
**A skill written for the in-product agents opts out.** The binding answers
503+
whether a connection *can* run a playbook, not whether the playbook is written
504+
for MCP: a skill can bind tools MCP serves under the same names
505+
(`create_record`, `action_*` through `run_action`) and still tell the model to
506+
call in-product tools or wait for the in-product approval card. Set
507+
`mcpPrompt: false` on such a skill and it is never offered as a prompt:
508+
`prompts/list` leaves it out and `prompts/get` answers it as an unknown prompt
509+
name, on every connection (HTTP and stdio) and whatever its `tools`. (The
510+
stdio server lists its prompts once, at boot, so a skill switched to
511+
`mcpPrompt: false` while it runs stays listed until restart; its `prompts/get`
512+
answers unknown at once.) Leave the key out, or set `true`, and the skill is
513+
offered as above. The key changes
514+
nothing on the in-product runtime: the `ask` / `build` agents resolve, bind
515+
and activate the skill exactly as before.
516+
517+
```typescript
518+
export const RecordWritingSkill = defineSkill({
519+
name: 'record_writing',
520+
label: 'Record Writing',
521+
instructions: 'Open the record, propose the change, and wait for the user to confirm on the card.',
522+
tools: ['create_record', 'update_record'],
523+
mcpPrompt: false, // written for the in-product agents only
524+
});
525+
```
526+
502527
**Only the instructions half projects.** A skill's `tools` / `surface` /
503528
`triggerConditions` are bound by the **in-product agent runtime** (the `ask` /
504529
`build` agents, cloud / Enterprise), which is the thing that composes a tool set

‎content/docs/references/ai/skill.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ const result = SkillSchema.parse(data);
3737
| **label** | `string` | ✅ | Skill display name |
3838
| **description** | `string` | optional | Skill description |
3939
| **surface** | `Enum<'ask' \| 'build' \| 'both'>` | optional (default: `"ask"`) | Agent surface this skill binds to ('ask' \| 'build' \| 'both') — ADR-0063 §3; read by the cloud agent runtime only |
40-
| **instructions** | `string` | optional | LLM instructions when skill is active — also served as an MCP prompt |
41-
| **tools** | `string[]` | ✅ | Tool names belonging to this skill (supports trailing wildcard, e.g. `action_*`) — bound by the cloud agent runtime; an MCP server whose prompts `registerSkillPrompts` installs offers the skill only when it serves every tool named here (an `action_` entry also through `run_action`) |
40+
| **instructions** | `string` | optional | LLM instructions when skill is active — also served as an MCP prompt unless mcpPrompt is false |
41+
| **tools** | `string[]` | ✅ | Tool names belonging to this skill (supports trailing wildcard, e.g. `action_*`) — bound by the cloud agent runtime; an MCP server whose prompts `registerSkillPrompts` installs offers the skill only when it serves every tool named here (an `action_` entry also through `run_action`); `mcpPrompt: false` withholds it from MCP whatever this binding |
4242
| **triggerConditions** | `{ field: string; operator: Enum<'eq' \| 'neq' \| 'in' \| 'not_in' \| 'contains'>; value: string \| string[] }[]` | optional | Programmatic activation conditions — evaluated by the cloud agent runtime only |
4343
| **active** | `boolean` | optional (default: `true`) | Whether the skill is enabled |
44+
| **mcpPrompt** | `boolean` | optional | Whether this skill is offered as an MCP prompt. false = written for the in-product agents only: never listed by prompts/list and unknown to prompts/get on any MCP connection, whatever its tools binding. Absent or true = offered where the server serves its tools |
4445
| **protection** | `{ lock: Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>; reason: string; docsUrl?: string }` | optional | Package author protection block — lock policy for this skill. |
4546
| **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). |
4647
| **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. |

‎packages/lint/src/validate-ai-surface-affinity.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ describe('validate-ai-surface-affinity', () => {
7373
expect(findings[0].message).toContain("'build'");
7474
});
7575

76+
it('reads a skill its owner keeps out of MCP (mcpPrompt: false) exactly as one without the key (#34167)', () => {
77+
// The opt-out narrows MCP prompt projection only; the in-product binding
78+
// this rule guards is the same either way.
79+
const stack = (mcpPrompt?: boolean) => ({
80+
agents: [{ name: 'helper', surface: 'ask', skills: ['metadata_authoring', 'record_writing'] }],
81+
skills: [
82+
{ name: 'metadata_authoring', surface: 'build', tools: [], ...(mcpPrompt === undefined ? {} : { mcpPrompt }) },
83+
{ name: 'record_writing', surface: 'ask', tools: ['create_record'], ...(mcpPrompt === undefined ? {} : { mcpPrompt }) },
84+
],
85+
});
86+
const undeclared = validateAiSurfaceAffinity(stack());
87+
expect(undeclared).toHaveLength(1);
88+
expect(validateAiSurfaceAffinity(stack(false))).toEqual(undeclared);
89+
});
90+
7691
it("flags a 'build' agent referencing an 'ask' skill (symmetric)", () => {
7792
const stack = {
7893
agents: [{ name: 'builder', surface: 'build', skills: ['data_explorer'] }],

‎packages/lint/src/validate-ai-tool-references.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ describe('validate-ai-tool-references', () => {
5757
]);
5858
});
5959

60+
it('checks the tools of a skill its owner keeps out of MCP (mcpPrompt: false) exactly as without the key (#34167)', () => {
61+
// The opt-out narrows MCP prompt projection only: the binding is still the
62+
// in-product agent's tool set, and still checked in both distributions.
63+
const stack = (mcpPrompt?: boolean) => ({
64+
skills: [
65+
{
66+
name: 'record_writing',
67+
tools: ['create_record', 'update_record', 'open_record_card'],
68+
...(mcpPrompt === undefined ? {} : { mcpPrompt }),
69+
},
70+
],
71+
});
72+
const undeclared = validateAiToolReferences(stack());
73+
expect(undeclared).toHaveLength(1);
74+
expect(validateAiToolReferences(stack(false))).toEqual(undeclared);
75+
});
76+
6077
it('resolves declared stack.tools records (the optional refinement layer)', () => {
6178
const stack = {
6279
tools: [{ name: 'quote_discount', label: 'Quote', description: 'x' }],

‎packages/mcp/src/mcp-server-runtime.ts‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
skillPromptListEntry,
5050
skillPromptRefusalError,
5151
skillPromptResult,
52+
skillPromptWithdrawn,
5253
type McpSkillBridge,
5354
type SkillPrompt,
5455
} from './skill-prompts.js';
@@ -2464,11 +2465,25 @@ export class MCPServerRuntime {
24642465
},
24652466
async () => {
24662467
// Re-read at call time so an edited skill serves fresh instructions.
2467-
const lookup = lookupSkillPrompt(await listSkillPrompts(skillBridge), entry.face);
2468+
// One read: the projection and the withdrawal check below see the same rows.
2469+
const rows = (await skillBridge.listSkills()) ?? [];
2470+
const lookup = lookupSkillPrompt(
2471+
await listSkillPrompts({ ...skillBridge, listSkills: async () => rows }),
2472+
entry.face,
2473+
);
24682474
if (lookup.status === 'refused') throw skillPromptRefusalError(lookup);
24692475
if (lookup.status === 'found') return skillPromptResult(lookup.prompt);
2470-
// Gone since the snapshot: the snapshot's one skill, as before.
2471-
if (entry.prompts.length === 1) return skillPromptResult(entry.prompts[0]);
2476+
if (entry.prompts.length === 1) {
2477+
// [#34167] Withdrawn since the snapshot (`mcpPrompt: false`):
2478+
// answered as the SDK answers a name it never registered. This
2479+
// server's list is a boot snapshot and keeps the name until
2480+
// restart; the get stops serving it at once.
2481+
if (skillPromptWithdrawn(rows, entry.prompts[0])) {
2482+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${entry.face} not found`);
2483+
}
2484+
// Gone since the snapshot: the snapshot's one skill, as before.
2485+
return skillPromptResult(entry.prompts[0]);
2486+
}
24722487
throw skillPromptRefusalError({
24732488
status: 'refused',
24742489
message: duplicateSkillFaceMessage(entry),

0 commit comments

Comments
 (0)