What happened?
CommonJS consumers cannot read the Ajv export from the AJV validator subpath.
Both @modelcontextprotocol/server and @modelcontextprotocol/client expose ./validators/ajv through a require condition, but the generated CJS output references an ESM alias that does not exist in the CJS module scope.
Object.defineProperty(exports, 'Ajv', {
enumerable: true,
get: function () {
return import_ajv.Ajv;
}
});
Accessing that export throws:
ReferenceError: import_ajv is not defined
This affects both package subpaths:
@modelcontextprotocol/server/validators/ajv
@modelcontextprotocol/client/validators/ajv
The issue is specifically the Ajv getter. Other exports from the same subpath, such as AjvJsonSchemaValidator and addFormats, are reachable.
Generated-output shape:
CJS subpath file
dist/validators/ajv.cjs
const require_ajvProvider = require('../ajvProvider-*.cjs')
|
|-- exports.addFormats = require_ajvProvider.addFormats ok
|-- exports.AjvJsonSchemaValidator = require_ajvProvider... ok
|
`-- exports.Ajv getter
|
`-- return import_ajv.Ajv crash
^^^^^^^^^^
no binding with this name exists in ajv.cjs
Provider chunk
dist/ajvProvider-*.cjs
exports.import_ajv = ...
|
`-- correct CJS lookup would be require_ajvProvider.import_ajv.Ajv
What did you expect?
A CommonJS consumer should be able to require the documented AJV validator subpath and read the exported Ajv symbol without a ReferenceError.
For example:
const { Ajv, addFormats, AjvJsonSchemaValidator } = require('@modelcontextprotocol/server/validators/ajv');
const ajv = new Ajv({ strict: true, allErrors: true });
addFormats(ajv);
const validator = new AjvJsonSchemaValidator(ajv);
Code to reproduce
// repro.cjs
const serverAjv = require('@modelcontextprotocol/server/validators/ajv');
const clientAjv = require('@modelcontextprotocol/client/validators/ajv');
console.log(serverAjv.Ajv);
console.log(clientAjv.Ajv);
Run:
Observed result:
ReferenceError: import_ajv is not defined
Minimal direct probes:
node -e "const m = require('@modelcontextprotocol/server/validators/ajv'); m.Ajv"
node -e "const m = require('@modelcontextprotocol/client/validators/ajv'); m.Ajv"
SDK version
@modelcontextprotocol/server@2.0.0-beta.2
@modelcontextprotocol/client@2.0.0-beta.2
Area
Server / Client packaging, CJS validator subpath exports.
What happened?
CommonJS consumers cannot read the
Ajvexport from the AJV validator subpath.Both
@modelcontextprotocol/serverand@modelcontextprotocol/clientexpose./validators/ajvthrough arequirecondition, but the generated CJS output references an ESM alias that does not exist in the CJS module scope.Accessing that export throws:
This affects both package subpaths:
@modelcontextprotocol/server/validators/ajv@modelcontextprotocol/client/validators/ajvThe issue is specifically the
Ajvgetter. Other exports from the same subpath, such asAjvJsonSchemaValidatorandaddFormats, are reachable.Generated-output shape:
What did you expect?
A CommonJS consumer should be able to require the documented AJV validator subpath and read the exported
Ajvsymbol without aReferenceError.For example:
Code to reproduce
Run:
Observed result:
Minimal direct probes:
SDK version
Area
Server / Client packaging, CJS validator subpath exports.