MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / callHandler

Function callHandler

src/test-utils/test-helpers.ts:145–175  ·  view source on GitHub ↗
(
  handler:
    | ToolHandler
    | ((args: Record<string, unknown>, ctx?: ToolHandlerContext) => Promise<void>),
  args: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

143 * returning a ToolResponse-shaped result for backward-compatible assertions.
144 */
145export async function callHandler(
146 handler:
147 | ToolHandler
148 | ((args: Record<string, unknown>, ctx?: ToolHandlerContext) => Promise<void>),
149 args: Record<string, unknown>,
150): Promise<CallHandlerResult> {
151 const session = createRenderSession('text');
152 const ctx: ToolHandlerContext = {
153 emit: (fragment: AnyFragment) => {
154 session.emit(fragment);
155 },
156 attach: (image) => session.attach(image),
157 };
158 await handler(args, ctx);
159 if (ctx.structuredOutput) {
160 session.setStructuredOutput?.(ctx.structuredOutput);
161 }
162 if (ctx.nextSteps && ctx.nextSteps.length > 0) {
163 session.setNextSteps?.([...ctx.nextSteps], 'cli');
164 }
165 const text = renderCliTextTranscript({
166 items: [],
167 structuredOutput: ctx.structuredOutput,
168 nextSteps: ctx.nextSteps,
169 });
170 return {
171 content: text ? [{ type: 'text' as const, text }] : [],
172 isError: session.isError() || undefined,
173 nextStepParams: ctx.nextStepParams,
174 };
175}
176
177function isMockToolHandlerResult(
178 result: ToolResponse | MockToolHandlerResult,

Calls 8

createRenderSessionFunction · 0.90
renderCliTextTranscriptFunction · 0.90
emitMethod · 0.80
attachMethod · 0.65
setStructuredOutputMethod · 0.65
setNextStepsMethod · 0.65
isErrorMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected