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

Function runElicitationHooks

src/services/mcp/elicitationHandler.ts:214–257  ·  view source on GitHub ↗
(
  serverName: string,
  params: ElicitRequestParams,
  signal: AbortSignal,
)

Source from the content-addressed store, hash-verified

212}
213
214export async function runElicitationHooks(
215 serverName: string,
216 params: ElicitRequestParams,
217 signal: AbortSignal,
218): Promise<ElicitResult | undefined> {
219 try {
220 const mode = params.mode === 'url' ? 'url' : 'form'
221 const url = 'url' in params ? (params.url as string) : undefined
222 const elicitationId =
223 'elicitationId' in params
224 ? (params.elicitationId as string | undefined)
225 : undefined
226
227 const { elicitationResponse, blockingError } =
228 await executeElicitationHooks({
229 serverName,
230 message: params.message,
231 requestedSchema:
232 'requestedSchema' in params
233 ? (params.requestedSchema as Record<string, unknown>)
234 : undefined,
235 signal,
236 mode,
237 url,
238 elicitationId,
239 })
240
241 if (blockingError) {
242 return { action: 'decline' }
243 }
244
245 if (elicitationResponse) {
246 return {
247 action: elicitationResponse.action,
248 content: elicitationResponse.content,
249 }
250 }
251
252 return undefined
253 } catch (error) {
254 logMCPError(serverName, `Elicitation hook error: ${error}`)
255 return undefined
256 }
257}
258
259/**
260 * Run ElicitationResult hooks after the user has responded, then fire a

Calls 2

executeElicitationHooksFunction · 0.85
logMCPErrorFunction · 0.85

Tested by

no test coverage detected