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

Function toolSchema

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

Source from the content-addressed store, hash-verified

3729 });
3730
3731 const toolSchema = (
3732 address: ToolAddress,
3733 ): Effect.Effect<ToolSchemaView | null, StorageFailure> =>
3734 Effect.gen(function* () {
3735 const policyRules = yield* listActivePolicyRuleSet();
3736 const staticEntry = staticTools.get(String(address));
3737 if (staticEntry) {
3738 const tool = staticToolToTool(staticEntry);
3739 const effective = yield* resolvePolicyFromRuleSet(
3740 normalizedPolicyId(tool),
3741 policyRules,
3742 tool.annotations?.requiresApproval,
3743 );
3744 if (effective.action === "block") return null;
3745 const preview = yield* Effect.tryPromise({
3746 try: () =>
3747 buildToolTypeScriptPreview({
3748 inputSchema: tool.inputSchema,
3749 outputSchema: tool.outputSchema,
3750 defs: new Map(),
3751 }),
3752 catch: (cause) =>
3753 storageFailureFromUnknown("Failed to build static tool TypeScript preview", cause),
3754 }).pipe(Effect.option);
3755 return ToolSchemaView.make({
3756 address,
3757 name: tool.name,
3758 description: tool.description,
3759 inputSchema: tool.inputSchema,
3760 outputSchema: tool.outputSchema,
3761 inputTypeScript: Option.getOrUndefined(preview)?.inputTypeScript,
3762 outputTypeScript: Option.getOrUndefined(preview)?.outputTypeScript,
3763 typeScriptDefinitions: Option.getOrUndefined(preview)?.typeScriptDefinitions,
3764 });
3765 }
3766
3767 const parsed = parseToolAddress(String(address));
3768 if (!parsed) return null;
3769 const row = yield* core.findFirst("tool", {
3770 where: (b: AnyCb) =>
3771 b.and(
3772 byOwner(parsed.owner)(b),
3773 b("integration", "=", String(parsed.integration)),
3774 b("connection", "=", String(parsed.connection)),
3775 b("name", "=", String(parsed.tool)),
3776 ),
3777 });
3778 if (!row) return null;
3779 const tool = rowToTool(row);
3780 const effective = yield* resolvePolicyFromRuleSet(
3781 normalizedPolicyId(tool),
3782 policyRules,
3783 tool.annotations?.requiresApproval,
3784 );
3785 if (effective.action === "block") return null;
3786
3787 const runtime = runtimes.get(row.plugin_id);
3788 const projected = runtime?.plugin.projectToolSchema

Callers

nothing calls this directly

Calls 15

listActivePolicyRuleSetFunction · 0.85
staticToolToToolFunction · 0.85
resolvePolicyFromRuleSetFunction · 0.85
normalizedPolicyIdFunction · 0.85
parseToolAddressFunction · 0.85
byOwnerFunction · 0.85
rowToToolFunction · 0.85
pluginStorageFailureFunction · 0.85
decodeJsonColumnFunction · 0.85

Tested by

no test coverage detected