Skip to content

Perplexity AI MCP #131

Description

@Rettbull112

This error occurs because your JSON Schema uses the Draft-07 dialect ("$schema": "http://json-schema.org/draft-07/schema#"), but the Ajv validator instance you're using is configured to only support JSON Schema 2020-12. stackoverflow

Why this happens

Ajv 8.x defaults to JSON Schema 2020-12, while older versions (Ajv 6.x) default to Draft-07. When you declare a Draft-07 schema but use a 2020-12 validator without proper configuration, Ajv rejects the $schema keyword as an "unsupported dialect." stackoverflow

How to fix it

You have two options:

Option 1: Use a pre-configured Ajv instance for Draft-07

If you want to keep using Draft-07 schemas, import and instantiate Ajv with the Draft-07 configuration:

// For Ajv 8.x with Draft-07 support
import Ajv from 'ajv/dist/2020'; // or appropriate import
const ajv = new Ajv({ strict: false });
// Add the draft-07 metaschema explicitly
ajv.addSchema(require('ajv/dist/refs/json-schema-draft-07.json'));

Or use the dedicated Draft-07 build if available in your Ajv version. stackoverflow

Option 2: Migrate your schema to JSON Schema 2020-12

Update your schema's $schema declaration to use the 2020-12 dialect:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  ...
}

Note that 2020-12 schemas don't use the trailing # in the URI (unlike Draft-07). jsonic

If your schema uses tuple validation (array form of items), you'll also need to:

  • Rename items (when it's an array) to prefixItems
  • Replace additionalItems with items or items: false jsonic

Option 3: Configure Ajv to accept multiple dialects

You can configure Ajv to be more permissive with schema dialects:

import Ajv2020 from 'ajv/dist/2020';
const ajv = new Ajv2020({ strict: false, strictSchema: false });

This disables strict mode checks that would otherwise reject unknown keywords or dialects. jsonic

Quick checklist

  • Check your Ajv version (npm list ajv)
  • Verify your import statement matches your intended draft (e.g., ajv/dist/2020 for 2020-12) stackoverflow
  • Either update your schema's $schema URI or configure Ajv to support Draft-07
  • Test validation with sample data after making changes

Would you like help with a specific migration step or configuration?

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