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

   ### SUMMARY
   `search_tools` (the synthetic tool-search entry point) is typed `str | 
list[dict]`, so FastMCP advertises an `outputSchema` for it when 
`MCP_STRUCTURED_OUTPUT_ENABLED` is on. MCP clients reject a successful call 
whose `structuredContent` is missing or does not satisfy that schema ("Tool 
search_tools has an output schema but did not return structured content"). A 
report described this for a caller who can only view dashboards.
   
   I could not reproduce the failure on current `master`, so this PR changes no 
runtime code. It adds the missing end-to-end coverage so a regression would be 
caught:
   
   - Serves the real tool catalog behind the production middleware list and the 
tool-search transform, over the real streamable-HTTP ASGI stack.
   - Calls `search_tools` as a dashboards-only caller (dashboard, chart and 
dataset read only) and as a caller with no permissions, for both the `bm25` and 
`regex` strategies, with no query, an empty query, a matching query, and a 
no-match query (empty result).
   - Validates `structuredContent` against the `outputSchema` advertised in 
`tools/list`, and asserts write/SQL tools are never offered to the restricted 
caller.
   - With structured output disabled, asserts neither the schema nor 
`structuredContent` is present.
   
   Checked on fastmcp 4.1.2 / mcp 2.3.0 and on fastmcp 3.4.7 / mcp 1.29.1 (both 
within the supported range). Both advertise the schema and return `{"result": 
[...]}` (including `{"result": []}`) for every case above. As a check that the 
test can fail, replacing an empty search result with `None` makes the 
empty-result cases fail on the missing `structuredContent`.
   
   Paths compared for the same divergence: 
`_filter_tools_by_current_user_permission` (search results) and 
`RBACToolVisibilityMiddleware` (`tools/list`) both call 
`is_tool_visible_to_current_user`, and `ToolResultCompatibilityMiddleware` 
strips the schema and the structured content together when structured output is 
off. None disagreed for the cases above. `call_tool` is a `ToolResult` proxy 
with no `outputSchema`.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A
   
   ### TESTING INSTRUCTIONS
   ```
   pytest tests/unit_tests/mcp_service/test_tool_search_structured_output.py 
tests/unit_tests/mcp_service/test_tool_search_transform.py 
tests/unit_tests/mcp_service/test_mcp_e2e_smoke.py
   ```
   
   ### 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
   - [ ] 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