Skip to content

Fix Gradio Playground MCP argument parsing - #1081

Open
lakshayxi wants to merge 1 commit into
huggingface:mainfrom
lakshayxi:fix-gradio-mcp-arguments
Open

Fix Gradio Playground MCP argument parsing#1081
lakshayxi wants to merge 1 commit into
huggingface:mainfrom
lakshayxi:fix-gradio-mcp-arguments

Conversation

@lakshayxi

@lakshayxi lakshayxi commented Aug 16, 2026

Copy link
Copy Markdown

Fixes #1080.

Summary

  • Parse JSON string arguments for MCP call_tool actions at the web preprocessing boundary.
  • Preserve strict deserialization for normal typed payloads.
  • Keep invalid, non-object, and malformed JSON subject to existing Pydantic validation.
  • Add regression coverage for both serialization behavior and the /web/step path.
  • Remove the stale Gradio MCP workaround from AGENTS.md.

Tests

  • PYTHONPATH=src:envs uv run pytest tests/core/ -q
  • PYTHONPATH=src:envs uv run pytest tests/ -q
  • uv run usort check src/openenv/core/env_server/serialization.py tests/core/test_mcp/test_mcp_types.py tests/core/test_web_interface_mcp.py
  • uv run ruff format src/openenv/core/env_server/serialization.py tests/core/test_mcp/test_mcp_types.py tests/core/test_web_interface_mcp.py --check
  • uv run ruff check src/openenv/core/env_server/serialization.py tests/core/test_mcp/test_mcp_types.py tests/core/test_web_interface_mcp.py

Full suite: 1641 passed, 129 skipped.


Note

Low Risk
Scoped to the web preprocessing deserialization path with clear validation boundaries and broad test coverage; no auth or data-model changes.

Overview
Fixes Gradio Playground and POST /web/step failures when MCP call_tool actions send arguments as a JSON string (textbox) instead of an object.

deserialize_action_with_preprocessing now JSON-decodes string arguments for type: call_tool into a dict on a copy of the payload (input is not mutated). deserialize_action stays strict—string arguments still fail validation. Malformed JSON, arrays, and scalar JSON strings still raise ValidationError.

Regression tests cover serialization edge cases and an integration test on /web/step. AGENTS.md drops the old workaround note about the broken Playground Step form.

Reviewed by Cursor Bugbot for commit 9b765f8. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

[Minor Bug] Gradio Playground Step rejects MCP arguments JSON as a string

1 participant