Repository navigation
Commit c2cabce
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
File tree
- .changeset
- content/docs
- ai
- references/ai
- packages
- lint/src
- mcp/src
- metadata-protocol/src
- spec
- authorable-surface
- liveness
- state-counts
- src
- ai
- system
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
273 | 285 | | |
274 | 286 | | |
275 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
502 | 527 | | |
503 | 528 | | |
504 | 529 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
| 40 | + | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
60 | 77 | | |
61 | 78 | | |
62 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
2464 | 2465 | | |
2465 | 2466 | | |
2466 | 2467 | | |
2467 | | - | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
2468 | 2474 | | |
2469 | 2475 | | |
2470 | | - | |
2471 | | - | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
2472 | 2487 | | |
2473 | 2488 | | |
2474 | 2489 | | |
| |||
0 commit comments