fix(arcade-mcp-server): put an array's enum on its items, not on the array - #939
Merged
Merged
Conversation
…array A list[Literal[...]] or list[SomeEnum] arrives as one ValueSchema with val_type="array", inner_val_type="string" and enum=[...]. That enum is an allow-list for the elements, but it was copied to the array level, where JSON Schema reads it as "the whole array must equal one of these strings" -- an assertion no array satisfies, not even an empty one. Every MCP client that validates structured output therefore rejected every response from a tool whose output names such a field, with "data/.../<field> must be equal to one of the allowed values". The write had already happened; only the response was lost. Input parameters typed the same way carried the same malformed schema. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
EricGustin
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_value_schema_to_json_schemacopied aValueSchema.enumto the array level whenval_type == "array". On an array that enum is an allow-list for the elements; at the array level JSON Schema reads it as "the whole array must equal one of these strings", which no array satisfies — not even an empty one.Any MCP client that validates structured output rejected every response from a tool whose output names such a field, with
Structured content does not match the tool's output schema: data/.../<field> must be equal to one of the allowed values. The write had already happened upstream; only the response was lost, so the agent could not read its own result. Input parameters typed the same way (list[SomeStrEnum]) carried the same malformed schema.This is the rule the Engine's Go renderer already follows for the same
ValueSchema, so the two paths now publish the same schema for the same tool.Design decisions
Literal/Enumkeeps its enum where it is — only arrays move.Noneappended to an array-level enum by_apply_nullable; the null goes ontype, which is what nullable means.Test plan
Six tests in
libs/tests/arcade_mcp_server/test_convert.py, each failing before the change:test_output_schema_array_enum_lands_on_itemstest_input_schema_array_enum_lands_on_itemstest_output_schema_nullable_array_enum_keeps_elements_non_nulltest_output_schema_list_of_literal_constrains_elements— end to end throughToolCatalogtest_output_schema_list_of_enum_constrains_elements—list[SomeStrEnum], the other source of an array-level enumtest_output_schema_nested_list_of_literal_constrains_elements— the field inside an object output, the shape that actually broke in the wilduv run pytest libs/tests-> 3944 passed, 1 skipped.🤖 Generated with Claude Code
Note
Low Risk
Corrects published JSON Schema for array-of-enum tools; reduces client validation failures with no auth or data-handling changes.
Overview
Fixes MCP tool schema generation so
ValueSchema.enumon array types applies toitems, not the array root. Previously,list[Literal[…]]/list[StrEnum]produced{"type": "array", "enum": [...]}, which JSON Schema interprets as “the entire value must be one of these scalars”—so MCP clients validating structured output rejected otherwise valid tool responses (and the same mistake affected input parameters).Scalar and object enums are unchanged; nullable arrays still use
type: ["array", "null"]without polluting element constraints.arcade-mcp-serveris bumped to 1.31.1, with new unit and end-to-end tests (including nested object fields andToolCatalogpaths).Reviewed by Cursor Bugbot for commit 368a12e. Bugbot is set up for automated code reviews on this repo. Configure here.