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

   ### SUMMARY
   
   The `@parse_request` decorator was originally added as a workaround for a 
Claude Code double-serialization bug 
([fastmcp#5504](https://github.com/jlowin/fastmcp/issues/5504)) that wrapped 
tool parameters in a confusing `anyOf [string, object]` schema under a 
`request` key. This caused two problems reported by users:
   
   1. **LLMs frequently forgot the `request` wrapper**, sending flat params 
like `{"chart_id": 62}` instead of `{"request": {"identifier": 62}}`, causing 
validation errors before self-correcting
   2. **LLMs used wrong parameter names** (e.g. `title` vs `dashboard_title`) 
because the `anyOf` schema was unclear to models
   
   With FastMCP 3.1, `Tool.from_function` handles Pydantic `BaseModel` 
parameters natively, generating clean JSON schemas. This makes `@parse_request` 
unnecessary.
   
   **Changes:**
   - Remove `@parse_request` decorator and its import from all 19 tool files
   - Add `Context` injection in `mcp_auth_hook` (previously handled by 
`@parse_request`) via `_needs_ctx` detection and `_inject_ctx` helper
   - Add default value for `get_instance_info`'s empty request model 
(previously handled by `@parse_request`)
   - Remove `from __future__ import annotations` from `execute_sql` and 
`save_sql_query` (string annotations prevent FastMCP from recognizing the 
`Context` parameter, causing silent tool registration failures)
   
   **Schema improvement (before → after):**
   ```
   # Before: confusing anyOf wrapping
   "request": {"anyOf": [{"type": "string"}, {"$ref": 
"#/$defs/ListChartsRequest"}]}
   
   # After: clean object type
   "request": {"properties": {"page": ..., "page_size": ..., ...}, "type": 
"object"}
   ```
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A - Backend-only change affecting MCP tool JSON schemas.
   
   ### TESTING INSTRUCTIONS
   
   1. Start the MCP service (`python -m superset.mcp_service.server`)
   2. Connect with an MCP client (Claude Code, Claude Desktop, etc.)
   3. Verify tools work correctly:
      - `get_instance_info` (no args needed)
      - `list_charts` with `{"request": {"page": 1, "page_size": 5}}`
      - `execute_sql` with `{"request": {"database_id": 1, "sql": "SELECT 1"}}`
      - `save_sql_query` with `{"request": {"database_id": 1, "label": "Test", 
"sql": "SELECT 1"}}`
   4. Verify tool schemas no longer contain `anyOf [string, object]` patterns
   5. Verify all 20 tools register without errors in startup logs
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [x] Removes existing feature or API


-- 
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