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

Classes

Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.d.ts:3

Customisation entry point for the AJV validator. Re-exports Ajv + addFormats from the SDK's bundled copy, so customising the validator needs no extra installs.

Example

ts
import { Ajv, addFormats, AjvJsonSchemaValidator } from '@modelcontextprotocol/client/validators/ajv';

const ajv = new Ajv({ strict: true, allErrors: true });
addFormats(ajv);
const validator = new AjvJsonSchemaValidator(ajv);

Extends

  • default

Constructors

Constructor

new Ajv(opts?): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:128

Parameters
opts?

Options

Returns

Ajv

Inherited from

AjvCore.constructor

Properties

_compilations

readonly _compilations: Set<SchemaEnv>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:122

Inherited from

AjvCore._compilations

errors?

optional errors?: ErrorObject<string, Record<string, any>, unknown>[] | null

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:109

Inherited from

AjvCore.errors

formats

readonly formats: object

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:118

Index Signature

[key: string]: AddedFormat | undefined

Inherited from

AjvCore.formats

logger

logger: Logger

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:110

Inherited from

AjvCore.logger

opts

opts: InstanceOptions

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:108

Inherited from

AjvCore.opts

refs

readonly refs: object

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:115

Index Signature

[key: string]: string | SchemaEnv | undefined

Inherited from

AjvCore.refs

RULES

readonly RULES: ValidationRules

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:121

Inherited from

AjvCore.RULES

schemas

readonly schemas: object

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:112

Index Signature

[key: string]: SchemaEnv | undefined

Inherited from

AjvCore.schemas

scope

readonly scope: ValueScope

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:111

Inherited from

AjvCore.scope

MissingRefError

static MissingRefError: typeof default

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:127

Inherited from

AjvCore.MissingRefError

ValidationError

static ValidationError: typeof default

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:126

Inherited from

AjvCore.ValidationError

Methods

_addDefaultMetaSchema()

_addDefaultMetaSchema(): void

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.d.ts:5

Returns

void

Overrides

AjvCore._addDefaultMetaSchema

_addSchema()

_addSchema(schema, meta?, baseId?, validateSchema?, addSchema?): SchemaEnv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:166

Parameters
schema

AnySchema

meta?

boolean

baseId?

string

validateSchema?

boolean | "log"

addSchema?

boolean

Returns

SchemaEnv

Inherited from

AjvCore._addSchema

_addVocabularies()

_addVocabularies(): void

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.d.ts:4

Returns

void

Overrides

AjvCore._addVocabularies

$dataMetaSchema()

$dataMetaSchema(metaSchema, keywordsJsonPointers): AnySchemaObject

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:164

Parameters
metaSchema

AnySchemaObject

keywordsJsonPointers

string[]

Returns

AnySchemaObject

Inherited from

AjvCore.$dataMetaSchema

addFormat()

addFormat(name, format): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:161

Parameters
name

string

format

Format

Returns

Ajv

Inherited from

AjvCore.addFormat

addKeyword()

addKeyword(kwdOrDef, def?): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:158

Parameters
kwdOrDef

string | KeywordDefinition

def?

KeywordDefinition

Returns

Ajv

Inherited from

AjvCore.addKeyword

addMetaSchema()

addMetaSchema(schema, key?, _validateSchema?): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:152

Parameters
schema

AnySchemaObject

key?

string

_validateSchema?

boolean | "log"

Returns

Ajv

Inherited from

AjvCore.addMetaSchema

addSchema()

addSchema(schema, key?, _meta?, _validateSchema?): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:148

Parameters
schema

AnySchema | AnySchema[]

key?

string

_meta?

boolean

_validateSchema?

boolean | "log"

Returns

Ajv

Inherited from

AjvCore.addSchema

addVocabulary()

addVocabulary(definitions): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:157

Parameters
definitions

Vocabulary

Returns

Ajv

Inherited from

AjvCore.addVocabulary

compile()
Call Signature

compile<T>(schema, _meta?): ValidateFunction<T>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:139

Type Parameters
T

T = unknown

Parameters
schema

Schema | JSONSchemaType<T>

_meta?

boolean

Returns

ValidateFunction<T>

Inherited from

AjvCore.compile

Call Signature

compile<T>(schema, _meta?): ValidateFunction<T>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:140

Type Parameters
T

T = unknown

Parameters
schema

JTDSchemaType<T>

_meta?

boolean

Returns

ValidateFunction<T>

Inherited from

AjvCore.compile

Call Signature

compile<N, T>(schema, _meta?): ValidateFunction<JTDDataType<T>>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:141

Type Parameters
N

N extends never

T

T extends SomeJTDSchemaType

Parameters
schema

T

_meta?

boolean

Returns

ValidateFunction<JTDDataType<T>>

Inherited from

AjvCore.compile

Call Signature

compile<T>(schema, _meta?): AsyncValidateFunction<T>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:142

Type Parameters
T

T = unknown

Parameters
schema

AsyncSchema

_meta?

boolean

Returns

AsyncValidateFunction<T>

Inherited from

AjvCore.compile

Call Signature

compile<T>(schema, _meta?): AnyValidateFunction<T>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:143

Type Parameters
T

T = unknown

