Skip to content

Keep all MCP enum choices when their names normalize alike - #746

Open
unknowlei wants to merge 1 commit into
browser-use:mainfrom
unknowlei:fix/mcp-enum-values
Open

unknowlei wants to merge 1 commit into
browser-use:mainfrom
unknowlei:fix/mcp-enum-values

Conversation

@unknowlei

@unknowlei unknowlei commented Oct 2, 2026 •

Copy link
Copy Markdown

MCP enum choices such as read-only, read_only, and READ_ONLY currently end up with the same Python member name. Earlier choices get overwritten, so valid tool arguments disappear from the schema and fail validation.

This gives conflicting member names a unique suffix without changing the values sent to the tool. It also handles collisions with generated names and avoids creating reserved Enum names when a value starts with an underscore.

I added nine focused tests for accepted values, rejected values, JSON schema output, and enums inside arrays. The original collision was reproduced before the fix, and all nine tests now pass using the real resolver and Pydantic. The test launcher stubs the unrelated browser and MCP imports; these are isolated schema tests, not browser or MCP-server integration tests.


Summary by cubic

Preserves every MCP enum choice even when their names normalize to the same Python member name, so earlier choices are no longer overwritten and valid tool arguments remain in the schema.

Bug Fixes

  • Appends a unique suffix to conflicting member names without changing the values sent to the tool.
  • Handles collisions with generated names and avoids reserved enum names when a value starts with an underscore.
  • Adds nine tests covering accepted and rejected values, JSON schema output, and enums inside arrays.

Written for commit 7bd9089. Summary will update on new commits.

Review in cubic

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants