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

Function toolsList

packages/core/sdk/src/executor.ts:5671–5730  ·  view source on GitHub ↗
(filter?: ToolListFilter)

Source from the content-addressed store, hash-verified

5669 });
5670
5671 const toolsList = (filter?: ToolListFilter): Effect.Effect<readonly Tool[], StorageFailure> =>
5672 Effect.gen(function* () {
5673 if (toolsSyncGraceMs === null) {
5674 yield* syncStaleConnectionTools;
5675 } else {
5676 yield* awaitStaleSyncWithinGrace(toolsSyncGraceMs);
5677 }
5678 // Projected: the list surface is metadata (address, description,
5679 // annotations) — loading every tool's input/output schema JSON made
5680 // an unbounded list scale with schema bytes, not tool count.
5681 const rows = yield* core.findMany("tool", {
5682 where: (b: AnyCb) =>
5683 b.and(
5684 filter?.integration === undefined
5685 ? true
5686 : b("integration", "=", String(filter.integration)),
5687 filter?.owner === undefined ? true : b("owner", "=", filter.owner),
5688 filter?.connection === undefined
5689 ? true
5690 : b("connection", "=", String(filter.connection)),
5691 ),
5692 select: TOOL_INVOCATION_COLUMNS,
5693 });
5694 const includeBlocked = filter?.includeBlocked ?? false;
5695 const policyRules = yield* listActivePolicyRuleSet();
5696 // Only tools whose integration is still in the catalog. A tool row
5697 // whose integration was removed is an orphan (a removal that could
5698 // not reach this subject's rows): listing it invites an invoke that
5699 // cannot resolve its config and a reconnect that cannot mint.
5700 const catalogSlugs = yield* listCatalogSlugs();
5701 const tools: Tool[] = [];
5702 for (const row of rows) {
5703 if (!catalogSlugs.has(String(row.integration))) continue;
5704 const tool = rowToTool(row);
5705 if (!matchesToolFilter(tool, filter)) continue;
5706 if (!includeBlocked) {
5707 const effective = yield* resolvePolicyFromRuleSet(
5708 normalizedPolicyId(tool),
5709 policyRules,
5710 tool.annotations?.requiresApproval,
5711 );
5712 if (effective.action === "block") continue;
5713 }
5714 tools.push(tool);
5715 }
5716 for (const entry of staticTools.values()) {
5717 const tool = staticToolToTool(entry);
5718 if (!matchesToolFilter(tool, filter)) continue;
5719 if (!includeBlocked) {
5720 const effective = yield* resolvePolicyFromRuleSet(
5721 normalizedPolicyId(tool),
5722 policyRules,
5723 tool.annotations?.requiresApproval,
5724 );
5725 if (effective.action === "block") continue;
5726 }
5727 tools.push(tool);
5728 }

Callers 2

integrationsListFunction · 0.70
connectionsListFunction · 0.70

Calls 10

listActivePolicyRuleSetFunction · 0.85
listCatalogSlugsFunction · 0.85
rowToToolFunction · 0.85
matchesToolFilterFunction · 0.85
resolvePolicyFromRuleSetFunction · 0.85
normalizedPolicyIdFunction · 0.85
staticToolToToolFunction · 0.85
pushMethod · 0.80
valuesMethod · 0.80

Tested by

no test coverage detected