Skip to content

schema.json: JSONValue rejects non-integer numbers and null that schema.ts allows (affects Remote.extensionsInfo) #57

Open

Description

@Wolfe-Jam

Observed (at 28db12c)

schema.ts defines:

export type JSONValue = string | number | boolean | null | JSONObject | JSONArray;

The generated schema.json has:

"JSONValue": { "anyOf": [
  { "$ref": "#/$defs/JSONObject" },
  { "items": { "$ref": "#/$defs/JSONValue" }, "type": "array" },
  { "type": ["string", "integer", "boolean"] }
] }

Since #55, Remote.extensionsInfo values are JSONObject, so an entry holding a fractional number or a null is valid by schema.ts and invalid by schema.json.

Repro: ajv 8.20 (Ajv2020), schema.json at 28db12c, validating #/$defs/ServerCard, with remotes[0].extensionsInfo set to:

Value Result
{"io.example/limits": {"rate": 3}} valid
{"io.example/limits": {"rate": 0.5}} invalid
{"io.example/keys": {"rotatesAt": null}} invalid

Context: the README makes schema.ts the source of truth and schema.json generated from it. scripts/generate-schema.ts runs typescript-json-schema --defaultNumberType integer. The core spec met the null half of this for Task.ttl (modelcontextprotocol/modelcontextprotocol#2313, fixed in #2408 with @nullable). The core spec's schema/draft/schema.json has the same JSONValue shape.

Question: is the narrower schema.json intended for extensionsInfo values, or should JSONValue keep number and null? Validators that use schema.json (mcp-server-card-check among them, which notes the difference in its README) reject these cards today. Glad to open a PR either way.

—
Drafted by Claude · Approved by James Wolfe

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions