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

   ### SUMMARY
   
   Add BM25SearchTransform from FastMCP 3.1.0 to reduce the initial tool 
catalog sent to LLM clients. The MCP service sends all ~25 tool definitions 
(~40k tokens) on connect. This wires in FastMCP's new `BM25SearchTransform` so 
LLMs see only 2 synthetic tools (`search_tools` + `call_tool`) plus 2 pinned 
tools (`health_check`, `get_instance_info`) on connect, discovering other tools 
on-demand via natural language search.
   
   **Changes:**
   - Upgrade `fastmcp` from `2.14.3` to `>=3.1.0,<4.0`
   - Add `MCP_TOOL_SEARCH_CONFIG` to `mcp_config.py` (follows existing config 
patterns)
   - Add `_apply_tool_search_transform()` to `server.py` and wire into both 
code paths
   - Add unit tests
   
   **Impact:**
   - ~70-80% reduction in initial context tokens (~40k → ~5-8k)
   - 1 extra round-trip for LLM to discover tools via `search_tools` before 
calling
   - No changes to existing tool implementations, schemas, or auth
   
   **Rollback:** Set `MCP_TOOL_SEARCH_CONFIG["enabled"] = False` in 
`superset_config.py`
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — backend change only, no UI impact.
   
   ### TESTING INSTRUCTIONS
   
   1. Install: `pip install "fastmcp>=3.1.0,<4.0"`
   2. Start server: `python -m superset.mcp_service.server`
   3. Connect MCP client → should see only `search_tools`, `call_tool`, 
`health_check`, `get_instance_info`
   4. Call `search_tools(query="chart")` → should return chart-related tools 
with full schemas
   5. Call `call_tool(name="list_charts", arguments={})` → should work
   6. Run tests: `python -m pytest 
tests/unit_tests/mcp_service/test_tool_search_transform.py -v`
   7. Disable test: Set `MCP_TOOL_SEARCH_CONFIG["enabled"] = False` → verify 
all 25 tools appear again
   
   ### ADDITIONAL INFORMATION
   
   - [x] Introduces new feature or API
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] 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