Skip to content

Commit 80da086

Browse files
fix(mcp): initialize points at the served SKILL.md; run_action names the no_confirmation_service next step (#37355)
Fixes #35778 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:连接开放 MCP 入口的 AI 客户端,初始化时会被告知使用指南在哪里下载;执行需人工确认的业务动作被拒时,工具说明会告诉它由人在应用里完成。 - 为什么做:上一轮把教学文字从工具说明挪进了使用指南,不读指南的客户端失去了指引,这里补回两句提示(属于"让自带 AI 的客户端在开放入口拿到受治理答案"这条主线)。 - 出错会怎样:只是给 AI 读的提示文字,说错了 AI 可能找错地址或多问一句,不会改数据;可直接撤回。 - 要你做什么:无。 ## What changes Items 1 and 2 of #35778. **Item 3 (optional slimming of list_datasets / query_dataset, the spec `QueryDatasetInputSchema` and the validate_expression variable descriptions) is not taken**: the card marks it optional and measure-first, and it stays open on the card. 1. `packages/mcp/src/mcp-server-runtime.ts`: the open door's default `initialize` text (`DEFAULT_HTTP_INSTRUCTIONS`) gains one sentence: `Usage guide (SKILL.md): GET this endpoint's path plus /skill (by default /api/v1/mcp/skill).` - Where it is true: the runtime dispatcher mounts `GET PREFIX/mcp/skill` beside `PREFIX/mcp` from the same domain list (`packages/runtime/src/domains/mcp.ts` `createMcpDomains`, mounted in `dispatcher-plugin.ts` with the same `prefix`, default `/api/v1`), behind the same `isMcpServerEnabled()` switch, answered by the same `mcp` service (`renderSkill`), and anonymous, so it holds for every grant. `handleHttpRequest`'s only caller in this repo is that domain. The sentence is relative to the endpoint because the prefix is configurable. - Where it is not added: a host's per-request texts and a configured `instructions` stay whole (existing pins), and the stdio default names no URL, since a stdio server has no HTTP endpoint. 2. `packages/mcp/src/mcp-http-tools.ts`: `run_action`'s description gains one clause after the ACTION_CONFIRMATION_REQUIRED sentence: `On details.reason "no_confirmation_service" a person performs it in the app: do not make the same change with another tool.` - It restores the pre-#35682 in-app hint, and adds the "not through another tool" half the qa record on #34325 (6966146204) asks the refusal wording to carry. It is door-neutral: true on stdio and on Streamable HTTP. It does not anticipate #34325's stdio-only sentence (use a client that supports confirmation), which belongs to the refusal text on that card, and stays consistent with ruling 6909391261 (HTTP keeps the hand-off path; cancel/timeout refused). Byte deltas: - tools/list on the API-key surface (`tools-list-weight-34689.test.ts`): 36,613 to 36,739 bytes (+126); `run_action` description 1,228 to 1,352 (+124). The ceiling of 38,000 is unchanged and still holds. - Default `initialize` text: +93 bytes (a bare bridge answers 533 characters). The 4,096-character bound pin on the longest default text still passes. ## Tests - New top-level describes in the existing harness files: - `initialize-selection-rule-34686.test.ts`: the pointer is in the first paragraph for five grants (no scope, data:read, data:write, metadata:write with an authoring injection, data:read with one). - `mcp-action-confirmation-handoff-33690.test.ts`: `run_action`'s tools/list description carries the clause. - Ablations, one-off, via `scripts/ablation-replace.mjs` (anchor hit 1 to 0, restored blob equal to HEAD, `git diff HEAD` empty). The tests import the source, so no dist rebuild sits in the path: - pointer removed: the new initialize pin fails (1 failed, 14 passed); - clause removed: the new run_action pin fails (1 failed, 28 passed). ## Acceptance notes - Not verified: a cloud host that calls `handleHttpRequest` from its own code and mounts the MCP endpoint without the runtime dispatcher. Such a host gets this default only when it injects no instructions of its own. If it serves no sibling `/skill` path, the sentence would not hold there; nothing in this repo is such a caller. ## Verification Two-minute check: `pnpm --filter @objectstack/mcp exec vitest run src/initialize-selection-rule-34686.test.ts src/mcp-action-confirmation-handoff-33690.test.ts src/tools-list-weight-34689.test.ts`. Expect 3 files passing, and a tools/list table line `| run_action | 1352 | 884 | 2236 |`. Readings at e3c3ac4: <details><summary>mcp build, typecheck, vitest (under os-verify-lock)</summary> - `@objectstack/mcp...` build: VERDICT command-exit 0. - `pnpm --filter @objectstack/mcp typecheck`, then the full `vitest run --maxWorkers=2`: VERDICT command-exit 0. Test Files 85 passed (85), Tests 1509 passed (1509). check:test-typecheck OK. </details> <details><summary>derived gate families</summary> - `dispatch-gates --commands --repo objectstack-ai/objectstack`: 68 families. - Results: 67 exit 0. `check:dual-build-cjs-loads` exit 3 (PREREQUISITE NOT MET: no whole-repo dist), so it is NOT MEASURED locally and left to CI. - `--ran` with exit codes: 68 derived, 67 run, 1 NOT-MEASURED, 0 UNRUN. - `overlap-check`: clean against origin/main. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01QSeKYo86w1wqy2z2fMrryr)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QSeKYo86w1wqy2z2fMrryr <!-- signed: repo:objectstack#4 · os-justin · session_01QSeKYo86w1wqy2z2fMrryr --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 84a27e7 commit 80da086

5 files changed

Lines changed: 62 additions & 1 deletion
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@objectstack/mcp': patch
3+
---
4+
5+
Clause-②: no
6+
Metadata-protocol: none
7+
8+
The open MCP door's default `initialize` instructions now say where the usage guide is served: a `GET` on the MCP endpoint's path plus `/skill` (by default `/api/v1/mcp/skill`) returns the `SKILL.md` that carries the teaching text the tool descriptions no longer hold. A host's own instructions and a configured `instructions` text are unchanged. `run_action`'s description again says what a `no_confirmation_service` refusal leaves the caller: a person performs the action in the app, and the agent does not make the same change with another tool.

‎packages/mcp/src/initialize-selection-rule-34686.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,28 @@ describe('[#34774] initialize instructions — the authoring contract line, and
304304
expect(text.length).toBeLessThan(4096);
305305
});
306306
});
307+
308+
/**
309+
* [#35778] The default text says where the usage guide is served: the teaching
310+
* prose moved out of the tool descriptions into the served SKILL.md, so a
311+
* client that never fetches it is pointed there. The route is anonymous and
312+
* mounted beside the MCP endpoint, so the sentence rides every grant's default
313+
* answer; a host's or the configured text stays whole (pinned above).
314+
*/
315+
describe('[#35778] initialize instructions — the default text points at the served SKILL.md', () => {
316+
const POINTER = 'Usage guide (SKILL.md): GET this endpoint\'s path plus /skill (by default /api/v1/mcp/skill).';
317+
const runtime = new MCPServerRuntime({ name: 't', version: '0.0.1-operator' });
318+
319+
it('is in the first paragraph for every grant, with and without an authoring registry', async () => {
320+
for (const o of [
321+
{},
322+
{ grantedScopes: [MCP_OAUTH_SCOPE_DATA_READ] },
323+
{ grantedScopes: [MCP_OAUTH_SCOPE_DATA_WRITE] },
324+
{ grantedScopes: [MCP_OAUTH_SCOPE_METADATA_WRITE], authoring: {} },
325+
{ grantedScopes: [MCP_OAUTH_SCOPE_DATA_READ], authoring: {} },
326+
] as Opts[]) {
327+
const text = await instructionsOf(runtime, makeBridge(), o);
328+
expect(text.split('\n\n')[0], JSON.stringify(o)).toContain(POINTER);
329+
}
330+
});
331+
});

