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

Function toolSchema

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

Source from the content-addressed store, hash-verified

3703 });
3704
3705 const toolSchema = (
3706 address: ToolAddress,
3707 ): Effect.Effect<ToolSchemaView | null, StorageFailure> =>
3708 Effect.gen(function* () {
3709 const policyRules = yield* listActivePolicyRuleSet();
3710 const staticEntry = staticTools.get(String(address));
3711 if (staticEntry) {
3712 const tool = staticToolToTool(staticEntry);
3713 const effective = yield* resolvePolicyFromRuleSet(
3714 normalizedPolicyId(tool),
3715 policyRules,
3716 tool.annotations?.requiresApproval,
3717 );
3718 if (effective.action === "block") return null;
3719 const preview = yield* Effect.tryPromise({
3720 try: () =>
3721 buildToolTypeScriptPreview({
3722 inputSchema: tool.inputSchema,
3723 outputSchema: tool.outputSchema,
3724 defs: new Map(),
3725 }),
3726 catch: (cause) =>
3727 storageFailureFromUnknown("Failed to build static tool TypeScript preview", cause),
3728 }).pipe(Effect.option);
3729 return ToolSchemaView.make({
3730 address,
3731 name: tool.name,
3732 description: tool.description,
3733 inputSchema: tool.inputSchema,
3734 outputSchema: tool.outputSchema,
3735 inputTypeScript: Option.getOrUndefined(preview)?.inputTypeScript,
3736 outputTypeScript: Option.getOrUndefined(preview)?.outputTypeScript,
3737 typeScriptDefinitions: Option.getOrUndefined(preview)?.typeScriptDefinitions,
3738 });
3739 }
3740
3741 const parsed = parseToolAddress(String(address));
3742 if (!parsed) return null;
3743 const row = yield* core.findFirst("tool", {
3744 where: (b: AnyCb) =>
3745 b.and(
3746 byOwner(parsed.owner)(b),
3747 b("integration", "=", String(parsed.integration)),
3748 b("connection", "=", String(parsed.connection)),
3749 b("name", "=", String(parsed.tool)),
3750 ),
3751 });
3752 if (!row) return null;
3753 const tool = rowToTool(row);
3754 const effective = yield* resolvePolicyFromRuleSet(
3755 normalizedPolicyId(tool),
3756 policyRules,
3757 tool.annotations?.requiresApproval,
3758 );
3759 if (effective.action === "block") return null;
3760
3761 const runtime = runtimes.get(row.plugin_id);
3762 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