This is the documentation for the v2 beta — looking for the v1 documentation?
Skip to content

MCP TypeScript SDK (V2) / @modelcontextprotocol/client / validators/ajv

validators/ajv

Variables

addFormats

const addFormats: any

Defined in: packages/core-internal/src/validators/ajvProvider.ts:36

ajv-formats default export, normalised through the CJS/ESM interop wrapper.


Ajv

const Ajv: typeof Ajv = Draft7Ajv

Defined in: packages/core-internal/src/validators/ajvProvider.ts:165

Draft-07 AJV class, re-exported for consumers who need to opt back to the pre-SEP-1613 default. The full v1-equivalent construction is:

ts
const ajv = new Ajv({ strict: false, validateFormats: true, validateSchema: false, allErrors: true });
addFormats(ajv);
new AjvJsonSchemaValidator(ajv);

(omitting validateSchema: false makes a 2020-12-stamped $schema fail with an opaque "no schema with key or ref …" engine error; omitting addFormats silently drops format validation that the v1 default had).

The SDK bundles ajv internally but does not re-export Ajv2020 (its type graph tips downstream declaration bundling — see #2339). To construct a custom 2020-12 instance, add ajv to your own dependencies (matching the SDK's pinned version) and import { Ajv2020 } from 'ajv/dist/2020.js'.

References

AjvJsonSchemaValidator

Renames and re-exports DefaultJsonSchemaValidator