Parameters
schema

AnySchema

_meta?

boolean

Returns

AnyValidateFunction<T>

Inherited from

AjvCore.compile

compileAsync()
Call Signature

compileAsync<T>(schema, _meta?): Promise<ValidateFunction<T>>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:144

Type Parameters
T

T = unknown

Parameters
schema

SchemaObject | JSONSchemaType<T>

_meta?

boolean

Returns

Promise<ValidateFunction<T>>

Inherited from

AjvCore.compileAsync

Call Signature

compileAsync<T>(schema, _meta?): Promise<ValidateFunction<T>>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:145

Type Parameters
T

T = unknown

Parameters
schema

JTDSchemaType<T>

_meta?

boolean

Returns

Promise<ValidateFunction<T>>

Inherited from

AjvCore.compileAsync

Call Signature

compileAsync<T>(schema, meta?): Promise<AsyncValidateFunction<T>>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:146

Type Parameters
T

T = unknown

Parameters
schema

AsyncSchema

meta?

boolean

Returns

Promise<AsyncValidateFunction<T>>

Inherited from

AjvCore.compileAsync

Call Signature

compileAsync<T>(schema, meta?): Promise<AnyValidateFunction<T>>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:147

Type Parameters
T

T = unknown

Parameters
schema

AnySchemaObject

meta?

boolean

Returns

Promise<AnyValidateFunction<T>>

Inherited from

AjvCore.compileAsync

defaultMeta()

defaultMeta(): string | AnySchemaObject | undefined

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.d.ts:6

Returns

string | AnySchemaObject | undefined

Overrides

AjvCore.defaultMeta

errorsText()

errorsText(errors?, __namedParameters?): string

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:162

Parameters
errors?

ErrorObject<string, Record<string, any>, unknown>[] | null

__namedParameters?

ErrorsTextOptions

Returns

string

Inherited from

AjvCore.errorsText

getKeyword()

getKeyword(keyword): boolean | AddedKeywordDefinition

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:159

Parameters
keyword

string

Returns

boolean | AddedKeywordDefinition

Inherited from

AjvCore.getKeyword

getSchema()

getSchema<T>(keyRef): AnyValidateFunction<T> | undefined

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:155

Type Parameters
T

T = unknown

Parameters
keyRef

string

Returns

AnyValidateFunction<T> | undefined

Inherited from

AjvCore.getSchema

removeKeyword()

removeKeyword(keyword): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:160

Parameters
keyword

string

Returns

Ajv

Inherited from

AjvCore.removeKeyword

removeSchema()

removeSchema(schemaKeyRef?): Ajv

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:156

Parameters
schemaKeyRef?

string | RegExp | AnySchema

Returns

Ajv

Inherited from

AjvCore.removeSchema

validate()
Call Signature

validate(schema, data): boolean

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:132

Parameters
schema

string | Schema

data

unknown

Returns

boolean

Inherited from

AjvCore.validate

Call Signature

validate(schemaKeyRef, data): boolean | Promise<unknown>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:133

Parameters
schemaKeyRef

string | AnySchema

data

unknown

Returns

boolean | Promise<unknown>

Inherited from

AjvCore.validate

Call Signature

validate<T>(schema, data): data is T

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:134

Type Parameters
T

T

Parameters
schema

string | Schema | JSONSchemaType<T>

data

unknown

Returns

data is T

Inherited from

AjvCore.validate

Call Signature

validate<T>(schema, data): data is T

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:135

Type Parameters
T

T

Parameters
schema

JTDSchemaType<T>

data

unknown

Returns

data is T

Inherited from

AjvCore.validate

Call Signature

validate<N, T>(schema, data): data is JTDDataType<T>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:136

Type Parameters
N

N extends never

T

T extends SomeJTDSchemaType

Parameters
schema

T

data

unknown

Returns

data is JTDDataType<T>

Inherited from

AjvCore.validate

Call Signature

validate<T>(schema, data): Promise<T>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:137

Type Parameters
T

T

Parameters
schema

AsyncSchema

data

unknown

Returns

Promise<T>

Inherited from

AjvCore.validate

Call Signature

validate<T>(schemaKeyRef, data): data is T | Promise<T>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:138

Type Parameters
T

T

Parameters
schemaKeyRef

string | AnySchema

data

unknown

Returns

data is T | Promise<T>

Inherited from

AjvCore.validate

validateSchema()

validateSchema(schema, throwOrLogError?): boolean | Promise<unknown>

Defined in: node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.d.ts:154

Parameters
schema

AnySchema

throwOrLogError?

boolean

Returns

boolean | Promise<unknown>

Inherited from

AjvCore.validateSchema

Variables

addFormats

const addFormats: any

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

Customisation entry point for the AJV validator. Re-exports Ajv + addFormats from the SDK's bundled copy, so customising the validator needs no extra installs.

Example

ts
import { Ajv, addFormats, AjvJsonSchemaValidator } from '@modelcontextprotocol/client/validators/ajv';

const ajv = new Ajv({ strict: true, allErrors: true });
addFormats(ajv);
const validator = new AjvJsonSchemaValidator(ajv);

References

AjvJsonSchemaValidator

Re-exports AjvJsonSchemaValidator