Skip to content

fix: map checkbox and json_object types in MCP schema publishing#34226

Open
majiayu000 wants to merge 1 commit intolanggenius:mainfrom
majiayu000:fix/issue-34199-mcp-input-type-mappings
Open

fix: map checkbox and json_object types in MCP schema publishing#34226
majiayu000 wants to merge 1 commit intolanggenius:mainfrom
majiayu000:fix/issue-34199-mcp-input-type-mappings

Conversation

@majiayu000
Copy link
Copy Markdown
Contributor

Fixes #34199

Summary

convert_input_form_to_parameters was mapping every input type to "string" in the JSON Schema it publishes to MCP clients. CHECKBOX and JSON_OBJECT inputs lost their real types, so MCP clients couldn't render proper boolean toggles or object editors.

Added two elif branches after the existing SELECT handling:

  • VariableEntityType.CHECKBOX"boolean"
  • VariableEntityType.JSON_OBJECT"object", forwarding properties/required/additionalProperties from the entity's json_schema when present

SELECT wasn't changed since it already maps to "string" + "enum", which is correct per JSON Schema. The dropdown rendering issue from the original report is a frontend concern tracked in #23285.

Screenshots

N/A (backend-only schema change)

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

convert_input_form_to_parameters was missing branches for CHECKBOX
and JSON_OBJECT, causing them to fall through without a type. Add
boolean mapping for CHECKBOX and object mapping for JSON_OBJECT,
with optional json_schema forwarding for field-level validation.

Signed-off-by: majiayu000 <1835304752@qq.com>
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

@majiayu000 majiayu000 marked this pull request as ready for review March 28, 2026 14:24
@majiayu000 majiayu000 requested a review from Nov1c444 as a code owner March 28, 2026 14:24
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP input types

1 participant