Skip to content

Conversation

@shaharluftig-exp
Copy link

Summary

This PR fixes an issue where JSON schemas containing $ref references were not properly resolved before being converted to Zod schemas in the McpClientTool. This was causing validation errors when using schemas with $ref definitions.

Changes made:

  • Added schema dereferencing step in McpClientTool before Zod conversion
  • Ensures all $ref references are properly resolved to their actual schema definitions
  • Handles both internal references (#/definitions/...) and nested $ref structures
  • Prevents validation errors when using complex JSON schemas with references

How to test:

  1. Create a workflow with a node that uses JSON schema validation
  2. Use a schema with $ref like:
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "user": { "$ref": "#/definitions/user" }
      },
      "definitions": {
        "user": {
          "type": "object",
          "properties": {
            "name": { "type": "string" },
            "age": { "type": "number" }
          }
        }
      }
    }
  3. Verify that the schema is properly resolved and validation works correctly
  4. Test with nested $ref and circular reference cases to ensure proper error handling

Related Linear tickets, Github issues, and Community forum posts

Closes #15603

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@CLAassistant
Copy link

CLAassistant commented May 27, 2025

CLA assistant check
All committers have signed the CLA.

@n8n-assistant n8n-assistant bot added community Authored by a community member in linear Issue or PR has been created in Linear for internal review labels May 27, 2025
@Joffcom
Copy link
Member

Joffcom commented May 27, 2025

Hey @shaharluftig-exp,

Thanks for the PR, We have created "GHC-2196" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic reviewed 3 files and found no issues. Review PR in cubic.dev.

@dana-gill dana-gill requested a review from ShireenMissi May 28, 2025 08:59
@ShireenMissi
Copy link
Contributor

@cubic-dev-ai please review

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Dec 19, 2025

@cubic-dev-ai please review

@ShireenMissi I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

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

Labels

community Authored by a community member in linear Issue or PR has been created in Linear for internal review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI Agent to MCP Client Node Invalid Request Issue

4 participants