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

Function toolSchema

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

Source from the content-addressed store, hash-verified

3007 });
3008
3009 const toolSchema = (
3010 address: ToolAddress,
3011 ): Effect.Effect<ToolSchemaView | null, StorageFailure> =>
3012 Effect.gen(function* () {
3013 const policyRules = yield* listActivePolicyRuleSet();
3014 const staticEntry = staticTools.get(String(address));
3015 if (staticEntry) {
3016 const tool = staticToolToTool(staticEntry);
3017 const effective = yield* resolvePolicyFromRuleSet(
3018 normalizedPolicyId(tool),
3019 policyRules,
3020 tool.annotations?.requiresApproval,
3021 );
3022 if (effective.action === "block") return null;
3023 const preview = yield* Effect.tryPromise({
3024 try: () =>
3025 buildToolTypeScriptPreview({
3026 inputSchema: tool.inputSchema,
3027 outputSchema: tool.outputSchema,
3028 defs: new Map(),
3029 }),
3030 catch: (cause) =>
3031 storageFailureFromUnknown("Failed to build static tool TypeScript preview", cause),
3032 }).pipe(Effect.option);
3033 return ToolSchemaView.make({
3034 address,
3035 name: tool.name,
3036 description: tool.description,
3037 inputSchema: tool.inputSchema,
3038 outputSchema: tool.outputSchema,
3039 inputTypeScript: Option.getOrUndefined(preview)?.inputTypeScript,
3040 outputTypeScript: Option.getOrUndefined(preview)?.outputTypeScript,
3041 typeScriptDefinitions: Option.getOrUndefined(preview)?.typeScriptDefinitions,
3042 });
3043 }
3044
3045 const parsed = parseToolAddress(String(address));
3046 if (!parsed) return null;
3047 const row = yield* core.findFirst("tool", {
3048 where: (b: AnyCb) =>
3049 b.and(
3050 byOwner(parsed.owner)(b),
3051 b("integration", "=", String(parsed.integration)),
3052 b("connection", "=", String(parsed.connection)),
3053 b("name", "=", String(parsed.tool)),
3054 ),
3055 });
3056 if (!row) return null;
3057 const tool = rowToTool(row);
3058 const effective = yield* resolvePolicyFromRuleSet(
3059 normalizedPolicyId(tool),
3060 policyRules,
3061 tool.annotations?.requiresApproval,
3062 );
3063 if (effective.action === "block") return null;
3064
3065 const definitionRows = yield* core.findMany("definition", {
3066 where: (b: AnyCb) =>

Callers

nothing calls this directly

Calls 13

listActivePolicyRuleSetFunction · 0.85
staticToolToToolFunction · 0.85
resolvePolicyFromRuleSetFunction · 0.85
normalizedPolicyIdFunction · 0.85
parseToolAddressFunction · 0.85
byOwnerFunction · 0.85
rowToToolFunction · 0.85
decodeJsonColumnFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected