MCPcopy
hub / github.com/codeaashu/claude-code / runElicitationResultHooks

Function runElicitationResultHooks

src/services/mcp/elicitationHandler.ts:264–313  ·  view source on GitHub ↗
(
  serverName: string,
  result: ElicitResult,
  signal: AbortSignal,
  mode?: 'form' | 'url',
  elicitationId?: string,
)

Source from the content-addressed store, hash-verified

262 * ElicitResult — hooks may override the action/content or block the response.
263 */
264export async function runElicitationResultHooks(
265 serverName: string,
266 result: ElicitResult,
267 signal: AbortSignal,
268 mode?: 'form' | 'url',
269 elicitationId?: string,
270): Promise<ElicitResult> {
271 try {
272 const { elicitationResultResponse, blockingError } =
273 await executeElicitationResultHooks({
274 serverName,
275 action: result.action,
276 content: result.content as Record<string, unknown> | undefined,
277 signal,
278 mode,
279 elicitationId,
280 })
281
282 if (blockingError) {
283 void executeNotificationHooks({
284 message: `Elicitation response for server "${serverName}": decline`,
285 notificationType: 'elicitation_response',
286 })
287 return { action: 'decline' }
288 }
289
290 const finalResult = elicitationResultResponse
291 ? {
292 action: elicitationResultResponse.action,
293 content: elicitationResultResponse.content ?? result.content,
294 }
295 : result
296
297 // Fire a notification for observability
298 void executeNotificationHooks({
299 message: `Elicitation response for server "${serverName}": ${finalResult.action}`,
300 notificationType: 'elicitation_response',
301 })
302
303 return finalResult
304 } catch (error) {
305 logMCPError(serverName, `ElicitationResult hook error: ${error}`)
306 // Fire notification even on error
307 void executeNotificationHooks({
308 message: `Elicitation response for server "${serverName}": ${result.action}`,
309 notificationType: 'elicitation_response',
310 })
311 return result
312 }
313}
314

Calls 3

executeNotificationHooksFunction · 0.85
logMCPErrorFunction · 0.85

Tested by

no test coverage detected