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

Function toolSchema

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

Source from the content-addressed store, hash-verified

3203 });
3204
3205 const toolSchema = (
3206 address: ToolAddress,
3207 ): Effect.Effect<ToolSchemaView | null, StorageFailure> =>
3208 Effect.gen(function* () {
3209 const policyRules = yield* listActivePolicyRuleSet();
3210 const staticEntry = staticTools.get(String(address));
3211 if (staticEntry) {
3212 const tool = staticToolToTool(staticEntry);
3213 const effective = yield* resolvePolicyFromRuleSet(
3214 normalizedPolicyId(tool),
3215 policyRules,
3216 tool.annotations?.requiresApproval,
3217 );
3218 if (effective.action === "block") return null;
3219 const preview = yield* Effect.tryPromise({
3220 try: () =>
3221 buildToolTypeScriptPreview({
3222 inputSchema: tool.inputSchema,
3223 outputSchema: tool.outputSchema,
3224 defs: new Map(),
3225 }),
3226 catch: (cause) =>
3227 storageFailureFromUnknown("Failed to build static tool TypeScript preview", cause),
3228 }).pipe(Effect.option);
3229 return ToolSchemaView.make({
3230 address,
3231 name: tool.name,
3232 description: tool.description,
3233 inputSchema: tool.inputSchema,
3234 outputSchema: tool.outputSchema,
3235 inputTypeScript: Option.getOrUndefined(preview)?.inputTypeScript,
3236 outputTypeScript: Option.getOrUndefined(preview)?.outputTypeScript,
3237 typeScriptDefinitions: Option.getOrUndefined(preview)?.typeScriptDefinitions,
3238 });
3239 }
3240
3241 const parsed = parseToolAddress(String(address));
3242 if (!parsed) return null;
3243 const row = yield* core.findFirst("tool", {
3244 where: (b: AnyCb) =>
3245 b.and(
3246 byOwner(parsed.owner)(b),
3247 b("integration", "=", String(parsed.integration)),
3248 b("connection", "=", String(parsed.connection)),
3249 b("name", "=", String(parsed.tool)),
3250 ),
3251 });
3252 if (!row) return null;
3253 const tool = rowToTool(row);
3254 const effective = yield* resolvePolicyFromRuleSet(
3255 normalizedPolicyId(tool),
3256 policyRules,
3257 tool.annotations?.requiresApproval,
3258 );
3259 if (effective.action === "block") return null;
3260
3261 const runtime = runtimes.get(row.plugin_id);
3262 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