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

MCP TypeScript SDK (V2) / @modelcontextprotocol/client / shimsBrowser

shimsBrowser

Classes

DefaultJsonSchemaValidator

Defined in: packages/core-internal/src/validators/cfWorkerProvider.ts:50

@cfworker/json-schema-backed JSON Schema validator. See @modelcontextprotocol/{client,server}/validators/cf-worker for the customisation entry point.

Default validates as JSON Schema 2020-12 (SEP-1613). Schemas declaring a different $schema are rejected with a plain Error. Passing an explicit draft to the constructor overrides this — that draft is used for every schema regardless of $schema.

Examples

Use with default configuration (2020-12, shortcircuit on)

ts
const validator = new CfWorkerJsonSchemaValidator();

Use with custom configuration

ts
const validator = new CfWorkerJsonSchemaValidator({
    draft: '2020-12',
    shortcircuit: false // Report all errors
});

Implements

Constructors

Constructor

new DefaultJsonSchemaValidator(options?): DefaultJsonSchemaValidator

Defined in: packages/core-internal/src/validators/cfWorkerProvider.ts:64

Create a validator

Parameters
options?

Configuration options

draft?

CfWorkerSchemaDraft

JSON Schema draft version to force for every schema. When set, the $schema check is skipped. When omitted, the provider validates as 2020-12 and rejects schemas declaring a different $schema.

shortcircuit?

boolean

If true, stop validation after first error (default: true)

Returns

DefaultJsonSchemaValidator

Methods

getValidator()

getValidator<T>(schema): JsonSchemaValidator<T>

Defined in: packages/core-internal/src/validators/cfWorkerProvider.ts:77

Create a validator for the given JSON Schema

Unlike AJV, this validator is not cached internally

Type Parameters
T

T

Parameters
schema

JsonSchemaType

Standard JSON Schema object

Returns

JsonSchemaValidator<T>

A validator function that validates input data

Implementation of

jsonSchemaValidator.getValidator

Variables

CORS_IS_POSSIBLE

const CORS_IS_POSSIBLE: true = true

Defined in: packages/client/src/shimsBrowser.ts:13

Whether fetch() may throw TypeError due to CORS. Only true in browser contexts (including Web Workers / Service Workers). In Node.js and Cloudflare Workers, a TypeError from fetch is always a real network/configuration error.