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

Function makeFullInvoker

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

Source from the content-addressed store, hash-verified

241};
242
243const makeFullInvoker = (
244 executor: Executor,
245 invokeOptions: InvokeOptions,
246 toolDiscoveryProvider: ToolDiscoveryProvider,
247): SandboxToolInvoker => {
248 const base = makeExecutorToolInvoker(executor, { invokeOptions });
249 return {
250 invoke: ({ path, args }) => {
251 if (path === "search") {
252 if (!isRecord(args)) {
253 return Effect.fail(
254 new ExecutionToolError({
255 message:
256 "tools.search expects an object: { query?: string; namespace?: string; limit?: number; offset?: number }",
257 }),
258 );
259 }
260
261 if (args.query !== undefined && typeof args.query !== "string") {
262 return Effect.fail(
263 new ExecutionToolError({
264 message: "tools.search query must be a string when provided",
265 }),
266 );
267 }
268
269 if (args.namespace !== undefined && typeof args.namespace !== "string") {
270 return Effect.fail(
271 new ExecutionToolError({
272 message: "tools.search namespace must be a string when provided",
273 }),
274 );
275 }
276
277 const limit = readOptionalLimit(args.limit, "tools.search");
278 if (Predicate.isTagged(limit, "ExecutionToolError")) {
279 return Effect.fail(limit);
280 }
281
282 const offset = readOptionalOffset(args.offset, "tools.search");
283 if (Predicate.isTagged(offset, "ExecutionToolError")) {
284 return Effect.fail(offset);
285 }
286
287 return toolDiscoveryProvider
288 .searchTools({
289 executor,
290 query: args.query ?? "",
291 limit,
292 namespace: args.namespace,
293 offset,
294 })
295 .pipe(
296 Effect.withSpan("mcp.tool.dispatch", {
297 attributes: { "mcp.tool.name": path, "executor.tool.builtin": true },
298 }),
299 );
300 }

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