Back Home

GitHub Repo

Dify Community Proposes MCP Type Fix for Arrays Converted to Strings in Nested Schemas

A report on October 19 says certain nested MCP tool schemas can cause valid arrays to be converted to strings, sending remote tools the wrong type. A fix proposal and regression tests were submitted the same day, but the change has not been merged and its impact on released versions remains unconfirmed.

The original uploader was Ggia at Greek Wikipedia. · CC BY-SA 2.5 · Image source
zh-Hant

On October 19, the Dify community reported a gap in how MCP tool parameter types are determined for nested schemas: when an anyOf allowing a string or an array is wrapped in an allOf, a valid array may be converted to a string before the call. The report concerns a self-hosted source-code version and identifies main-branch commit 96202aa; it does not establish that all released versions are affected. Issue report

In the reproduction case, the domain field allows either a single string or an array of strings. After receiving ["light", "cover"] as input, the converter instead determines the parameter type to be string and does not preserve input_schema. The subsequent call flow therefore sends the string representation of a Python list instead of a JSON array. This means that even when upstream supplies parameters matching the original schema, an intermediate conversion can change the data type the tool actually receives. Reproduction details

The case involves the semantics of schema composition. The official JSON Schema documentation says anyOf means that at least one subschema must match, while allOf requires every subschema to match. A fix therefore cannot simply search deeply for multiple types; it must also account for intersecting constraints. Otherwise, schemas that initially allow multiple types and are then narrowed by other constraints may still be misclassified. JSON Schema composition rules

A fix was proposed the same day in PR #44322. It traverses nested composition structures and calculates the intersection of allOf constraints, preserving the original value when the schema permits multiple JSON types. The author says the regression tests cover both branch orders, scalars and arrays, and cases where an intersection narrows to a single type. A total of 72 related unit tests passed, according to the proposal author; these results are not a guarantee of an official release. Fix proposal

For engineers integrating MCP tools, this case suggests extending validation to the parameters received by remote tools. Check nested compositions and array inputs against your own tool schemas, and compare JSON types before and after transmission. As of this review, the proposal is still awaiting code-owner review. Track its merge status, release version, and tests covering additional schema combinations; the current fix should not be treated as full support for every JSON Schema case.

Sources

  1. MCP nested union schemas stringify valid list parameters — Dify Issue #44321
  2. fix(api): preserve nested MCP union parameter types — PR #44322
  3. Boolean JSON Schema combination