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

Function invokeAndFinalize

src/runtime/__tests__/tool-invoker.test.ts:122–145  ·  view source on GitHub ↗
(
  invoker: DefaultToolInvoker,
  toolName: string,
  args: Record<string, unknown>,
  opts: {
    runtime: 'cli' | 'daemon' | 'mcp';
    socketPath?: string;
    workspaceRoot?: string;
    cliExposedWorkflowIds?: string[];
  },
)

Source from the content-addressed store, hash-verified

120}
121
122function invokeAndFinalize(
123 invoker: DefaultToolInvoker,
124 toolName: string,
125 args: Record<string, unknown>,
126 opts: {
127 runtime: 'cli' | 'daemon' | 'mcp';
128 socketPath?: string;
129 workspaceRoot?: string;
130 cliExposedWorkflowIds?: string[];
131 },
132): Promise<ToolResponse & { structuredOutput?: StructuredToolOutput }> {
133 const session = createRenderSession('text');
134 const promise = invoker.invoke(toolName, args, { ...opts, renderSession: session });
135 return promise.then(() => {
136 const text = session.finalize();
137 const response: ToolResponse = {
138 content: text ? [{ type: 'text', text }] : [],
139 isError: session.isError() || undefined,
140 nextSteps: undefined,
141 structuredOutput: session.getStructuredOutput?.(),
142 };
143 return response;
144 });
145}
146
147function emitHandler(text: string): ToolDefinition['handler'] {
148 return vi.fn(async (_params, ctx) => {

Callers 1

Calls 5

createRenderSessionFunction · 0.90
getStructuredOutputMethod · 0.80
invokeMethod · 0.65
finalizeMethod · 0.65
isErrorMethod · 0.65

Tested by

no test coverage detected