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

Function invokeRegisteredTool

src/utils/tool-registry.ts:250–295  ·  view source on GitHub ↗
(
  toolName: string,
  toolModule: ImportedToolModule,
  args: unknown,
)

Source from the content-addressed store, hash-verified

248}
249
250async function invokeRegisteredTool(
251 toolName: string,
252 toolModule: ImportedToolModule,
253 args: unknown,
254): Promise<ToolResponse> {
255 const startedAt = Date.now();
256
257 try {
258 const session = createRenderSession('text', { outputStyle: 'minimal' });
259 const ctx: ToolHandlerContext = {
260 emit: (fragment) => {
261 session.emit(fragment);
262 },
263 attach: session.attach,
264 };
265 await toolModule.handler(args as Record<string, unknown>, ctx);
266
267 if (ctx.structuredOutput) {
268 session.setStructuredOutput?.(ctx.structuredOutput);
269 }
270
271 const catalog = registryState.catalog;
272 const catalogTool = catalog?.getByMcpName(toolName);
273 if (catalog && catalogTool) {
274 postProcessSession({
275 tool: catalogTool,
276 session,
277 ctx,
278 catalog,
279 runtime: 'mcp',
280 });
281 }
282
283 const response = sessionToToolResponse(session);
284 recordMcpInvocation(toolName, startedAt, 'completed');
285 return response;
286 } catch (error) {
287 recordInternalErrorMetric({
288 component: 'mcp-tool-registry',
289 runtime: 'mcp',
290 errorKind: error instanceof Error ? error.name || 'Error' : typeof error,
291 });
292 recordMcpInvocation(toolName, startedAt, 'infra_error');
293 throw error;
294 }
295}
296
297function registerToolFromManifest(
298 toolManifest: ToolManifestEntry,

Callers 1

registerToolFromManifestFunction · 0.85

Calls 8

createRenderSessionFunction · 0.90
postProcessSessionFunction · 0.90
sessionToToolResponseFunction · 0.85
recordMcpInvocationFunction · 0.85
emitMethod · 0.80
getByMcpNameMethod · 0.80
setStructuredOutputMethod · 0.65

Tested by

no test coverage detected