Skip to content

Commit ddb2e9a

Browse files
larrysingleton007ntkathole
authored andcommitted
fix: Avoid importing feast.feature_store at mcp_server import time
mcp_server used a module-level `from feast.feature_store import FeatureStore` solely for a type annotation on add_mcp_support_to_app. Because the feast.infra.mcp_servers package __init__ eagerly imports mcp_server, importing the package pulled in the entire feature_store import graph. Under parallel unit-test collection (pytest -n) this intermittently raced with an in-progress feature_store import and failed collection of test_mcp_server.py with `KeyError: 'feast.infra.mcp_servers.mcp_server'`. Move the import under TYPE_CHECKING and use a forward reference, so importing mcp_server no longer triggers the feature_store graph. Public API and the annotation are unchanged. Signed-off-by: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com>
1 parent 7ae64ec commit ddb2e9a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

sdk/python/feast/infra/mcp_servers/mcp_server.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"""
77

88
import logging
9-
from typing import Any, Dict, Optional, Set
9+
from typing import TYPE_CHECKING, Any, Dict, Optional, Set
1010

11-
from feast.feature_store import FeatureStore
11+
if TYPE_CHECKING:
12+
from feast.feature_store import FeatureStore
1213

1314
logger = logging.getLogger(__name__)
1415

@@ -97,7 +98,9 @@ def _patch_fastapi_mcp_schema_resolver() -> None:
9798
pass
9899

99100

100-
def add_mcp_support_to_app(app, store: FeatureStore, config) -> Optional["FastApiMCP"]:
101+
def add_mcp_support_to_app(
102+
app, store: "FeatureStore", config
103+
) -> Optional["FastApiMCP"]:
101104
"""Add MCP support to the FastAPI app if enabled in configuration."""
102105
if not MCP_AVAILABLE:
103106
logger.warning("MCP support requested but fastapi_mcp is not available")

0 commit comments

Comments
 (0)