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

Function toolSchema

packages/core/sdk/src/executor.ts:5824–5970  ·  view source on GitHub ↗
(
      address: ToolAddress,
    )

Source from the content-addressed store, hash-verified

5822 readTools(filter, { awaitStaleSync: true });
5823
5824 const toolSchema = (
5825 address: ToolAddress,
5826 ): Effect.Effect<ToolSchemaView | null, StorageFailure> =>
5827 Effect.gen(function* () {
5828 const policyRules = yield* listActivePolicyRuleSet();
5829 const staticEntry = staticTools.get(String(address));
5830 if (staticEntry) {
5831 const tool = staticToolToTool(staticEntry);
5832 const effective = yield* resolvePolicyFromRuleSet(
5833 normalizedPolicyId(tool),
5834 policyRules,
5835 tool.annotations?.requiresApproval,
5836 );
5837 if (effective.action === "block") return null;
5838 const preview = yield* Effect.tryPromise({
5839 try: () =>
5840 buildToolTypeScriptPreview({
5841 inputSchema: tool.inputSchema,
5842 outputSchema: tool.outputSchema,
5843 defs: new Map(),
5844 }),
5845 catch: (cause) =>
5846 storageFailureFromUnknown("Failed to build static tool TypeScript preview", cause),
5847 }).pipe(Effect.option);
5848 return ToolSchemaView.make({
5849 address,
5850 name: tool.name,
5851 description: tool.description,
5852 inputSchema: tool.inputSchema,
5853 outputSchema: tool.outputSchema,
5854 inputTypeScript: Option.getOrUndefined(preview)?.inputTypeScript,
5855 outputTypeScript: Option.getOrUndefined(preview)?.outputTypeScript,
5856 typeScriptDefinitions: Option.getOrUndefined(preview)?.typeScriptDefinitions,
5857 annotations: toolAnnotationsView(tool.annotations),
5858 });
5859 }
5860
5861 const parsed = parseToolAddress(String(address));
5862 if (!parsed) return null;
5863 const row = yield* core.findFirst("tool", {
5864 where: (b: AnyCb) =>
5865 b.and(
5866 byOwner(parsed.owner)(b),
5867 b("integration", "=", String(parsed.integration)),
5868 b("connection", "=", String(parsed.connection)),
5869 b("name", "=", String(parsed.tool)),
5870 ),
5871 });
5872 if (!row) return null;
5873 const tool = rowToTool(row);
5874 const effective = yield* resolvePolicyFromRuleSet(
5875 normalizedPolicyId(tool),
5876 policyRules,
5877 tool.annotations?.requiresApproval,
5878 );
5879 if (effective.action === "block") return null;
5880
5881 const runtime = runtimes.get(row.plugin_id);

Callers

nothing calls this directly

Calls 15

listActivePolicyRuleSetFunction · 0.85
staticToolToToolFunction · 0.85
resolvePolicyFromRuleSetFunction · 0.85
normalizedPolicyIdFunction · 0.85
toolAnnotationsViewFunction · 0.85
parseToolAddressFunction · 0.85
byOwnerFunction · 0.85
rowToToolFunction · 0.85

Tested by

no test coverage detected