‎packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,3 +511,19 @@ describe('[#33712] Streamable HTTP: initialize batched with a tool call', () =>
511511
expect(bridge.calls).toEqual([]);
512512
});
513513
});
514+
515+
/**
516+
* [#35778] run_action's description says what the no-service refusal leaves
517+
* the caller: a person performs the action in the app, and the agent does not
518+
* make the same change through another tool. Door-neutral: it reads true on
519+
* the stdio door and on Streamable HTTP.
520+
*/
521+
describe('[#35778] run_action names the next step on a no_confirmation_service refusal', () => {
522+
it('its tools/list description carries the in-app clause', async () => {
523+
const json = await call(makeBridge('none'), { jsonrpc: '2.0', id: 1, method: 'tools/list' });
524+
const runAction = (json.result.tools as Array<{ name: string; description: string }>).find((t) => t.name === 'run_action');
525+
expect(runAction?.description).toContain(
526+
'On details.reason "no_confirmation_service" a person performs it in the app: do not make the same change with another tool.',
527+
);
528+
});
529+
});

‎packages/mcp/src/mcp-http-tools.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4977,6 +4977,10 @@ export function registerActionTools(
49774977
'you are answered status "pending_confirmation" with a pendingId: do not retry, tell the user to approve ' +
49784978
'it. A refusal ACTION_CONFIRMATION_REQUIRED (declined, cancelled, timed out, or no confirmation service) ' +
49794979
'means nothing ran; do not retry unless the user asks. ' +
4980+
// [#35778] The no-service reason's next step, door-neutral: true
4981+
// whether or not the client could have confirmed in place.
4982+
'On details.reason "no_confirmation_service" a person performs it in the app: do not make the same change ' +
4983+
'with another tool. ' +
49804984
// [ADR-0151 D3 rule 3] An AI service account is refused, never handed off.
49814985
'Under an AI service account\'s own key the call is refused whatever it sends: hand the action to a ' +
49824986
'person, or its author declares ai.requiresConfirmation: false when it is safe unattended. ' +

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1794,9 +1794,17 @@ function hostInstructions(
17941794
* every grant (a `metadata:write`-only or `actions:execute`-only token lists
17951795
* no data tool) and with or without a build door mounted, so it never
17961796
* promises building to a deployment that has none.
1797+
* [#35778] It also says where the usage guide is: the teaching prose lives in
1798+
* the served SKILL.md, not in the tool descriptions, so a client that never
1799+
* fetches it is told where it went. The runtime dispatcher mounts the public
1800+
* `GET <prefix>/mcp/skill` beside `<prefix>/mcp`, from the same domain list,
1801+
* behind the same enable switch and for every grant (it is anonymous), so the
1802+
* sentence names it relative to this endpoint and gives the default prefix.
1803+
* The stdio default names no URL: a stdio server has no HTTP endpoint.
17971804
*/
17981805
const DEFAULT_HTTP_INSTRUCTIONS =
1799-
'ObjectStack MCP Server. The tools this connection lists depend on what its credential was granted.';
1806+
'ObjectStack MCP Server. The tools this connection lists depend on what its credential was granted. '
1807+
+ 'Usage guide (SKILL.md): GET this endpoint\'s path plus /skill (by default /api/v1/mcp/skill).';
18001808

18011809
/**
18021810
* [#34774] The authoring contract line (#34659 ruling D4 = A): the

0 commit comments

Comments
 (0)