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