aminghadersohi opened a new pull request, #36249:
URL: https://github.com/apache/superset/pull/36249

   ### SUMMARY
   
   This PR adds support for both JSON string and native object formats in MCP 
tool request parameters to handle a Claude Code bug where request objects are 
double-serialized as escaped JSON strings (anthropics/claude-code#5504).
   
   **Key Changes:**
   - Created `@parse_request` decorator in `schema_utils.py` that automatically 
handles string-to-model conversion
   - Applied decorator to all 19 MCP tools (chart, dashboard, dataset, SQL Lab, 
system tools)
   - Added comprehensive test coverage (12 new tests) for the decorator
   - Fixed MyPy type annotations for validator functions in `schema_utils.py`
   
   **Benefits:**
   - Eliminates 5 lines of boilerplate per tool (95 lines total code savings)
   - Handles both async and sync functions automatically  
   - Works with Claude Code while maintaining compatibility with other MCP 
clients
   - Type-safe with proper error handling and validation
   
   The decorator seamlessly converts string requests to Pydantic models before 
tool execution, allowing MCP tools to work with clients that double-serialize 
JSON (like Claude Code) as well as clients that send native objects.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A - Backend change only
   
   ### TESTING INSTRUCTIONS
   
   1. Run the new tests:
   ```bash
   pytest 
tests/unit_tests/mcp_service/utils/test_schema_utils.py::TestParseRequestDecorator
 -xvs
   ```
   
   2. Verify all 12 decorator tests pass
   3. Run pre-commit checks on changed files:
   ```bash
   pre-commit run --files superset/mcp_service/utils/schema_utils.py 
superset/mcp_service/*/tool/*.py
   ```
   
   4. Verify MCP tools still work with both string and object inputs
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue: anthropics/claude-code#5504 (external repo)
   - [ ] Required feature flags: None
   - [ ] Changes UI: No
   - [ ] Includes DB Migration: No
   - [x] Introduces new feature or API: Yes - new `@parse_request` decorator 
utility
   - [ ] Removes existing feature or API: No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to