Skip to content

feat(ai-core): support JSON Schema union types in ToolRequestParameterProperty#17576

Open
kaikongbj wants to merge 2 commits into
eclipse-theia:masterfrom
kaikongbj:feat/json-schema-union-type-support
Open

feat(ai-core): support JSON Schema union types in ToolRequestParameterProperty#17576
kaikongbj wants to merge 2 commits into
eclipse-theia:masterfrom
kaikongbj:feat/json-schema-union-type-support

Conversation

@kaikongbj

@kaikongbj kaikongbj commented May 28, 2026

Copy link
Copy Markdown

Summary

This PR adds support for JSON Schema union types in the ToolRequestParameterProperty interface and its type guard function isToolRequestParameterProperty. This enables MCP tools with union type schemas (e.g., type: ["string", "null"]) to work correctly in Theia.

Problem

When MCP tools include JSON Schema with union types (where type is an array like ["string", "null"]), Theia's isToolRequestParameterProperty validation function rejects these schemas, causing tool properties to be dropped.

Solution

  1. Interface Update: Changed ToolRequestParameterProperty.type from string to string | string[] to accept both single types and union types (arrays).

  2. Validator Enhancement: Updated isToolRequestParameterProperty to validate:

    • type as a string (existing behavior, backward compatible)
    • type as an array of strings (new union type support)

Related

This PR complements the SDK/zod layer fix by adding type-level support in language-model.ts.

Backward Compatibility

This change is fully backward compatible:

  • Single string type values continue to work as before
  • JSON Schema standard compliant (type can be string or array per specification)
  • Does not affect existing anyOf support

Testing

The change enables MCP tools that declare union type schemas to be validated and used correctly, without dropping properties whose type is an array of strings.


Signed-off-by: kaikongbj kaikongbj@github.com

…rProperty

This change adds support for JSON Schema union types where the 'type'
field can be an array of strings (e.g., type: ['string', 'null'])
instead of just a single string.

Changes:
- Updated ToolRequestParameterProperty interface to accept string | string[]
- Enhanced isToolRequestParameterProperty validator to check array types

Fixes eclipse-theia#16615 - complements PR eclipse-theia#16780 which fixed SDK/zod layer

This enables MCP tools with union type schemas to work correctly in Theia.
@github-project-automation github-project-automation Bot moved this to Waiting on reviewers in PR Backlog May 28, 2026
@ndoschek

ndoschek commented Jun 9, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution!
Before we look at this in detail, could you please:

  1. Rebase onto current master. The branch dates back to April 2025, so there are some conflicts in the meantime.
  2. Please use our repo's PR description template (.github/PULL_REQUEST_TEMPLATE.md) as we use those sections for our automated changelog generation.

Also, the current description only covers the ToolRequestParameterProperty union-type change, but the diff also includes a few unrelated changes that aren't mentioned.
It would be easier to review if either the description is updated to cover all of these, or the PR is split so each concern can be reviewed independently. The SSE transport and the resource API in particular feel like they deserve their own PRs.
Thanks!

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

Labels

None yet

Projects

Status: Waiting on reviewers

Development

Successfully merging this pull request may close these issues.

3 participants