@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
39 lines • 2.48 kB
TypeScript
import type { jsonSchemaValidator } from '@modelcontextprotocol/sdk/validation';
import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';
export interface McpInputSchemaOptions {
/**
* Compiles the JSON Schema. Defaults to the SDK's AJV adapter; swap in
* `CfWorkerJsonSchemaValidator` (or your own) on a runtime where AJV's code generation is not
* available.
*/
validator?: jsonSchemaValidator;
/**
* Reject a schema carrying a `pattern` that can backtrack exponentially (see
* {@link findUnsafePattern}). Default `true`. Turn it off only for a `validator` whose regex
* engine does not backtrack, where the screen costs tools and buys nothing.
*/
rejectUnsafePatterns?: boolean;
}
/**
* Wraps one MCP tool's JSON Schema as the [Standard Schema](https://standardschema.dev) that
* `ToolSpec.inputSchema` requires, so an imported tool goes through the same `~standard.validate`
* gate in `ToolRegistry.invoke` as a hand-written `@AiTool`.
*
* Both halves are the server's real schema, not an approximation of it:
* - `validate` compiles the schema and rejects what it rejects. A tool whose schema cannot be
* compiled THROWS from here — the caller drops that tool, because the alternative (a schema that
* accepts anything) would let the model send a remote tool arbitrary arguments under the
* appearance of a validated call. A schema whose `pattern` can backtrack exponentially throws
* the same way: validating against it is a denial of service on this process, so the tool is
* worth no more than one whose schema does not compile.
* - `jsonSchema.input` hands the schema back verbatim, which is what makes the model see the real
* parameter shapes: `@adonis-agora/agent/ai-sdk` derives tool parameters from Zod or from
* this Standard JSON Schema extension, and degrades any other Standard Schema to an untyped
* object.
*
* `input` and `output` return the same document because validation here is a pass-through: a valid
* value is handed on unchanged, so the input and output types are the same type. The requested
* `target` draft is ignored — the server's schema is a document we relay, not one we can transpile.
*/
export declare function mcpInputSchema(jsonSchema: Record<string, unknown>, options?: McpInputSchemaOptions): StandardSchemaV1<unknown, Record<string, unknown>> & StandardJSONSchemaV1;
//# sourceMappingURL=tool-input.d.ts.map