Skip to content

Commit d558de0

Browse files
fix(runtime,mcp): the no_confirmation_service refusal names the route that works on the door that asked (#37367)
Fixes #34325 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:AI 客户端调用需要人工确认的业务动作、而服务器没有挂起审批服务时,拒绝提示会按入口说清楚该怎么办:本地(stdio)连接且客户端不支持弹框确认时,提示换用支持确认的客户端;所有入口都提示由人在应用里完成,并且不要改用别的工具做同样的修改。 - 为什么做:属于「MCP 写数」主线;此前有 AI 读到「去应用里做」后改用直接改记录的工具绕过了确认,维护者已同意在提示里明确禁止。 - 出错会怎样:只改拒绝提示的文字,错误码、状态和返回字段都不变,不会改数据;对外接口只新增可选项,已有接入方不受影响;可直接撤回。 - 要你做什么:无。 ## What changes The `no_confirmation_service` refusal (`428 ACTION_CONFIRMATION_REQUIRED`) that the MCP `run_action` and `resume_run` doors answer when a declared-gated action meets a host with no pending-confirmation service now names the route that works on the door that asked. The code, the status, `details` (including `reason`) and the hand-off handed to a host's service are unchanged. No spec file is touched. Messages, measured through the real runtime bridge (`buildMcpBridge`) at this head, for `archive_lead` on `crm_lead`: - Before, every door (main 80da086): `Action 'archive_lead' on 'crm_lead' declares ai.requiresConfirmation: true, so a person confirms it — nothing was run. This server has no pending-confirmation service to ask them through, and a confirmation sent on the request does not count. Perform the action in the app instead.` - After, stdio door, client without `elicitation`: `... does not count. A client that supports confirmation (MCP elicitation) is asked in place on this server: use one to confirm it here. Otherwise a person performs it in the app: do not make the same change with another tool.` - After, Streamable HTTP door (and any caller that passes no door): `... does not count. A person performs it in the app: do not make the same change with another tool.` The first sentence is the step-3 sentence of `AI_ACTION_CONFIRMATION_CAPABILITY`. It is left out on Streamable HTTP, which asks no client until #34321, as ruling 6909391261 on #33712 says. The in-app clause on every door is the wording of comment 6966146204 on this card. It matches the `run_action` description clause that #37355 added. How the refusal site knows the door: the MCP tools already decide per call whether the client can be elicited (`actionConfirmationElicitorFor`, from #34318). A new `actionCallDoorFor` in `packages/mcp/src/action-confirmation-elicitation.ts` returns one of three things: - `door`, main's `McpActionCallDoor` (the elicitor), when the client can be asked. The bridge is called with three arguments, as on main; - `facts`, `{ elicitsCapableClients: true }`, when this server read the client's `initialize` and can carry a request to it, but the client did not advertise form-mode `elicitation` (the long-lived stdio server today). The bridge is called as `(name, request, undefined, facts)`; - nothing, when the server never read `initialize` (the per-request Streamable HTTP server). The bridge is then called with two arguments, as before. The check is made on what the server can do, not on a transport name. If the HTTP door starts to read `initialize` (#34321), it gets the sentence at the same time as the elicitation that makes it true. The runtime bridge (`packages/runtime/src/domains/mcp.ts`) forwards the flag through `invokeBusinessAction` / `confirmAdmittedAction` (`action-dispatch.ts`) and `resumeActionRun` to `handOffActionConfirmation(..., door)` (`action-execution.ts`). It arrives as a separate argument, not on `ActionConfirmationHandOff`, so the host's service never sees it. Public surface of `@objectstack/mcp`, additive only (hence `Clause-②: yes (widening)`): - `McpActionCallDoor` is unchanged, and it is still passed only when the client can be elicited; - there is a new exported type `McpActionCallDoorFacts` (`{ elicitsCapableClients?: true }`); - `McpActionBridge.runAction` and `resumeRun` gain an optional fourth parameter `facts`. A bridge written against main compiles unchanged. It ignores the fourth argument and hands the call off as before, so only the refusal wording differs on such a bridge. ## Tests - `packages/runtime/src/action-confirmation-handoff-33690.test.ts`, new describe `[#34325]` (7 cases), run through the real bridge for both tools. With the stdio door, the message carries the client sentence followed by the in-app clause. With no door (HTTP), it carries the in-app clause and never the client sentence. `details` are equal on both doors. The flag never reaches the service's hand-off. - `packages/mcp/src/mcp-action-confirmation-handoff-33690.test.ts`, new describe `[#34325]` (6 cases), for both tools: - stdio with a client without `elicitation`: the bridge gets no door and exactly `{ elicitsCapableClients: true }` as the fourth argument; - stdio with a client that has the capability: main's door (the elicitor alone), three arguments, no facts; - Streamable HTTP after an `initialize` that advertised `elicitation`: no door, two arguments. - One existing #33712 pin, "a client WITHOUT the capability", pinned `door: undefined, argCount: 2` on stdio. The door is still `undefined`; the pin now also reads `facts: { elicitsCapableClients: true }` and `argCount: 4`. The intent is the same: the client is never asked and the call is handed off. The Streamable HTTP pin is unchanged. - Ablations, one-off, via `scripts/ablation-replace.mjs`: each anchor went from 1 hit to 0, and each restore left the blob equal to HEAD with an empty `git diff HEAD`. The tests import source through relative paths, so no dist rebuild is on the path. All 7 went red: - A1, the client sentence switched off: runtime stdio x2 red. - A2, the in-app clause reverted to today's wording: runtime stdio x2 and HTTP x2 red. - A3, the bridge's forwarding of the flag deleted: runtime stdio x2 red. - A4, `confirmAdmittedAction` stops passing it: runtime stdio `run_action` red. - A5, the resume path stops passing it: runtime stdio `resume_run` red. - A6, `actionCallDoorFor` never returns the facts: mcp stdio x3 red (one existing pin and two new ones). - A7, the facts are set without a read `initialize`: mcp HTTP x3 red (the existing #33712 HTTP pin and two new ones). - All seven re-run on head fa794d0 after the rework: same red sets, every restore equal to HEAD. ## Acceptance notes - An out-of-repo bridge built against main keeps compiling and behaving as today. On a stdio client without `elicitation` its refusal keeps the old wording until it reads `facts`. carrier: cloud (if cloud implements that bridge). - The spec's step-3 prose (`packages/spec/src/contracts/ai-service.ts`) still describes one message with both routes. The HTTP door's omission of the client route follows ruling 6909391261. The prose is left as it is. ## Verification Two-minute check: `pnpm --filter @objectstack/runtime exec vitest run src/action-confirmation-handoff-33690.test.ts -t 34325`. Expect 7 passing, including `stdio, a client without elicitation (run_action)` and `Streamable HTTP, no door (run_action)`. Readings at fa794d0: <details><summary>build, typecheck, vitest (under os-verify-lock)</summary> - `pnpm --filter '@objectstack/runtime^...' --filter '@objectstack/mcp^...' build && mcp typecheck && runtime typecheck && both pin files`: VERDICT command-exit 0 (pins 53/53 and 34/34). - `pnpm --filter @objectstack/mcp test`: MCP_EXIT=0, Test Files 85 passed (85), Tests 1515 passed (1515). - `pnpm --filter @objectstack/runtime test`: RUNTIME_EXIT=0, Test Files 649 passed (649), Tests 12034 passed, 25 skipped (12059). </details> <details><summary>derived gate families</summary> - `dispatch-gates --commands --repo objectstack-ai/objectstack`: 69 families. - 68 exit 0, including `check-adr-0087-registration` and `check-changeset-no-major` on the `yes (widening)` changeset. `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: 69 derived, 68 run, 1 NOT-MEASURED, 0 UNRUN (exit 0). - `overlap-check`: clean against origin/main 98bda0a. No merge of main was needed: main's 4 new commits do not touch `packages/mcp` or `packages/runtime`. </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 b8c8c88 commit d558de0

9 files changed

Lines changed: 301 additions & 30 deletions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@objectstack/runtime': patch
3+
'@objectstack/mcp': patch
4+
---
5+
6+
Clause-②: yes (widening)
7+
Metadata-protocol: none
8+
9+
The `no_confirmation_service` refusal (`428 ACTION_CONFIRMATION_REQUIRED`) of the MCP `run_action` and `resume_run` tools now names the route that works on the door that asked. On every door it says that a person performs the action in the app and that the same change must not be made with another tool. On the stdio door, for a client that did not advertise `elicitation`, it also says that a client that supports confirmation is asked in place on that server. The Streamable HTTP door, which asks no client, does not carry that sentence. The code, the status and `details` are unchanged. No type is made optional: `McpActionCallDoor` is unchanged, and it is still passed only when the client can be elicited. The added, optional surface is a new exported type `McpActionCallDoorFacts` (`{ elicitsCapableClients?: true }`) and an optional fourth parameter `facts` on `McpActionBridge.runAction` and `resumeRun`. The tools pass it, after an `undefined` door, only for a stdio client without `elicitation`. A bridge that does not read it compiles and answers as before.

‎packages/mcp/src/action-confirmation-elicitation.ts‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ export interface McpActionCallDoor {
9595
elicitConfirmation: McpActionConfirmationElicitor;
9696
}
9797

98+
/**
99+
* [#34325] What the action tools tell the bridge about the door when no
100+
* elicitor rides beside the call, passed as the bridge method's fourth
101+
* argument (after an `undefined` door). Additive: a bridge that does not read
102+
* it hands the call off exactly as before.
103+
*/
104+
export interface McpActionCallDoorFacts {
105+
/**
106+
* This door would ask a client that advertised `elicitation` (it read the
107+
* client's `initialize` and can carry a request to it while the call is
108+
* open), and this call's client did not advertise it. The
109+
* `no_confirmation_service` refusal then names the route that works here: a
110+
* client that supports confirmation (step 3). Never set on a door that
111+
* cannot ask any client, where that sentence would be false.
112+
*/
113+
elicitsCapableClients?: true;
114+
}
115+
98116
/**
99117
* The result shape this door reads: `action` and nothing else. Loose on
100118
* purpose, unlike the SDK's own `ElicitResultSchema`, which also parses
@@ -212,3 +230,31 @@ export function actionConfirmationElicitorFor(
212230
}
213231
};
214232
}
233+
234+
/**
235+
* [#34325] What the action tools hand the bridge for the tool call `extra`
236+
* belongs to:
237+
*
238+
* - the client can be elicited: `door`, its elicitor (step 1);
239+
* - this server read the client's `initialize` and can carry a request to it,
240+
* but the client advertised no form-mode `elicitation`: `facts`
241+
* (`elicitsCapableClients`), so a `no_confirmation_service` refusal tells the
242+
* caller that a client supporting confirmation is asked in place here. That
243+
* is the long-lived stdio server today;
244+
* - this server never read the client's `initialize`: neither, and the bridge
245+
* is called as before. That is the per-request Streamable HTTP server,
246+
* which asks no client, so the refusal names only the in-app route there.
247+
*
248+
* Judged on what the server can do, never on a transport name: a door that
249+
* comes to read `initialize` gets the step-3 sentence with the elicitation
250+
* that makes it true.
251+
*/
252+
export function actionCallDoorFor(
253+
server: McpServer,
254+
extra: RequestHandlerExtra<ServerRequest, ServerNotification> | undefined,
255+
): { door?: McpActionCallDoor; facts?: McpActionCallDoorFacts } {
256+
const elicitConfirmation = actionConfirmationElicitorFor(server, extra);
257+
if (elicitConfirmation) return { door: { elicitConfirmation } };
258+
const readInitialize = server.server.getClientCapabilities() !== undefined;
259+
return readInitialize && typeof extra?.sendRequest === 'function' ? { facts: { elicitsCapableClients: true } } : {};
260+
}

‎packages/mcp/src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export {
7979
} from './action-confirmation-elicitation.js';
8080
export type {
8181
McpActionCallDoor,
82+
McpActionCallDoorFacts,
8283
McpActionConfirmationAnswer,
8384
McpActionConfirmationElicitor,
8485
McpActionConfirmationSubject,

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

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
actionConfirmationElicitorFor,
4444
actionConfirmationQuestion,
4545
type McpActionCallDoor,
46+
type McpActionCallDoorFacts,
4647
} from './action-confirmation-elicitation.js';
4748

4849
const GATED = 'archive_account';
@@ -272,7 +273,7 @@ async function openStdioClient(server: McpServer, opts: { elicitation: boolean;
272273

273274
/** A bridge double for the stdio door: runs the step-1 half the runtime owns, through whatever `door` the tool handed it. */
274275
function elicitingBridge() {
275-
const calls: Array<{ tool: string; door: McpActionCallDoor | undefined; argCount: number }> = [];
276+
const calls: Array<{ tool: string; door: McpActionCallDoor | undefined; facts?: McpActionCallDoorFacts; argCount: number }> = [];
276277
const confirmWith = async (door: McpActionCallDoor | undefined, name: string) => {
277278
if (!door) return pendingOf(1);
278279
const answer = await door.elicitConfirmation({
@@ -288,12 +289,12 @@ function elicitingBridge() {
288289
const bridge = {
289290
...makeBridge('service'),
290291
calls,
291-
async runAction(name: string, _input: any, door?: McpActionCallDoor) {
292-
calls.push({ tool: 'run_action', door, argCount: arguments.length });
292+
async runAction(name: string, _input: any, door?: McpActionCallDoor, facts?: McpActionCallDoorFacts) {
293+
calls.push({ tool: 'run_action', door, ...(facts !== undefined ? { facts } : {}), argCount: arguments.length });
293294
return confirmWith(door, name);
294295
},
295-
async resumeRun(_runId: string, _input: any, door?: McpActionCallDoor) {
296-
calls.push({ tool: 'resume_run', door, argCount: arguments.length });
296+
async resumeRun(_runId: string, _input: any, door?: McpActionCallDoor, facts?: McpActionCallDoorFacts) {
297+
calls.push({ tool: 'resume_run', door, ...(facts !== undefined ? { facts } : {}), argCount: arguments.length });
297298
return confirmWith(door, GATED);
298299
},
299300
};
@@ -356,11 +357,13 @@ describe('[#33712] stdio: a client that advertises elicitation is asked in place
356357
expect(JSON.parse(declined.result.content[0].text).error.details.reason).toBe('declined');
357358
});
358359

359-
it('a client WITHOUT the capability is never asked: the bridge is called exactly as before and hands off', async () => {
360+
it('a client WITHOUT the capability is never asked: the bridge gets no door and hands off', async () => {
360361
const { result, calls } = await stdioCall({ elicitation: false });
361362
expect(result.isError).toBeFalsy();
362363
expect(JSON.parse(result.content[0].text)).toEqual(pendingOf(1));
363-
expect(calls).toEqual([{ tool: 'run_action', door: undefined, argCount: 2 }]);
364+
// [#34325] No door, as before; the door's facts ride as a fourth,
365+
// additive argument a bridge may ignore.
366+
expect(calls).toEqual([{ tool: 'run_action', door: undefined, facts: { elicitsCapableClients: true }, argCount: 4 }]);
364367
});
365368
});
366369

@@ -527,3 +530,51 @@ describe('[#35778] run_action names the next step on a no_confirmation_service r
527530
);
528531
});
529532
});
533+
534+
/**
535+
* [#34325] Which door asked, as the bridge is told it: the runtime words the
536+
* `no_confirmation_service` refusal from it (pinned in
537+
* `packages/runtime/src/action-confirmation-handoff-33690.test.ts`). The
538+
* long-lived stdio server read the client's `initialize`, so for a client
539+
* without `elicitation` it says it would have asked a client that supports
540+
* confirmation (`facts.elicitsCapableClients`, the fourth argument; the door
541+
* argument stays as on main), on both tools. The per-request
542+
* Streamable HTTP server asks no client and says nothing: the bridge is
543+
* called exactly as before, even for a client that advertised the capability
544+
* at `initialize`, so the refusal keeps the in-app route alone there.
545+
*/
546+
describe('[#34325] the door facts the action tools hand the bridge name whether a client that supports confirmation is asked here', () => {
547+
for (const tool of ['run_action', 'resume_run'] as const) {
548+
it(`stdio, a client without elicitation: ${tool} hands the bridge no door and the facts { elicitsCapableClients: true }`, async () => {
549+
const { calls, asked } = await stdioCall({ elicitation: false }, tool);
550+
expect(asked).toEqual([]);
551+
expect(calls).toHaveLength(1);
552+
expect(calls[0].argCount).toBe(4);
553+
expect(calls[0].door).toBeUndefined();
554+
expect(calls[0].facts).toStrictEqual({ elicitsCapableClients: true });
555+
});
556+
557+
it(`CONTROL stdio, a client with elicitation: ${tool} hands the bridge main's door (the elicitor alone) and no facts`, async () => {
558+
const { calls } = await stdioCall({ elicitation: true, answer: { action: 'accept' } }, tool);
559+
expect(Object.keys(calls[0].door ?? {})).toEqual(['elicitConfirmation']);
560+
expect(calls[0].argCount).toBe(3);
561+
expect(calls[0]).not.toHaveProperty('facts');
562+
});
563+
564+
it(`Streamable HTTP, after an initialize that advertised elicitation: ${tool} calls the bridge with no door at all`, async () => {
565+
const runtime = new MCPServerRuntime({ name: 'objectstack-test', version: '9.9.9' });
566+
const bridge = elicitingBridge();
567+
const init = {
568+
jsonrpc: '2.0', id: 0, method: 'initialize',
569+
params: { protocolVersion: '2025-11-25', capabilities: { elicitation: {} }, clientInfo: { name: 'c', version: '1' } },
570+
};
571+
expect((await runtime.handleHttpRequest(mcpRequest(init), { bridge, parsedBody: init })).status).toBe(200);
572+
const args = tool === 'run_action' ? { actionName: GATED, recordId: 'a1' } : { runId: 'run_1', values: { reason: 'x' } };
573+
const body = toolsCall(1, tool, args);
574+
const req = mcpRequest(body);
575+
req.headers.set('mcp-protocol-version', '2025-11-25');
576+
await runtime.handleHttpRequest(req, { bridge, parsedBody: body });
577+
expect(bridge.calls).toStrictEqual([{ tool, door: undefined, argCount: 2 }]);
578+
});
579+
}
580+
});

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ import {
137137
} from './metadata-completeness.js';
138138
// [#30892] The file seam and what `read_file` renders from it.
139139
import { READ_FILE_MAX_BYTES, ReadFileExtractionBusyError, renderReadFile, type McpFileBridge } from './file-content.js';
140-
import { actionConfirmationElicitorFor, type McpActionCallDoor } from './action-confirmation-elicitation.js';
140+
import { actionCallDoorFor, type McpActionCallDoor, type McpActionCallDoorFacts } from './action-confirmation-elicitation.js';
141141
import type { McpLatestPer } from './types.js';
142142
// [#35145] `expand` and `related`: the relation reads, judged before any read.
143143
import {
@@ -684,6 +684,10 @@ export interface McpActionBridge {
684684
* the person through `door.elicitConfirmation` first, once every admission
685685
* gate has passed: `accept` runs the call, any other answer refuses it, and
686686
* nothing is handed off. Without `door` the call is handed off as above.
687+
* [#34325] `facts.elicitsCapableClients`, passed only without `door`, says
688+
* this door would have asked a client that advertised `elicitation`: the
689+
* `no_confirmation_service` refusal then names that route too. A bridge
690+
* that does not read `facts` answers exactly as before.
687691
*/
688692
runAction(
689693
name: string,
@@ -699,6 +703,7 @@ export interface McpActionBridge {
699703
params?: Record<string, unknown>;
700704
} & AIActionConfirmation,
701705
door?: McpActionCallDoor,
706+
facts?: McpActionCallDoorFacts,
702707
): Promise<unknown>;
703708
/**
704709
* [#30771] The capability refusal `runAction` would throw for an action on
@@ -727,7 +732,8 @@ export interface McpActionBridge {
727732
* gated action resolves to `ActionConfirmationPending` instead, as
728733
* {@link runAction} does, and the run stays parked. [#33712] `door` as on
729734
* {@link runAction}: an elicited `accept` resumes the run, any other
730-
* answer refuses it and the run stays parked.
735+
* answer refuses it and the run stays parked. [#34325] `facts` as on
736+
* {@link runAction}.
731737
*
732738
* OPTIONAL, like {@link McpDataBridge.aggregate}. A host that cannot resume
733739
* runs omits it, and `resume_run` is then not registered.
@@ -736,6 +742,7 @@ export interface McpActionBridge {
736742
runId: string,
737743
input: { values?: Record<string, unknown> } & AIActionConfirmation,
738744
door?: McpActionCallDoor,
745+
facts?: McpActionCallDoorFacts,
739746
): Promise<unknown>;
740747
}
741748

@@ -5097,12 +5104,17 @@ export function registerActionTools(
50975104
};
50985105
// [#33712] Step 1 of the amended confirmation contract: a client that
50995106
// advertised `elicitation` on a server that read its `initialize` (the
5100-
// stdio door) is asked in place. Otherwise the bridge is called
5101-
// exactly as before and hands a gated call off.
5102-
const elicitConfirmation = actionConfirmationElicitorFor(server, extra);
5103-
const result = elicitConfirmation
5104-
? await bridge.runAction(actionName, request, { elicitConfirmation })
5105-
: await bridge.runAction(actionName, request);
5107+
// stdio door) is asked in place. Otherwise the bridge hands a gated
5108+
// call off. [#34325] On that door a client without the capability is
5109+
// named to the bridge (`facts.elicitsCapableClients`), so a no-service
5110+
// refusal names the client route; the per-request HTTP server calls
5111+
// the bridge exactly as before.
5112+
const { door, facts } = actionCallDoorFor(server, extra);
5113+
const result = door
5114+
? await bridge.runAction(actionName, request, door)
5115+
: facts
5116+
? await bridge.runAction(actionName, request, undefined, facts)
5117+
: await bridge.runAction(actionName, request);
51065118
return textResult(result);
51075119
} catch (err) {
51085120
return landedWriteResultOrError(
@@ -5188,10 +5200,13 @@ export function registerActionTools(
51885200
// at the closed input, as on `run_action`.
51895201
const request = { values };
51905202
// [#33712] As `run_action`: asked in place where the client can be.
5191-
const elicitConfirmation = actionConfirmationElicitorFor(server, extra);
5192-
const result = elicitConfirmation
5193-
? await resumeRun(runId, request, { elicitConfirmation })
5194-
: await resumeRun(runId, request);
5203+
// [#34325] And the same door facts for a no-service refusal.
5204+
const { door, facts } = actionCallDoorFor(server, extra);
5205+
const result = door
5206+
? await resumeRun(runId, request, door)
5207+
: facts
5208+
? await resumeRun(runId, request, undefined, facts)
5209+
: await resumeRun(runId, request);
51955210
return textResult(result);
51965211
} catch (err) {
51975212
return errorResultFromThrown(err, `resume_run ${runId}`);

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,71 @@ describe('[#34515] a resume approval is bound to the screen it was given on', ()
861861
expect(h.runs.get(runId)?.status).toBe('completed');
862862
});
863863
});
864+
865+
/**
866+
* [#34325] The `no_confirmation_service` refusal names the route that works on
867+
* the door that asked. Every door: a person performs it in the app, and the
868+
* caller makes no such change through another tool (an agent that read only
869+
* "in the app" completed the change with a raw record update). The stdio door
870+
* for a client without `elicitation` (no door, and the fourth argument
871+
* `facts.elicitsCapableClients`, set by `@objectstack/mcp`'s
872+
* `actionCallDoorFor`) also names a client that supports confirmation
873+
* (step 3); the Streamable HTTP door, which asks no client and passes
874+
* neither, does not, since that sentence would be false there. The
875+
* envelope is unchanged: same code, status and details on both doors.
876+
*/
877+
describe('[#34325] the no_confirmation_service refusal names the route that works on the door that asked', () => {
878+
const IN_APP = 'a person performs it in the app: do not make the same change with another tool.';
879+
const CLIENT = 'A client that supports confirmation (MCP elicitation) is asked in place on this server';
880+
const STDIO_NO_ELICITATION = { elicitsCapableClients: true } as const;
881+
882+
async function pausedRun(h: ReturnType<typeof makeHarness>): Promise<string> {
883+
const started: any = await h.automation.execute(GATED_FLOW.target, { userId: 'u1', object: OBJECT, record: { id: 'lead_1' } });
884+
return started.runId;
885+
}
886+
887+
/** Each tool's no-service refusal through the real bridge, with the facts the tool would pass after an undefined door (or neither). */
888+
async function refusedAt(tool: 'run_action' | 'resume_run', facts: Record<string, unknown> | undefined) {
889+
const h = makeHarness();
890+
const bridge = h.bridgeAs(PERSON);
891+
const args: unknown[] = tool === 'run_action'
892+
? [GATED.name, { recordId: 'lead_1' }]
893+
: [await pausedRun(h), { values: { reason: 'x' } }];
894+
if (facts) args.push(undefined, facts);
895+
const refused = await refusalOf(tool === 'run_action' ? bridge.runAction(...args) : bridge.resumeRun(...args));
896+
expect({ code: refused.code, status: refused.status }, tool).toEqual({ code: 'ACTION_CONFIRMATION_REQUIRED', status: 428 });
897+
expect(refused.details?.reason, tool).toBe('no_confirmation_service');
898+
expect(h.ql.executeAction).not.toHaveBeenCalled();
899+
expect(h.automation.resume).not.toHaveBeenCalled();
900+
return refused;
901+
}
902+
903+
for (const tool of ['run_action', 'resume_run'] as const) {
904+
it(`stdio, a client without elicitation (${tool}): names a client that supports confirmation, then the app, and no other tool`, async () => {
905+
const refused = await refusedAt(tool, STDIO_NO_ELICITATION);
906+
expect(refused.message).toContain(`${CLIENT}: use one to confirm it here. Otherwise ${IN_APP}`);
907+
});
908+
909+
it(`Streamable HTTP, no door (${tool}): the app and no other tool, never the client sentence`, async () => {
910+
const refused = await refusedAt(tool, undefined);
911+
expect(refused.message).toContain(`does not count. A${IN_APP.slice(1)}`);
912+
expect(refused.message).not.toContain('supports confirmation');
913+
expect(refused.message).not.toContain('elicitation');
914+
});
915+
916+
it(`no new response field (${tool}): both doors answer the same details`, async () => {
917+
const stdio = await refusedAt(tool, STDIO_NO_ELICITATION);
918+
const http = await refusedAt(tool, undefined);
919+
expect(stdio.details).toEqual(http.details);
920+
});
921+
}
922+
923+
it('CONTROL: the door fact is never handed to the host\'s service (the hand-off is the contract\'s shape)', async () => {
924+
const service = makeConfirmationService();
925+
const h = makeHarness({ service });
926+
await h.bridgeAs(PERSON).runAction(GATED.name, { recordId: 'lead_1' }, undefined, STDIO_NO_ELICITATION);
927+
expect((service.submit.mock.calls[0] as any[])[0]).toEqual({
928+
actionName: GATED.name, objectName: OBJECT, recordId: 'lead_1', params: {}, door: 'mcp',
929+
});
930+
});
931+
});

‎packages/runtime/src/action-dispatch.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ export interface ResolvedActionCall {
172172
* answer refuses it, and nothing is handed off.
173173
*/
174174
elicitConfirmation?: actionExec.ActionConfirmationElicitor;
175+
/**
176+
* [#34325] The door would ask a client that supports confirmation,
177+
* and this call's client does not (`actionExec.ActionConfirmationDoor`):
178+
* a `no_confirmation_service` refusal names that route too.
179+
*/
180+
elicitsCapableClients?: boolean;
175181
};
176182
/**
177183
* [ADR-0106 D1] This door's answer for a name nothing declares, where it
@@ -425,7 +431,7 @@ async function confirmAdmittedAction(
425431
...(subjectRecordId !== undefined ? { recordId: subjectRecordId } : {}),
426432
params,
427433
door: handOff.door,
428-
}, wiring.ec);
434+
}, wiring.ec, { elicitsCapableClients: handOff.elicitsCapableClients === true });
429435
if ('refused' in answer) {
430436
const { refused } = answer;
431437
return {

0 commit comments

Comments
 (0)