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

Function makeFullInvoker

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

Source from the content-addressed store, hash-verified

282};
283
284const makeFullInvoker = (
285 executor: Executor,
286 invokeOptions: InvokeOptions,
287 toolDiscoveryProvider: ToolDiscoveryProvider,
288): SandboxToolInvoker => {
289 const base = makeExecutorToolInvoker(executor, { invokeOptions });
290 return {
291 invoke: ({ path, args }) => {
292 if (path === "search") {
293 if (!isRecord(args)) {
294 return Effect.fail(
295 new ExecutionToolError({
296 message:
297 "tools.search expects an object: { query?: string; namespace?: string; limit?: number; offset?: number }",
298 }),
299 );
300 }
301
302 if (args.query !== undefined && typeof args.query !== "string") {
303 return Effect.fail(
304 new ExecutionToolError({
305 message: "tools.search query must be a string when provided",
306 }),
307 );
308 }
309
310 if (args.namespace !== undefined && typeof args.namespace !== "string") {
311 return Effect.fail(
312 new ExecutionToolError({
313 message: "tools.search namespace must be a string when provided",
314 }),
315 );
316 }
317
318 const limit = readOptionalLimit(args.limit, "tools.search");
319 if (Predicate.isTagged(limit, "ExecutionToolError")) {
320 return Effect.fail(limit);
321 }
322
323 const offset = readOptionalOffset(args.offset, "tools.search");
324 if (Predicate.isTagged(offset, "ExecutionToolError")) {
325 return Effect.fail(offset);
326 }
327
328 return toolDiscoveryProvider
329 .searchTools({
330 executor,
331 query: args.query ?? "",
332 limit,
333 namespace: args.namespace,
334 offset,
335 })
336 .pipe(
337 Effect.withSpan("mcp.tool.dispatch", {
338 attributes: { "mcp.tool.name": path, "executor.tool.builtin": true },
339 }),
340 );
341 }

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