Skip to content

Commit 6c098d6

Browse files
committed
Replace fastapi_mcp with the MCP Python SDK (FastMCP) to fix RecursionError on recursive Pydantic models, expose explicit @mcp.tool() handlers that call FeatureStore directly, and add registry discovery, data access, and materialization tools with flat LLM-friendly schemas.
Signed-off-by: Chaitany patel <patelchaitany93@gmail.com>
1 parent 0c469a7 commit 6c098d6

File tree

7 files changed

+640
-279
lines changed

7 files changed

+640
-279
lines changed

sdk/python/feast/feature_server.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
)
3939
from fastapi.concurrency import run_in_threadpool
4040
from fastapi.logger import logger
41+
from fastapi.middleware.cors import CORSMiddleware
4142
from fastapi.responses import JSONResponse
4243
from fastapi.staticfiles import StaticFiles
4344
from google.protobuf.json_format import MessageToDict
@@ -353,8 +354,14 @@ async def lifespan(app: FastAPI):
353354

354355
await store.initialize()
355356
async_refresh()
357+
358+
mcp_sm = getattr(app.state, "mcp_session_manager", None)
356359
try:
357-
yield
360+
if mcp_sm:
361+
async with mcp_sm.run():
362+
yield
363+
else:
364+
yield
358365
finally:
359366
stop_refresh()
360367
if offline_batcher is not None:
@@ -363,6 +370,15 @@ async def lifespan(app: FastAPI):
363370

364371
app = FastAPI(lifespan=lifespan)
365372

373+
app.add_middleware(
374+
CORSMiddleware,
375+
allow_origins=["*"],
376+
allow_credentials=True,
377+
allow_methods=["*"],
378+
allow_headers=["*"],
379+
expose_headers=["Mcp-Session-Id"],
380+
)
381+
366382
@app.post(
367383
"/get-online-features",
368384
dependencies=[Depends(inject_user_details)],
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# MCP (Model Context Protocol) server implementations for Feast
22

33
from .mcp_config import McpFeatureServerConfig
4-
from .mcp_server import add_mcp_support_to_app
4+
from .mcp_server import add_mcp_support_to_app, create_mcp_server
55

66
__all__ = [
77
"McpFeatureServerConfig",
88
"add_mcp_support_to_app",
9+
"create_mcp_server",
910
]

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@
88
class McpFeatureServerConfig(BaseFeatureServerConfig):
99
"""MCP (Model Context Protocol) Feature Server configuration."""
1010

11-
# Feature server type selector
1211
type: Literal["mcp"] = "mcp"
1312

14-
# Enable MCP server support - defaults to False as requested
1513
mcp_enabled: StrictBool = False
1614

17-
# MCP server name for identification
1815
mcp_server_name: StrictStr = "feast-mcp-server"
1916

20-
# MCP server version
2117
mcp_server_version: StrictStr = "1.0.0"
2218

2319
mcp_transport: Literal["sse", "http"] = "sse"
2420

25-
# The endpoint definition for transformation_service (inherited from base)
21+
mcp_base_path: StrictStr = "/mcp"
22+
2623
transformation_service_endpoint: StrictStr = "localhost:6566"

0 commit comments

Comments
 (0)