codeant-ai-for-open-source[bot] commented on code in PR #37216:
URL: https://github.com/apache/superset/pull/37216#discussion_r2708406746
##########
superset/mcp_service/server.py:
##########
@@ -55,21 +65,83 @@ def configure_logging(debug: bool = False) -> None:
logging.info("🔍 SQL Debug logging enabled")
+def create_event_store(config: dict[str, Any] | None = None) -> Any | None:
+ """
+ Create an EventStore for MCP session management.
+
+ For multi-pod deployments, uses Redis-backed storage to share session state
+ across pods. For single-pod deployments, returns None (uses in-memory).
+
+ Args:
+ config: Optional config dict. If None, reads from MCP_STORE_CONFIG.
+
+ Returns:
+ EventStore instance if Redis URL is configured, None otherwise.
+ """
+ if config is None:
+ config = MCP_STORE_CONFIG
+
+ redis_url = config.get("CACHE_REDIS_URL")
+ if not redis_url:
+ logging.info("EventStore: Using in-memory storage (single-pod mode)")
+ return None
+
+ try:
+ from fastmcp.server.event_store import EventStore
+
+ # Get prefix from config (allows Preset to customize for multi-tenancy)
+ # Default prefix prevents key collisions in shared Redis environments
+ prefix = config.get("event_store_prefix", "mcp_events_")
+
+ # Create wrapped Redis store with prefix for key namespacing
+ redis_store = _create_redis_store(config, prefix=prefix, wrap=True)
Review Comment:
**Suggestion:** Passing keyword arguments (`prefix` and `wrap`) directly to
`_create_redis_store` may not match its signature and will raise a TypeError at
runtime if that helper doesn't accept those keywords; instead pass a plain
config mapping (or set the prefix in a config copy) so the helper reads the
prefix from config and avoid unexpected keyword arguments. [type error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ FastMCP multi-pod server startup fails.
- ❌ Redis-backed session sharing disabled.
- ⚠️ K8s multi-replica deployments unstable.
- ⚠️ Affects MCP_EVENT_STORE_CONFIG enabled users.
```
</details>
```suggestion
# Create Redis store without passing unknown kwargs to avoid
TypeError
# (helpers commonly accept a config mapping; provide prefix via
config if needed)
redis_store = _create_redis_store(config)
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Start MCP service in multi-pod mode by enabling Redis in config:
- Edit MCP_STORE_CONFIG / MCP_EVENT_STORE_CONFIG to include
"CACHE_REDIS_URL".
- File: superset/mcp_service/mcp_config.py (module-level config consumed
by server.py).
- Entry point: run the module via python -m superset.mcp_service.server
or let system
call
the package's entrypoint that ends up invoking server.run_server().
2. run_server() calls create_event_store(...) to construct the backing store:
- File: superset/mcp_service/server.py, function run_server (calls
create_event_store).
- create_event_store defined at superset/mcp_service/server.py:69
(function start).
3. create_event_store computes the prefix and calls the storage helper:
- The prefix computation and helper invocation live at
superset/mcp_service/server.py:92-97 (see the existing_code block).
- Line: 97 executes: redis_store = _create_redis_store(config,
prefix=prefix,
wrap=True)
4. If the imported helper _create_redis_store (from
superset.mcp_service.storage) does NOT
accept
keyword args "prefix" or "wrap", Python raises a TypeError at that call
(superset/mcp_service/server.py:97),
failing create_event_store and causing run_server startup to error out.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/server.py
**Line:** 96:97
**Comment:**
*Type Error: Passing keyword arguments (`prefix` and `wrap`) directly
to `_create_redis_store` may not match its signature and will raise a TypeError
at runtime if that helper doesn't accept those keywords; instead pass a plain
config mapping (or set the prefix in a config copy) so the helper reads the
prefix from config and avoid unexpected keyword arguments.
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>
--
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]