MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeFullInvoker

Function makeFullInvoker

packages/core/execution/src/engine.ts:312–448  ·  view source on GitHub ↗
(
  executor: Executor,
  invokeOptions: InvokeOptions,
  toolDiscoveryProvider: ToolDiscoveryProvider,
)

Source from the content-addressed store, hash-verified

310};
311
312const makeFullInvoker = (
313 executor: Executor,
314 invokeOptions: InvokeOptions,
315 toolDiscoveryProvider: ToolDiscoveryProvider,
316): SandboxToolInvoker => {
317 const base = makeExecutorToolInvoker(executor, { invokeOptions });
318 return {
319 invoke: ({ path, args }) => {
320 if (path === "search") {
321 if (!isRecord(args)) {
322 return Effect.fail(
323 new ExecutionToolError({
324 message:
325 "tools.search expects an object: { query?: string; namespace?: string; limit?: number; offset?: number }",
326 }),
327 );
328 }
329
330 if (args.query !== undefined && typeof args.query !== "string") {
331 return Effect.fail(
332 new ExecutionToolError({
333 message: "tools.search query must be a string when provided",
334 }),
335 );
336 }
337
338 if (args.namespace !== undefined && typeof args.namespace !== "string") {
339 return Effect.fail(
340 new ExecutionToolError({
341 message: "tools.search namespace must be a string when provided",
342 }),
343 );
344 }
345
346 const limit = readOptionalLimit(args.limit, "tools.search");
347 if (Predicate.isTagged(limit, "ExecutionToolError")) {
348 return Effect.fail(limit);
349 }
350
351 const offset = readOptionalOffset(args.offset, "tools.search");
352 if (Predicate.isTagged(offset, "ExecutionToolError")) {
353 return Effect.fail(offset);
354 }
355
356 return toolDiscoveryProvider
357 .searchTools({
358 executor,
359 query: args.query ?? "",
360 limit,
361 namespace: args.namespace,
362 offset,
363 })
364 .pipe(
365 Effect.withSpan("mcp.tool.dispatch", {
366 attributes: { "mcp.tool.name": path, "executor.tool.builtin": true },
367 }),
368 );
369 }

Callers 1

createExecutionEngineFunction · 0.85

Calls 5

makeExecutorToolInvokerFunction · 0.90
readOptionalLimitFunction · 0.85
readOptionalOffsetFunction · 0.85
invokeMethod · 0.80
isRecordFunction · 0.70

Tested by

no test coverage detected