Skip to content

fix(core-internal): silence unknown-format warnings in v2 validators - #3007

Open
senorMk wants to merge 1 commit into
modelcontextprotocol:mainfrom
senorMk:fix/v2-ajv-unknown-format-warnings
Open

senorMk wants to merge 1 commit into
modelcontextprotocol:mainfrom
senorMk:fix/v2-ajv-unknown-format-warnings

Conversation

@senorMk

@senorMk senorMk commented Oct 12, 2026

Copy link
Copy Markdown

Refs #2855 (v2).

Servers that publish unknown format annotations cause the v2 default Ajv validators to print warnings while compiling tool schemas. A three-field schema emits six warnings per compilation: two for each subschema path. The shared default-engine factory now filters these warnings for every supported dialect. Known formats still validate, other diagnostics still reach the console, and caller-supplied engines keep their own logging.

#2898 covers the corresponding v1.x fix. This targets main and complements that work. #2601 also targets v2, but registers google-duration specifically; this change handles arbitrary unknown formats without adding vendor-specific validation. Both release lines need the fix, so this PR references rather than auto-closes #2855.

Adapted from sean-park-funda's v2 patch, 36da288, with co-author credit. The logger stays internal, and regression coverage now exercises the default, 2020-12, 2019-09, draft-07, and draft-06 dispatch paths.

Validation:

  • The five new silence tests fail on unmodified main, each observing 12 warnings across two distinct schema compilations, and pass with the fix.
  • All 1,541 core-internal tests pass, including 16 new cases covering zero warnings, duplicate diagnostics from custom engines, schema validation, known formats, and forwarding other logger messages.
  • core-internal typecheck and ESLint on both changed TypeScript files pass; changed files are Prettier-clean.

The normal pnpm install could not access the registry in this environment. Checks used the repository's lockfile-pinned dependencies downloaded separately and verified against their integrity hashes. The full monorepo checks were not run.

Filter unknown-format warnings in the shared default Ajv factory. Cover every supported dialect, duplicate warnings, known formats, custom engines, and forwarding of other diagnostics.

Adapted from sean-park-funda/typescript-sdk commit 36da288.

Co-authored-by: sean-park-funda <sungjunpark7392@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0210f84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/core-internal Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3007

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3007

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3007

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3007

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3007

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3007

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3007

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3007

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3007

commit: 0210f84

@senorMk
senorMk marked this pull request as ready for review October 12, 2026 09:53
@senorMk
senorMk requested a review from a team as a code owner October 12, 2026 09:53

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@senorMk, the spam is real, and most of it lands where nobody can fix it: client.ts:1846 compiles every third-party tool's outputSchema through the default engine, so a client author sees the vendor's google-duration and can't change it. non-blocking: I'd still warn once per format name per engine, not never. Silence also removes the only typo signal a server author gets through fromJsonSchema or an elicitation requestedSchema (server.ts:1224), and Ajv then accepts any string. A caller-supplied engine keeps its warnings under this PR, but the author who typed date_time never configured one. The cost of my version is one unfixable line per vendor format on each client.

Put the Set inside createDefaultAjvInstance. A module-level one would also mute a second client meeting the same name, and it would leak across the five dialect tests. Probe: one default AjvJsonSchemaValidator, two tool schemas with three google-duration fields each, then format: "date_time" validating "not a date". It's a scratch test outside the diff:

$ npx vitest run test/validators/zzprobe.test.ts
== base b022522
PROBE warnings=14 typo-valid=true formats=["google-duration","date_time"]
== PR 0210f84
PROBE warnings=0 typo-valid=true formats=[]
== once-per-name, Set per engine
PROBE warnings=2 typo-valid=true formats=["google-duration","date_time"]

The new tests discriminate, and with the per-engine Set each dialect's suppress test sees exactly two warnings:

$ npx vitest run test/validators          # at 0210f84
 Test Files  3 passed (3)
      Tests  125 passed (125)
$ git apply -R src.diff && npx vitest run test/validators
 Test Files  1 failed | 2 passed (3)
      Tests  5 failed | 120 passed (125)
$ npx vitest run test/validators/ajvUnknownFormat.test.ts --reporter=json   # Set per engine; failures
["unknown formats ('default')"] ['Number of calls: 2']
["unknown formats ('2020-12')"] ['Number of calls: 2']
["unknown formats ('2019-09')"] ['Number of calls: 2']
["unknown formats ('draft-07')"] ['Number of calls: 2']
["unknown formats ('draft-06')"] ['Number of calls: 2']

@felixweinberger, this is a policy call more than a code one. I would keep one line per format name for the typo signal; do you want that, or should unknown formats stay silent? The answer should bind the open v1.x fix in #2898 too.

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Oct 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v1.x] Unknown custom formats spam console on listTools (e.g. google-duration)

2 participants