Skip to content

alpha.3: CfWorkerJsonSchemaValidator and AjvJsonSchemaValidator declared in types but missing from runtime index.mjs export #2391

Description

@morluto

Bug

In @modelcontextprotocol/server@2.0.0-alpha.3, CfWorkerJsonSchemaValidator and AjvJsonSchemaValidator are declared in the type declarations (dist/index.d.mts) and listed in the export type statement, but are missing from the runtime dist/index.mjs export. This causes a runtime SyntaxError when importing them from the package root.

Package version

@modelcontextprotocol/server@2.0.0-alpha.3

Reproduction

import { CfWorkerJsonSchemaValidator } from "@modelcontextprotocol/server";
const validator = new CfWorkerJsonSchemaValidator();

Results in:

SyntaxError: Export named 'CfWorkerJsonSchemaValidator' not found in module '.../dist/index.mjs'.

The same happens with AjvJsonSchemaValidator.

Evidence

Type declarations (dist/index.d.mts) — both are present

import { t as AjvJsonSchemaValidator } from "./ajvProvider-DZ_siXcF.mjs";
import { t as CfWorkerJsonSchemaValidator } from "./cfWorkerProvider-DUhk5Ewx.mjs";

export { ..., AjvJsonSchemaValidator, ..., CfWorkerJsonSchemaValidator, CfWorkerSchemaDraft, ... };

Runtime (dist/index.mjs) — both are absent

export { BAGGAGE_META_KEY, CLIENT_CAPABILITIES_META_KEY, ..., fromJsonSchema, getDisplayName, ..., validateHostHeader };
// No CfWorkerJsonSchemaValidator, no AjvJsonSchemaValidator

Subpath exports work correctly

The package.json exports field includes subpath entries that DO export them at runtime:

{
  "./validators/ajv": {
    "types": "./dist/validators/ajv.d.mts",
    "import": "./dist/validators/ajv.mjs"
  },
  "./validators/cf-worker": {
    "types": "./dist/validators/cfWorker.d.mts",
    "import": "./dist/validators/cfWorker.mjs"
  }
}
// dist/validators/cfWorker.mjs
import { t as CfWorkerJsonSchemaValidator } from "../cfWorkerProvider-BrJKpSFH.mjs";
export { CfWorkerJsonSchemaValidator };

So the classes exist and are exported via subpaths — the main index.mjs bundle just forgot to re-export them.

Workaround

Import from the subpath export instead of the package root:

import { CfWorkerJsonSchemaValidator } from "@modelcontextprotocol/server/validators/cf-worker";
import { AjvJsonSchemaValidator } from "@modelcontextprotocol/server/validators/ajv";

Expected behavior

Either:

  1. Re-export CfWorkerJsonSchemaValidator and AjvJsonSchemaValidator from dist/index.mjs (matching the type declarations), or
  2. Remove them from the dist/index.d.mts export list if the intent is to only expose them via subpath exports.

Option 1 is preferable since the type declarations already promise these exports from the root, and consumers importing from @modelcontextprotocol/server will expect them to be available at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingfix proposedBot has a verified fix diff in the commentready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions