codeant-ai-for-open-source[bot] commented on code in PR #40906:
URL: https://github.com/apache/superset/pull/40906#discussion_r3404401155
##########
superset/mcp_service/server.py:
##########
@@ -509,6 +509,27 @@ def _fix_call_tool_arguments(tool: Any) -> Any:
return tool
+def _fix_search_tool_query(tool: Any) -> Any:
+ """Fix anyOf schema in search_tools ``query`` for MCP bridge compatibility.
+
+ The optional ``query: str | None`` parameter emits an ``anyOf`` JSON
+ Schema with no top-level ``type``. Some MCP bridges (mcp-remote,
+ Claude Desktop) don't handle ``anyOf`` and strip it, leaving the field
+ typeless — the same failure mode ``_fix_call_tool_arguments`` guards
+ against. Replaces the ``anyOf`` with a flat ``type: string``.
+
+ Only the advertised schema changes; FastMCP validates calls against
+ the function signature, so omitting ``query`` remains valid.
+ """
+ if "query" in (props := (tool.parameters or {}).get("properties", {})):
+ props["query"] = {
+ "default": None,
+ "description": "Natural language query. Omit to list all available
tools.",
+ "type": "string",
+ }
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not flag `default: null` in JSON Schema tool-schema patches when it is
used as an annotation keyword and intentionally matches the existing MCP tool
schema shape in this file.
**Applied to:**
- `superset/mcp_service/server.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
##########
superset/mcp_service/server.py:
##########
@@ -619,14 +640,40 @@ async def call_tool(
)
-def _create_search_transform(
+def _create_search_transform( # noqa: C901
*,
strategy: str,
kwargs: dict[str, Any],
make_normalizing_call_tool: Callable[[Any], Any],
) -> Any:
"""Create the configured search transform with tool-permission
filtering."""
from fastmcp.server.context import Context
+ from fastmcp.tools.base import Tool
+
+ def _make_optional_query_search_tool(transform: Any) -> Any:
+ """Create search tool with optional query — returns all tools when
omitted."""
+
+ async def search_tools(
+ query: Annotated[
+ str | None,
+ "Natural language query. Omit to list all available tools.",
+ ] = None,
+ ctx: Context = None,
+ ) -> str | list[dict[str, Any]]:
+ """Search for tools using natural language.
+
+ Returns matching tool definitions ranked by relevance.
+ If no query is provided, returns all available tools.
+ """
+ hidden = await transform._get_visible_tools(ctx)
+ if not query:
+ results = hidden
+ else:
+ results = await transform._search(hidden, query)
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not flag `search_tools` empty-string handling in
`superset/mcp_service/server.py`; treating `{"query": ""}` the same as an
omitted query is intentional fail-open behavior and should return the visible
catalog.
**Applied to:**
- `superset/mcp_service/server.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]