aminghadersohi commented on code in PR #37216:
URL: https://github.com/apache/superset/pull/37216#discussion_r2708405149
##########
superset/mcp_service/server.py:
##########
@@ -55,21 +65,79 @@ 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
+
+ # Reuse _create_redis_store with wrap=False for raw RedisStore
+ redis_store = _create_redis_store(config, wrap=False)
Review Comment:
Good point! I've updated the code to use wrap=True with a configurable
prefix:
```
# 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)
```
Key changes:
- EventStore now uses wrap=True by default
- Prefix is configurable via event_store_prefix config (defaults to
"mcp_events_")
- For multi-tenant deployments, we can configure a dynamic prefix (callable)
via the config
This prevents key collisions in shared Redis environments while allowing
customization for different deployment scenarios.
--
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]