Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions superset/mcp_service/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ MCP_USER_RESOLVER = None # Custom function to extract username from JWT
# RBAC
MCP_RBAC_ENABLED = True # Enable permission checking (default: True)

# Request Parsing
MCP_PARSE_REQUEST_ENABLED = True # Accept JSON string requests (workaround for client bugs)

# Response Caching (optional, uses in-memory store by default; Redis when MCP_STORE_CONFIG enabled)
MCP_CACHE_CONFIG = {
Expand Down
3 changes: 1 addition & 2 deletions superset/mcp_service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ def get_default_instructions(branding: str = "Apache Superset") -> str:

Input format:
- Tool request parameters accept structured objects (dicts/JSON)
- When MCP_PARSE_REQUEST_ENABLED is True (default), string-serialized JSON is also
accepted as input, which works around double-serialization bugs in some MCP clients
- FastMCP 3.1+ handles Pydantic BaseModel parameters natively

Feature Availability:
- Call get_instance_info to discover accessible menus for the current user.
Expand Down
45 changes: 17 additions & 28 deletions superset/mcp_service/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ def _get_app_context_manager() -> AbstractContextManager[None]:
is_async = inspect.iscoroutinefunction(tool_func)

# Detect if the original function expects a ctx: Context parameter.
# If so, we inject it via get_context() at call time so tool functions
# don't need @parse_request to handle Context injection.
# If so, we inject it via get_context() at call time.
from fastmcp import Context as FMContext

_tool_sig = inspect.signature(tool_func)
Expand Down Expand Up @@ -696,33 +695,23 @@ def sync_wrapper(*args: Any, **kwargs: Any) -> Any:
# Copy docstring from original function (not wrapper, which may have lost it)
new_wrapper.__doc__ = tool_func.__doc__

# Set __signature__ from the original function, but:
# 1. Remove ctx parameter - FastMCP tools don't expose it to clients
# 2. Skip if original has *args (parse_request output has its own handling)
has_var_positional = any(
p.kind == inspect.Parameter.VAR_POSITIONAL
for p in _tool_sig.parameters.values()
# Set __signature__ from the original function, removing ctx parameter
# since FastMCP tools don't expose it to clients.
new_params = []
for _name, param in _tool_sig.parameters.items():
# Skip ctx parameter - FastMCP tools don't expose it to clients
if param.annotation is FMContext or (
hasattr(param.annotation, "__name__")
and param.annotation.__name__ == "Context"
):
continue
new_params.append(param)
new_wrapper.__signature__ = _tool_sig.replace( # type: ignore[attr-defined]
parameters=new_params
)

if not has_var_positional:
# For functions without *args, preserve signature but remove ctx
new_params = []
for _name, param in _tool_sig.parameters.items():
# Skip ctx parameter - FastMCP tools don't expose it to clients
if param.annotation is FMContext or (
hasattr(param.annotation, "__name__")
and param.annotation.__name__ == "Context"
):
continue
new_params.append(param)
new_wrapper.__signature__ = _tool_sig.replace( # type: ignore[attr-defined]
parameters=new_params
)

# Also remove ctx from annotations to match signature
if "ctx" in new_wrapper.__annotations__:
del new_wrapper.__annotations__["ctx"]
# For functions with *args (parse_request output), the signature
# is already set by parse_request without ctx.
# Also remove ctx from annotations to match signature
if "ctx" in new_wrapper.__annotations__:
del new_wrapper.__annotations__["ctx"]

return new_wrapper # type: ignore[return-value]
6 changes: 0 additions & 6 deletions superset/mcp_service/mcp_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@
# per RFC 6750 Section 3.1. This flag NEVER affects client-facing output.
MCP_JWT_DEBUG_ERRORS = False

# Enable parse_request decorator for MCP tools.
# When True (default), tool requests are automatically parsed from JSON strings
# to Pydantic models, working around a Claude Code double-serialization bug
# (https://github.com/anthropics/claude-code/issues/5504).
# Set to False to disable and let FastMCP handle request parsing natively.
MCP_PARSE_REQUEST_ENABLED = True

# Session configuration for local development
MCP_SESSION_CONFIG = {
Expand Down
Loading
Loading