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

Function makeFullInvoker

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

Source from the content-addressed store, hash-verified

260};
261
262const makeFullInvoker = (
263 executor: Executor,
264 invokeOptions: InvokeOptions,
265 toolDiscoveryProvider: ToolDiscoveryProvider,
266): SandboxToolInvoker => {
267 const base = makeExecutorToolInvoker(executor, { invokeOptions });
268 return {
269 invoke: ({ path, args }) => {
270 if (path === "search") {
271 if (!isRecord(args)) {
272 return Effect.fail(
273 new ExecutionToolError({
274 message:
275 "tools.search expects an object: { query?: string; namespace?: string; limit?: number; offset?: number }",
276 }),
277 );
278 }
279
280 if (args.query !== undefined && typeof args.query !== "string") {
281 return Effect.fail(
282 new ExecutionToolError({
283 message: "tools.search query must be a string when provided",
284 }),
285 );
286 }
287
288 if (args.namespace !== undefined && typeof args.namespace !== "string") {
289 return Effect.fail(
290 new ExecutionToolError({
291 message: "tools.search namespace must be a string when provided",
292 }),
293 );
294 }
295
296 const limit = readOptionalLimit(args.limit, "tools.search");
297 if (Predicate.isTagged(limit, "ExecutionToolError")) {
298 return Effect.fail(limit);
299 }
300
301 const offset = readOptionalOffset(args.offset, "tools.search");
302 if (Predicate.isTagged(offset, "ExecutionToolError")) {
303 return Effect.fail(offset);
304 }
305
306 return toolDiscoveryProvider
307 .searchTools({
308 executor,
309 query: args.query ?? "",
310 limit,
311 namespace: args.namespace,
312 offset,
313 })
314 .pipe(
315 Effect.withSpan("mcp.tool.dispatch", {
316 attributes: { "mcp.tool.name": path, "executor.tool.builtin": true },
317 }),
318 );
319 }

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