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

Function toolSchema

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

Source from the content-addressed store, hash-verified

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