MCP TypeScript SDK (V2) / @modelcontextprotocol/server / shimsBrowser
shimsBrowser
Classes
DefaultJsonSchemaValidator
Defined in: packages/core-internal/src/validators/cfWorkerProvider.ts:51
@cfworker/json-schema-backed JSON Schema validator. See @modelcontextprotocol/{client,server}/validators/cf-worker for the customisation entry point.
Default dispatches on the schema's declared dialect: no $schema or 2020-12 → '2020-12' (SEP-1613); 2019-09 → '2019-09'; draft-07 or draft-06 → '7'. Schemas declaring any other $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.
Known draft-07 engine gap: @cfworker/json-schema does not treat draft-07 dependencies as a name→subschema map during $ref collection, so a dependency entry whose KEY collides with a JSON Schema keyword (type, default, format, required, pattern, …) and whose subschema contains a $ref throws Unresolved $ref at validation time when the dependency triggers — data-dependently, not at compile. The Node (classic Ajv) engine handles the same schema correctly. Callers that hit this receive the SDK's typed validation error (the throw is captured by the validation paths), and the deviation is pinned by a recorded-contract test.
Examples
Use with default configuration (2020-12, shortcircuit on)
const validator = new CfWorkerJsonSchemaValidator();Use with custom configuration
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:65
Create a validator
Parameters
options?
Configuration options
draft?
JSON Schema draft version to force for every schema. When set, the $schema dispatch is skipped. When omitted, the provider dispatches on each schema's declared $schema (2020-12, 2019-09, draft-07, draft-06; absent means 2020-12) and rejects others.
shortcircuit?
boolean
If true, stop validation after first error (default: true)
Returns
Methods
getValidator()
getValidator<
T>(schema):JsonSchemaValidator<T>
Defined in: packages/core-internal/src/validators/cfWorkerProvider.ts:88
Create a validator for the given JSON Schema
Unlike AJV, this validator is not cached internally
Type Parameters
T
T
Parameters
schema
Standard JSON Schema object
Returns
A validator function that validates input data
Implementation of
jsonSchemaValidator.getValidator
Variables
process
constprocess:object
Defined in: packages/server/src/shimsBrowser.ts:20
Type Declaration
stdin
Get Signature
get stdin():
never
Returns
never
stdout
Get Signature
get stdout():
never
Returns
never