codeant-ai-for-open-source[bot] commented on code in PR #38641:
URL: https://github.com/apache/superset/pull/38641#discussion_r2939144745
##########
superset-core/src/superset_core/mcp/decorators.py:
##########
@@ -37,6 +37,13 @@ def another_tool(value: int) -> str:
from typing import Any, Callable, TypeVar
+try:
+ from mcp.types import ToolAnnotations
+except (
+ ImportError
+): # MCP extras may not be installed in superset-core-only environments
+ ToolAnnotations = Any
Review Comment:
**Suggestion:** The fallback `ToolAnnotations = Any` is not callable, so in
environments where `mcp.types` is unavailable, every `ToolAnnotations(...)`
usage in tool modules raises `TypeError: Any cannot be instantiated` at import
time. Replace the fallback with a callable lightweight type (for example
`dict`) so annotation objects can still be constructed when MCP extras are
missing. [type error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ `superset mcp run` fails during module import.
- ❌ All annotated MCP tools fail registration path.
- ⚠️ Optional-dependency fallback does not degrade gracefully.
```
</details>
```suggestion
ToolAnnotations = dict
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Use an environment where `mcp.types` is unavailable (the fallback path is
explicitly
intended in `superset-core/src/superset_core/mcp/decorators.py:40-45`).
2. Start MCP via CLI: `superset mcp run`, which executes `run()` in
`superset/cli/mcp.py:32-37` and imports `superset.mcp_service.server` at
`superset/cli/mcp.py:35`.
3. `superset/mcp_service/server.py:32` imports `superset.mcp_service.app`,
and
`superset/mcp_service/app.py:395-429` imports all MCP tool modules.
4. Tool modules instantiate `ToolAnnotations(...)` at import time (example:
`superset/mcp_service/system/tool/health_check.py:39`; same pattern found
across all 20
tools), but fallback `ToolAnnotations = Any` from `decorators.py:45` raises
`TypeError:
Any cannot be instantiated` (verified by runtime check), so module import
and MCP startup
fail.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-core/src/superset_core/mcp/decorators.py
**Line:** 45:45
**Comment:**
*Type Error: The fallback `ToolAnnotations = Any` is not callable, so
in environments where `mcp.types` is unavailable, every `ToolAnnotations(...)`
usage in tool modules raises `TypeError: Any cannot be instantiated` at import
time. Replace the fallback with a callable lightweight type (for example
`dict`) so annotation objects can still be constructed when MCP extras are
missing.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38641&comment_hash=43ef5dab124bc0dfb25874c189a83f857a02e4489bcdac068fd697399e6fbcbb&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38641&comment_hash=43ef5dab124bc0dfb25874c189a83f857a02e4489bcdac068fd697399e6fbcbb&reaction=dislike'>👎</a>
--
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]