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

Function makeFullInvoker

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

Source from the content-addressed store, hash-verified

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

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