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

Function toolSchema

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

Source from the content-addressed store, hash-verified

3775 });
3776
3777 const toolSchema = (
3778 address: ToolAddress,
3779 ): Effect.Effect<ToolSchemaView | null, StorageFailure> =>
3780 Effect.gen(function* () {
3781 const policyRules = yield* listActivePolicyRuleSet();
3782 const staticEntry = staticTools.get(String(address));
3783 if (staticEntry) {
3784 const tool = staticToolToTool(staticEntry);
3785 const effective = yield* resolvePolicyFromRuleSet(
3786 normalizedPolicyId(tool),
3787 policyRules,
3788 tool.annotations?.requiresApproval,
3789 );
3790 if (effective.action === "block") return null;
3791 const preview = yield* Effect.tryPromise({
3792 try: () =>
3793 buildToolTypeScriptPreview({
3794 inputSchema: tool.inputSchema,
3795 outputSchema: tool.outputSchema,
3796 defs: new Map(),
3797 }),
3798 catch: (cause) =>
3799 storageFailureFromUnknown("Failed to build static tool TypeScript preview", cause),
3800 }).pipe(Effect.option);
3801 return ToolSchemaView.make({
3802 address,
3803 name: tool.name,
3804 description: tool.description,
3805 inputSchema: tool.inputSchema,
3806 outputSchema: tool.outputSchema,
3807 inputTypeScript: Option.getOrUndefined(preview)?.inputTypeScript,
3808 outputTypeScript: Option.getOrUndefined(preview)?.outputTypeScript,
3809 typeScriptDefinitions: Option.getOrUndefined(preview)?.typeScriptDefinitions,
3810 });
3811 }
3812
3813 const parsed = parseToolAddress(String(address));
3814 if (!parsed) return null;
3815 const row = yield* core.findFirst("tool", {
3816 where: (b: AnyCb) =>
3817 b.and(
3818 byOwner(parsed.owner)(b),
3819 b("integration", "=", String(parsed.integration)),
3820 b("connection", "=", String(parsed.connection)),
3821 b("name", "=", String(parsed.tool)),
3822 ),
3823 });
3824 if (!row) return null;
3825 const tool = rowToTool(row);
3826 const effective = yield* resolvePolicyFromRuleSet(
3827 normalizedPolicyId(tool),
3828 policyRules,
3829 tool.annotations?.requiresApproval,
3830 );
3831 if (effective.action === "block") return null;
3832
3833 const runtime = runtimes.get(row.plugin_id);
3834 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