aminghadersohi opened a new pull request, #36271:
URL: https://github.com/apache/superset/pull/36271
### SUMMARY
This PR fixes FastMCP validation errors when Claude Code sends
double-serialized JSON strings as request parameters. All MCP tools using the
`@parse_request` decorator have been updated to accept both string and object
formats.
**Problem:** Claude Code serializes tool requests as JSON strings (e.g.,
`'{"page": 1}'`) instead of native objects, causing FastMCP to fail validation
before the `@parse_request` decorator can parse them.
**Solution:** Updated type hints from `RequestModel` to `str | RequestModel`
for all 19 MCP tools, allowing FastMCP to accept strings while the decorator
handles parsing.
**Changes:**
- Updated 19 MCP tool function signatures to accept `str | RequestModel`
type hints
- Updated test to verify string filters are now properly parsed to objects
- Maintains backward compatibility with native object requests
- Allows `@parse_request` decorator to handle string-to-object conversion
properly
**Affected tools:**
- Chart tools: `list_charts`, `get_chart_info`, `generate_chart`,
`update_chart`, `update_chart_preview`, `get_chart_preview`,
`get_chart_available_filters`
- Dashboard tools: `list_dashboards`, `get_dashboard_info`,
`add_chart_to_existing_dashboard`, `generate_dashboard`,
`get_dashboard_available_filters`
- Dataset tools: `list_datasets`, `get_dataset_info`,
`get_dataset_available_filters`
- SQL Lab tools: `execute_sql`, `open_sql_lab_with_context`
- System tools: `get_instance_info`
- Explore tools: `generate_explore_link`
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend change only
### TESTING INSTRUCTIONS
1. Run the updated test to verify string parsing works:
```bash
pytest
tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py::test_list_dashboards_with_string_filters
-xvs
```
2. Test with Claude Code MCP client:
- Start MCP server
- Call `list_charts` tool with parameters from Claude Code
- Verify no validation errors occur
3. Run pre-commit checks:
```bash
pre-commit run --files superset/mcp_service/*/tool/*.py
tests/unit_tests/mcp_service/dashboard/tool/test_dashboard_tools.py
```
4. Verify all MCP unit tests pass:
```bash
pytest tests/unit_tests/mcp_service/ -xvs
```
### ADDITIONAL INFORMATION
- [ ] Has associated issue: Related to Claude Code issue with
double-serialized requests
- [ ] Required feature flags: None
- [ ] Changes UI: No
- [ ] Includes DB Migration: No
- [ ] Introduces new feature or API: No (bug fix to existing MCP tools)
- [ ] 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]