({
serverName,
action,
content,
permissionMode,
signal,
timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS,
mode,
elicitationId,
}: {
serverName: string
action: 'accept' | 'decline' | 'cancel'
content?: Record<string, unknown>
permissionMode?: string
signal?: AbortSignal
timeoutMs?: number
mode?: 'form' | 'url'
elicitationId?: string
})
| 4523 | } |
| 4524 | |
| 4525 | export async function executeElicitationResultHooks({ |
| 4526 | serverName, |
| 4527 | action, |
| 4528 | content, |
| 4529 | permissionMode, |
| 4530 | signal, |
| 4531 | timeoutMs = TOOL_HOOK_EXECUTION_TIMEOUT_MS, |
| 4532 | mode, |
| 4533 | elicitationId, |
| 4534 | }: { |
| 4535 | serverName: string |
| 4536 | action: 'accept' | 'decline' | 'cancel' |
| 4537 | content?: Record<string, unknown> |
| 4538 | permissionMode?: string |
| 4539 | signal?: AbortSignal |
| 4540 | timeoutMs?: number |
| 4541 | mode?: 'form' | 'url' |
| 4542 | elicitationId?: string |
| 4543 | }): Promise<ElicitationResultHookResult> { |
| 4544 | const hookInput: ElicitationResultHookInput = { |
| 4545 | ...createBaseHookInput(permissionMode), |
| 4546 | hook_event_name: 'ElicitationResult', |
| 4547 | mcp_server_name: serverName, |
| 4548 | elicitation_id: elicitationId, |
| 4549 | mode, |
| 4550 | action, |
| 4551 | content, |
| 4552 | } |
| 4553 | |
| 4554 | const results = await executeHooksOutsideREPL({ |
| 4555 | hookInput, |
| 4556 | matchQuery: serverName, |
| 4557 | signal, |
| 4558 | timeoutMs, |
| 4559 | }) |
| 4560 | |
| 4561 | let elicitationResultResponse: ElicitationResponse | undefined |
| 4562 | let blockingError: HookBlockingError | undefined |
| 4563 | |
| 4564 | for (const result of results) { |
| 4565 | const parsed = parseElicitationHookOutput(result, 'ElicitationResult') |
| 4566 | if (parsed.blockingError) { |
| 4567 | blockingError = parsed.blockingError |
| 4568 | } |
| 4569 | if (parsed.response) { |
| 4570 | elicitationResultResponse = parsed.response |
| 4571 | } |
| 4572 | } |
| 4573 | |
| 4574 | return { elicitationResultResponse, blockingError } |
| 4575 | } |
| 4576 | |
| 4577 | /** |
| 4578 | * Execute status line command if configured |
no test coverage detected