Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Ajv defaults: non-standard "format": "json" in third-party schemas (e.g. Notion) warns twice per property — register it like #2601

Aperta Adatta ai principianti
#2,854 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, typescript

Direzione di ricerca

Esamina la funzione createDefaultAjvInstance nel modulo validatore dell'SDK. Il problema riguarda l'aggiunta di un formato no-op per 'json' alle istanze Ajv per sopprimere gli avvisi. Controlla come 'google-duration' è stato registrato nell'issue #2601 come riferimento. La modifica implica l'alterazione della configurazione del validatore predefinito per includere ajv.addFormat('json', true) per tutti e tre i motori del dialetto (Ajv2020, Ajv2019, Ajv). Dopo aver apportato la modifica, testa con il codice di riproduzione fornito per assicurarti che gli avvisi siano spariti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Context

This is the same class of noise as #2601 (google-duration), with an instance found in the wild.

The Notion MCP server's post-page tool annotates two string properties with "format": "json" — a value that is defined neither by JSON Schema nor by ajv-formats. Compiling that inputSchema through the default validator instances of @modelcontextprotocol/client@2.0.0 (createDefaultAjvInstance: { strict: false, allErrors: true } + ajv-formats) logs, per compile:

unknown format "json" ignored in schema at path "#/properties/icon"
unknown format "json" ignored in schema at path "#/properties/icon"
unknown format "json" ignored in schema at path "#/properties/cover"
unknown format "json" ignored in schema at path "#/properties/cover"

Two lines per property, because allErrors: true makes Ajv compile the format check twice — i.e. connecting to that one server costs 4 lines of client-side warning output per session.

It is not purely cosmetic: with Ajv's own defaults (strict: true) the same schema throws during compile (Error: unknown format "json" ignored in schema at path "#/properties/icon"), so any integrator who wants a strict validator cannot load that tool.

Ask

  1. Register json as a no-op format (ajv.addFormat("json", true)) in createDefaultAjvInstance, for all three dialect engines, alongside the google-duration registration proposed in #2601; or
  2. Downgrade the unknown-format message to debug-level output, so quirks in third-party schemas don't surface as user-visible warnings.

Note on custom validator providers

Consumers that pass their own Ajv instance to AjvJsonSchemaValidator bypass the default instances entirely, so registering formats there does not help them — e.g. a downstream extension that constructs its own validator provider still gets the warnings until it registers json itself. Worth a line in the validator docs.

Environment / reproduction

@modelcontextprotocol/client 2.0.0 · ajv 8.20.0 · node 24.12.0

import Ajv2020 from "ajv/dist/2020.js";
import addFormats from "ajv-formats";

const ajv = new Ajv2020({ strict: false, allErrors: true });  // mirrors createDefaultAjvInstance
addFormats(ajv);

ajv.compile({
  type: "object",
  properties: {
    icon:  { type: "string", format: "json" },
    cover: { type: "string", format: "json" },
  },
});
// -> the four "unknown format" lines above

Filed after reproducing the behaviour locally with the reporter's coding agent; outputs above are from that run and can be provided on request.

Lingua principale
TypeScript
Stelle
13.4k
Fork
2.2k
Merge medio
4g 18h
PR unite (30g)
6

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/typescript-sdk

Tutte le issue di modelcontextprotocol/typescript-sdk

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.