Skip to content
TypeScript

fix(server): show Claude MCP elicitations on the approval card (#21903)

Christopher Gómezff55c19baa7d
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
index 40f33b3a1a3..f6c5926bf81 100644
--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
@@ -8,6 +8,7 @@ import * as ClaudeSdk from "@anthropic-ai/claude-agent-sdk";
import { beforeEach, vi } from "vite-plus/test";
import type {
+ ElicitationRequest,
Query as ClaudeQuery,
SDKMessage,
SDKResultMessage,
@@ -1187,6 +1188,82 @@ describe("ClaudeAdapterV2 approval cancellation", () => {
);
});
+describe("ClaudeAdapterV2 MCP elicitation acceptance", () => {
+ const form = (
+ properties: Record<string, unknown>,
+ required?: ReadonlyArray<string>,
+ ): ElicitationRequest => ({
+ serverName: "deploys",
+ message: "Deploy web?",
+ mode: "form",
+ requestedSchema: { type: "object", properties, ...(required ? { required } : {}) },
+ });
+
+ it("answers an empty-properties form with empty content", () => {
+ assert.deepEqual(ClaudeAdapterV2.claudeMcpElicitationAcceptance(form({})), {
+ action: "accept",
+ content: {},
+ });
+ });
+
+ it("picks the one-time choice however the server spells it", () => {
+ for (const choice of [
+ "allow_once",
+ "Allow",
+ "accept_once",
+ "Approve once",
+ "allow_this_time",
+ "allow_once_only",
+ ]) {
+ assert.deepEqual(
+ ClaudeAdapterV2.claudeMcpElicitationAcceptance(
+ form({ decision: { type: "string", enum: ["disallow", choice, "always"] } }, [
+ "decision",
+ ]),
+ ),
+ { action: "accept", content: { decision: choice } },
+ );
+ }
+ });
+
+ it("answers a persistence toggle with false", () => {
+ assert.deepEqual(
+ ClaudeAdapterV2.claudeMcpElicitationAcceptance(
+ form({ remember: { type: "boolean", title: "Always allow" } }, ["remember"]),
+ ),
+ { action: "accept", content: { remember: false } },
+ );
+ });
+
+ it("leaves out optional fields the card does not show", () => {
+ assert.deepEqual(
+ ClaudeAdapterV2.claudeMcpElicitationAcceptance(
+ form({ scope: { type: "string", enum: ["once", "always"], default: "always" } }),
+ ),
+ { action: "accept", content: { scope: "once" } },
+ );
+ assert.deepEqual(
+ ClaudeAdapterV2.claudeMcpElicitationAcceptance(
+ form({ limit: { type: "number", default: 500 } }),
+ ),
+ { action: "accept", content: {} },
+ );
+ });
+
+ it("has no answer for URL mode or a form asking for a value", () => {
+ for (const request of [
+ { serverName: "deploys", message: "Sign in", mode: "url", url: "https://example.com" },
+ form({ reason: { type: "string" } }, ["reason"]),
+ form({ grant: { type: "string", enum: ["always", "session"] } }, ["grant"]),
+ form({ grant: { type: "string", enum: ["deny", "always"], default: "always" } }, ["grant"]),
+ form({ limit: { type: "number", default: 500 } }, ["limit"]),
+ { serverName: "deploys", message: "Deploy web?", mode: "form" },
+ ] satisfies ReadonlyArray<ElicitationRequest>) {
+ assert.isUndefined(ClaudeAdapterV2.claudeMcpElicitationAcceptance(request));
+ }
+ });
+});
+
const captureSdkExecutablePaths = Effect.fn("captureSdkExecutablePaths")(function* (
binaryPath: string,
environment: ResolvedProviderInstanceEnvironment = [],
@@ -4403,6 +4480,196 @@ describe("ClaudeAdapterV2 background wake turns", () => {
),
);
+ describe("MCP elicitations", () => {
+ const testLayer = Layer.mergeAll(
+ IdAllocator.layer,
+ McpProviderSessions.layer,
+ NodeServices.layer,
+ );
+ const approvalOnly: ElicitationRequest = {
+ serverName: "deploys",
+ message: "Deploy web to production?",
+ mode: "form",
+ requestedSchema: { type: "object", properties: {} },
+ title: "Deploy",
+ };
+
+ const startElicitationTurn = Effect.fnUntraced(function* (
+ options?: Parameters<typeof makeWakeHarnessWithOptions>[0],
+ ) {
+ const harness = yield* makeWakeHarnessWithOptions(options);
+ yield* harness.runtime.startTurn(
+ makeClaudeTestTurnInput({
+ threadId: harness.threadId,
+ providerThread: harness.providerThread,
+ now: yield* DateTime.now,
+ attemptId: RunAttemptId.make("attempt-claude-elicitation"),
+ text: "Deploy web.",
+ attachments: [],
+ }),
+ );
+ const onElicitation = harness.getOpenedOptions()?.onElicitation;
+ if (onElicitation === undefined) throw new Error("The Claude query has no onElicitation.");
+ const runtimeRequests = () =>
+ harness.events.flatMap((event) =>
+ event.type === "runtime_request.updated" ? [event.runtimeRequest] : [],
+ );
+ let requestNumber = 0;
+ const elicit = (request: ElicitationRequest, signal = new AbortController().signal) =>
+ Effect.promise(() =>
+ onElicitation(request, { signal, requestId: `sdk-${requestNumber++}` }),
+ ).pipe(Effect.forkScoped);
+ const awaitCard = Effect.fnUntraced(function* (count: number) {
+ const event = yield* Queue.take(harness.runtimeRequestReceipts);
+ assert.equal(runtimeRequests().length, count);
+ return event.runtimeRequest;
+ });
+ return { harness, elicit, awaitCard, runtimeRequests };
+ });
+
+ it.effect("shows an approval-only form and accepts only after Approve", () =>
+ Effect.gen(function* () {
+ const { harness, elicit, awaitCard } = yield* startElicitationTurn();
+ const answer = yield* elicit(approvalOnly);
+ const request = yield* awaitCard(1);
+ assert.equal(request.kind, "mcp-elicitation");
+ assert.isTrue(request.responseCapability.type === "live");
+ if (request.responseCapability.type === "live") {
+ assert.isUndefined(request.responseCapability.supportsFeedback);
+ }
+ const card = harness.events.findLast(
+ (event) =>
+ event.type === "turn_item.updated" && event.turnItem.type === "approval_request",
+ );
+ assert.deepInclude(card?.type === "turn_item.updated" ? card.turnItem : undefined, {
+ prompt: "Deploy web to production?",
+ appName: "Deploy",
+ options: [
+ { decision: "cancel", label: "Cancel" },
+ { decision: "decline", label: "Decline" },
+ { decision: "accept", label: "Approve" },
+ ],
+ });
+ assert.isUndefined(answer.pollUnsafe());
+
+ yield* harness.runtime.respondToRuntimeRequest({
+ requestId: request.id,
+ decision: "accept",
+ });
+ assert.deepEqual(yield* Fiber.join(answer), { action: "accept", content: {} });
+
+ // The card is gone, so a second click is an unknown request.
+ const late = yield* Effect.flip(
+ harness.runtime.respondToRuntimeRequest({ requestId: request.id, decision: "decline" }),
+ );
+ assert.include(String(late.cause), "No pending Claude runtime request");
+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
+ );
+
+ it.effect.each(["decline", "cancel"] as const)("answers %s with that action", (decision) =>
+ Effect.gen(function* () {
+ const { harness, elicit, awaitCard } = yield* startElicitationTurn();
+ const answer = yield* elicit(approvalOnly);
+ const request = yield* awaitCard(1);
+ yield* harness.runtime.respondToRuntimeRequest({ requestId: request.id, decision });
+ assert.deepEqual(yield* Fiber.join(answer), { action: decision });
+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
+ );
+
+ it.effect.each(["acceptForSession", "acceptAlways"] as const)(
+ "declines an unsupported %s decision",
+ (decision) =>
+ Effect.gen(function* () {
+ const { harness, elicit, awaitCard } = yield* startElicitationTurn();
+ const answer = yield* elicit(approvalOnly);
+ const request = yield* awaitCard(1);
+ yield* harness.runtime.respondToRuntimeRequest({ requestId: request.id, decision });
+ assert.deepEqual(yield* Fiber.join(answer), { action: "decline" });
+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
+ );
+
+ it.effect("declines URL and value forms without a card", () =>
+ Effect.gen(function* () {
+ const { elicit, runtimeRequests } = yield* startElicitationTurn();
+ for (const request of [
+ { ...approvalOnly, mode: "url", url: "https://example.com/auth" },
+ {
+ ...approvalOnly,
+ requestedSchema: {
+ type: "object",
+ properties: { reason: { type: "string" } },
+ required: ["reason"],
+ },
+ },
+ ] satisfies ReadonlyArray<ElicitationRequest>) {
+ assert.deepEqual(yield* Fiber.join(yield* elicit(request)), { action: "decline" });
+ }
+ assert.isEmpty(runtimeRequests());
+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
+ );
+
+ it.effect("cancels an already-aborted request without a card", () =>
+ Effect.gen(function* () {
+ const { harness, elicit, awaitCard, runtimeRequests } = yield* startElicitationTurn();
+ const aborted = yield* Effect.sync(() => {
+ const controller = new AbortController();
+ controller.abort();
+ return controller.signal;
+ });
+ const answer = yield* elicit(approvalOnly, aborted);
+ assert.deepEqual(yield* Fiber.join(answer), { action: "cancel" });
+ assert.isEmpty(runtimeRequests());
+ const next = yield* elicit(approvalOnly);
+ const card = yield* awaitCard(1);
+ assert.equal(card.nativeRequestRef?.nativeId, "mcp-elicitation:sdk-1");
+ yield* harness.runtime.respondToRuntimeRequest({ requestId: card.id, decision: "accept" });
+ assert.deepEqual(yield* Fiber.join(next), { action: "accept", content: {} });
+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
+ );
+
+ it.effect("withdraws an open card when the SDK cancels while the session continues", () =>
+ Effect.gen(function* () {
+ const { harness, elicit, awaitCard } = yield* startElicitationTurn();
+ const controller = yield* Effect.sync(() => new AbortController());
+ const answer = yield* elicit(approvalOnly, controller.signal);
+ const request = yield* awaitCard(1);
+ yield* Effect.sync(() => controller.abort());
+ assert.deepEqual(yield* Fiber.join(answer), { action: "cancel" });
+ const cancelled = yield* Queue.take(harness.runtimeRequestReceipts);
+ assert.equal(cancelled.runtimeRequest.id, request.id);
+ assert.equal(cancelled.runtimeRequest.status, "cancelled");
+ assert.equal(
+ harness.events.findLast((e) => e.type === "node.updated")?.node.status,
+ "cancelled",
+ );
+ assert.equal(
+ harness.events.findLast((e) => e.type === "turn_item.updated")?.turnItem.status,
+ "cancelled",
+ );
+ yield* Effect.flip(
+ harness.runtime.respondToRuntimeRequest({ requestId: request.id, decision: "accept" }),
+ );
+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
+ );
+
+ it.effect("cancels an open card when the session stops", () =>
+ Effect.gen(function* () {
+ // Like the SDK, the fake query aborts in-flight callbacks when closed.
+ const inFlight = yield* Effect.sync(() => new AbortController());
+ const session = yield* Scope.make();
+ const { elicit, awaitCard } = yield* startElicitationTurn({
+ close: () => Effect.sync(() => inFlight.abort()),
+ }).pipe(Scope.provide(session));
+ const answer = yield* elicit(approvalOnly, inFlight.signal);
+ yield* awaitCard(1);
+ assert.isUndefined(answer.pollUnsafe());
+
+ yield* Scope.close(session, Exit.void);
+ assert.deepEqual(yield* Fiber.join(answer), { action: "cancel" });
+ }).pipe(Effect.scoped, Effect.provide(testLayer)),
+ );
+ });
+
it.effect(
"applies model, effort and Fast changes to a process running a background shell, but not thinking or a cleared effort",
() =>
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
index f42f37d1ab1..65d48b01dde 100644
--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
@@ -22,8 +22,11 @@ import {
import { isWorkspaceImagePreviewPath } from "@t3tools/shared/filePreview";
import { normalizeClaudeTurnTokenUsage } from "../../provider/ClaudeTurnTokenUsage.ts";
+import { toMcpElicitationResponse } from "../../provider/CodexMcpElicitation.ts";
import {
type CanUseTool,
+ type ElicitationRequest,
+ type ElicitationResult,
forkSession as forkClaudeSession,
type EffortLevel,
type ForkSessionOptions,
@@ -1470,6 +1473,7 @@ export function makeClaudeQueryOptions(input: {
readonly permissionMode?: PermissionMode;
readonly canUseTool?: CanUseTool;
readonly onUserDialog?: ClaudeQueryOptions["onUserDialog"];
+ readonly onElicitation?: ClaudeQueryOptions["onElicitation"];
readonly supportedDialogKinds?: ClaudeQueryOptions["supportedDialogKinds"];
readonly allowDangerouslySkipPermissions?: boolean;
readonly appendSystemPromptFileText?: string;
@@ -1568,6 +1572,7 @@ export function makeClaudeQueryOptions(input: {
? {}
: { settings: effectiveQuerySettings }),
...(input.onUserDialog === undefined ? {} : { onUserDialog: input.onUserDialog }),
+ ...(input.onElicitation === undefined ? {} : { onElicitation: input.onElicitation }),
...(input.supportedDialogKinds === undefined
? {}
: { supportedDialogKinds: input.supportedDialogKinds }),
@@ -3443,6 +3448,69 @@ export const awaitClaudeApprovalDecision = Effect.fn("awaitClaudeApprovalDecisio
return yield* Effect.raceFirst(Deferred.await(decision), cancellation);
});
+// Web and mobile offer a session grant when options are omitted, and this
+// path only ever answers once.
+const CLAUDE_MCP_ELICITATION_OPTIONS: ReadonlyArray<ProviderApprovalOption> = [
+ { decision: "cancel", label: "Cancel" },
+ { decision: "decline", label: "Decline" },
+ { decision: "accept", label: "Approve" },
+];
+
+type ClaudeMcpElicitationContent = NonNullable<ElicitationResult["content"]>;
+
+const isClaudeMcpElicitationValue = (
+ value: unknown,
+): value is ClaudeMcpElicitationContent[string] =>
+ typeof value === "string" ||
+ typeof value === "number" ||
+ typeof value === "boolean" ||
+ (Array.isArray(value) && value.every((item) => typeof item === "string"));
+
+const withoutSchemaDefaults = (schema: Record<string, unknown>): Record<string, unknown> => {
+ const properties = schema.properties;
+ if (typeof properties !== "object" || properties === null || Array.isArray(properties)) {
+ return schema;
+ }
+ return {
+ ...schema,
+ properties: Object.fromEntries(
+ Object.entries(properties).map(([key, field]) => [
+ key,
+ typeof field === "object" && field !== null
+ ? Object.fromEntries(Object.entries(field).filter(([name]) => name !== "default"))
+ : field,
+ ]),
+ ),
+ };
+};
+
+// The card collects consent only; schema defaults must never grant unseen permissions.
+export function claudeMcpElicitationAcceptance(
+ request: ElicitationRequest,
+): ElicitationResult | undefined {
+ if (request.mode === "url" || request.requestedSchema === undefined) return undefined;
+ const response = toMcpElicitationResponse(
+ { mode: "form", requestedSchema: withoutSchemaDefaults(request.requestedSchema) },
+ "accept",
+ );
+ // The helper leaves content out when the schema is not a form it can read.
+ const filled = response.content;
+ if (
+ response.action !== "accept" ||
+ typeof filled !== "object" ||
+ filled === null ||
+ Array.isArray(filled)
+ ) {
+ return undefined;
+ }
+ const content: ClaudeMcpElicitationContent = {};
+ for (const [key, value] of Object.entries(filled)) {
+ if (!isClaudeMcpElicitationValue(value)) return undefined;
+ content[key] = value;
+ }
+ return { action: "accept", content };
+}
+
const awaitClaudeUserInputAnswers = Effect.fn("awaitClaudeUserInputAnswers")(function* (
answers: Deferred.Deferred<ProviderUserInputAnswers>,
signal: AbortSignal,
@@ -7015,7 +7083,10 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
readonly nativeRequestId: string;
readonly requestKind: OrchestrationV2RuntimeRequest["kind"];
readonly prompt?: string;
+ readonly appName?: string;
+ readonly options?: ReadonlyArray<ProviderApprovalOption>;
readonly presentation?: ReturnType<typeof claudeApprovalPresentation>;
+
readonly questions?: ReadonlyArray<OrchestrationV2UserInputQuestion>;
}) {
const createdAt = yield* DateTime.now;
@@ -7075,7 +7146,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
responseCapability: {
type: "live",
providerSessionId,
- ...(input.questions === undefined ? { supportsFeedback: true } : {}),
+ ...(input.questions === undefined && input.requestKind !== "mcp-elicitation"
+ ? { supportsFeedback: true }
+ : {}),
},
createdAt,
resolvedAt: null,
@@ -7101,6 +7174,8 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
requestId,
requestKind: input.requestKind as ProviderRequestKind,
...(input.prompt === undefined ? {} : { prompt: input.prompt }),
+ ...(input.appName === undefined ? {} : { appName: input.appName }),
+ ...(input.options === undefined ? {} : { options: input.options }),
...input.presentation,
}
: {
@@ -9715,6 +9790,125 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
const canUseTool: CanUseTool = (toolName, toolInput, callbackOptions) =>
runPromise(canUseToolEffect(toolName, toolInput, callbackOptions));
+ const onElicitationEffect = Effect.fn("ClaudeAdapterV2.onElicitation")(function* (
+ request: ElicitationRequest,
+ callbackOptions: Parameters<NonNullable<ClaudeQueryOptions["onElicitation"]>>[1],
+ ) {
+ if (callbackOptions.signal.aborted)
+ return { action: "cancel" } satisfies ElicitationResult;
+ const acceptance = claudeMcpElicitationAcceptance(request);
+ const context = yield* Ref.get(activeTurn);
+ if (acceptance === undefined || context === null) {
+ yield* Effect.logWarning(
+ "Declined an MCP elicitation the approval card cannot answer.",
+ {
+ serverName: request.serverName,
+ mode: request.mode,
+ activeTurn: context !== null,
+ },
+ );
+ return { action: "decline" } satisfies ElicitationResult;
+ }
+ // The CLI waits on this answer, so a turn held for its prompt echo
+ // must show its output now, as canUseTool does.
+ if (context.heldRootFrames.length > 0) {
+ yield* releaseHeldRootFrames(context);
+ }
+
+ // The SDK's requestId names this control request; T3 allocates its own
+ // runtime request id from it.
+ const nativeRequestId = `mcp-elicitation:${callbackOptions.requestId}`;
+ const artifacts = yield* buildApprovalRequestArtifacts({
+ context,
+ nativeItemId: nativeRequestId,
+ nativeRequestId,
+ requestKind: "mcp-elicitation",
+ prompt: request.message,
+ appName: request.displayName ?? request.title ?? request.serverName,
+ options: CLAUDE_MCP_ELICITATION_OPTIONS,
+ });
+ const decision = yield* Deferred.make<ClaudeApprovalResponse>();
+ yield* Ref.update(pendingRuntimeRequests, (current) => {
+ const updated = new Map(current);
+ updated.set(String(artifacts.request.id), {
+ type: "approval",
+ requestKind: "mcp-elicitation",
+ decision,
+ });
+ return updated;
+ });
+ yield* Effect.all(
+ [
+ emitProviderEvent({
+ type: "node.updated",
+ driver: CLAUDE_PROVIDER,
+ node: artifacts.node,
+ }),
+ emitProviderEvent({
+ type: "runtime_request.updated",
+ driver: CLAUDE_PROVIDER,
+ runtimeRequest: artifacts.request,
+ }),
+ emitProviderEvent({
+ type: "turn_item.updated",
+ driver: CLAUDE_PROVIDER,
+ turnItem: artifacts.turnItem,
+ }),
+ ],
+ { concurrency: 1 },
+ );
+
+ // Closing the query aborts the signal, so a stopped session settles
+ // this as cancel and a late response finds no pending request.
+ const { decision: resolved } = yield* awaitClaudeApprovalDecision(
+ decision,
+ callbackOptions.signal,
+ ).pipe(
+ Effect.ensuring(
+ Ref.update(pendingRuntimeRequests, (current) => {
+ const updated = new Map(current);
+ updated.delete(String(artifacts.request.id));
+ return updated;
+ }),
+ ),
+ );
+ if (resolved === "cancel" && callbackOptions.signal.aborted) {
+ const now = yield* DateTime.now;
+ yield* emitProviderEvent({
+ type: "node.updated",
+ driver: CLAUDE_PROVIDER,
+ node: { ...artifacts.node, status: "cancelled", completedAt: now },
+ });
+ yield* emitProviderEvent({
+ type: "turn_item.updated",
+ driver: CLAUDE_PROVIDER,
+ turnItem: {
+ ...artifacts.turnItem,
+ status: "cancelled",
+ completedAt: now,
+ updatedAt: now,
+ },
+ });
+ yield* emitProviderEvent({
+ type: "runtime_request.updated",
+ driver: CLAUDE_PROVIDER,
+ runtimeRequest: { ...artifacts.request, status: "cancelled", resolvedAt: now },
+ });
+ }
+ // Never null: the SDK reads null as answered out of band and leaves
+ // the server waiting. Every accept is one-time; no grant is offered.
+ return resolved === "accept"
+ ? acceptance
+ : ({
+ action: resolved === "cancel" ? "cancel" : "decline",
+ } satisfies ElicitationResult);
+ });
+
+ const onElicitation: NonNullable<ClaudeQueryOptions["onElicitation"]> = (
+ request,
+ callbackOptions,
+ ) => runPromise(onElicitationEffect(request, callbackOptions));
+
const onUserDialog: NonNullable<ClaudeQueryOptions["onUserDialog"]> = (
request,
callbackOptions,
@@ -9988,6 +10182,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
}),
canUseTool,
onUserDialog,
+ onElicitation,
supportedDialogKinds: ["resume_return"],
...(appendSystemPromptFileText === undefined ? {} : { appendSystemPromptFileText }),
...(toolSearchOverride === undefined ? {} : { toolSearchOverride }),
diff --git a/apps/server/src/provider/CodexMcpElicitation.ts b/apps/server/src/provider/CodexMcpElicitation.ts
index 7703b02f03b..eafe09e07e7 100644
--- a/apps/server/src/provider/CodexMcpElicitation.ts
+++ b/apps/server/src/provider/CodexMcpElicitation.ts
@@ -76,7 +76,14 @@ function mcpElicitationPersistenceDecision(
return null;
}
-function mcpElicitationFormFields(payload: EffectCodexSchema.McpServerElicitationRequestParams) {
+// Claude hands over the same MCP request with its own envelope; these are the
+// only fields the response is built from.
+type McpElicitationResponseInput = {
+ readonly mode: string;
+ readonly requestedSchema?: unknown;
+};
+
+function mcpElicitationFormFields(payload: McpElicitationResponseInput) {
if (payload.mode === "url" || !isMcpElicitationForm(payload.requestedSchema)) {
return undefined;
}
@@ -171,7 +178,7 @@ export function describeMcpElicitation(
}
export function toMcpElicitationResponse(
- payload: EffectCodexSchema.McpServerElicitationRequestParams,
+ payload: McpElicitationResponseInput,
decision: ProviderApprovalDecision,
): EffectCodexSchema.McpServerElicitationRequestResponse {
if (decision === "decline" || decision === "cancel") {
@@ -196,8 +203,9 @@ export function toMcpElicitationResponse(
const chosenOption = options.find((option) =>
persist
? mcpElicitationPersistenceDecision(option.value) === decision
- : /once|accept|approve|allow/i.test(option.value) &&
- mcpElicitationPersistenceDecision(option.value) === null,
+ : /^(?:once|accept|approve|allow)(?:[_\s-]*(?:once(?:[_\s-]*only)?|this[_\s-]*time))?$/i.test(
+ option.value.trim(),
+ ) && mcpElicitationPersistenceDecision(option.value) === null,
);
if (chosenOption) {
content[key] = chosenOption.value;