aminghadersohi commented on code in PR #40906:
URL: https://github.com/apache/superset/pull/40906#discussion_r3404142755
##########
superset/mcp_service/server.py:
##########
@@ -619,14 +619,39 @@ 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,
Review Comment:
Thanks @gabotorresruiz, good catch — verified your read against fastmcp
3.4.2: `query: str | None` does emit `{"anyOf": [{"type": "string"}, {"type":
"null"}]}` with no top-level `type`, the exact shape `_fix_call_tool_arguments`
exists to flatten.
Addressed in 25accbbde30e65ea5e7c8a3772c9b1a558792725:
- Added `_fix_search_tool_query`, mirroring `_fix_call_tool_arguments`,
which flattens the advertised `query` schema to a plain `{"type": "string",
"default": null}`. Only the advertised schema changes — FastMCP still validates
calls against the function signature, so omitting `query` remains valid.
- Strengthened `test_search_tool_query_is_optional_in_schema` per your
suggestion: it asserts `query` has a concrete `type: string` and no `anyOf`.
--
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]