-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Add MCP (Model Context Protocol) support for Feast feature server #5406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ba1feb6
86b6a20
1ed32d4
2bb7248
479eb7a
edbb58f
a8b17e1
bc00dba
e3a30d7
8a644b5
08c4dd6
6c6f6ee
c3043c1
8b26804
1bec81f
8aa31a7
9409e6a
426744b
c40809b
6135cde
b31cc87
b9a84f3
dc71713
ba6f51a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Feast MCP Feature Server Example | ||
|
|
||
| This example demonstrates how to enable MCP (Model Context Protocol) support in Feast, allowing AI agents and applications to interact with your features through standardized MCP interfaces. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. Python 3.8+ | ||
| 2. Feast installed | ||
| 3. FastAPI MCP library | ||
|
|
||
| ## Installation | ||
|
|
||
| 1. Install Feast with MCP support: | ||
| ```bash | ||
| pip install feast[mcp] | ||
| ``` | ||
|
|
||
| Alternatively, you can install the dependencies separately: | ||
| ```bash | ||
| pip install feast | ||
| pip install fastapi_mcp | ||
| ``` | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Navigate to this example directory within your cloned Feast repository: | ||
| ```bash | ||
| cd examples/mcp_feature_store | ||
| ``` | ||
|
|
||
| 2. Initialize a Feast repository in this directory. We'll use the existing `feature_store.yaml` that's already configured for MCP: | ||
| ```bash | ||
| feast init . | ||
| ``` | ||
| This will create a `data` subdirectory and a `feature_repo` subdirectory if they don't exist, and will use the `feature_store.yaml` present in the current directory (`examples/mcp_feature_store`). | ||
|
|
||
| 3. Apply the feature store configuration: | ||
| ```bash | ||
| cd feature_repo | ||
| feast apply | ||
| cd .. # Go back to examples/mcp_feature_store for the next steps | ||
| ``` | ||
|
|
||
| ## Starting the MCP-Enabled Feature Server | ||
|
|
||
| Start the Feast feature server with MCP support: | ||
|
|
||
| ```bash | ||
| feast serve --host 0.0.0.0 --port 6566 | ||
| ``` | ||
|
|
||
| If MCP is properly configured, you should see a log message indicating that MCP support has been enabled: | ||
|
|
||
| ``` | ||
| INFO:feast.feature_server:MCP support has been enabled for the Feast feature server | ||
| ``` | ||
|
|
||
| ## Available MCP Tools | ||
|
|
||
| The fastapi_mcp integration automatically exposes your Feast feature server's FastAPI endpoints as MCP tools. This means AI assistants can: | ||
|
|
||
| - **Call `/get-online-features`** to retrieve features from the feature store | ||
| - **Use `/health`** to check server status | ||
|
|
||
|
|
||
| ## Configuration Details | ||
|
|
||
| The key configuration that enables MCP support: | ||
|
|
||
| ```yaml | ||
| feature_server: | ||
| type: mcp # Use MCP feature server type | ||
| enabled: true # Enable feature server | ||
| mcp_enabled: true # Enable MCP protocol support | ||
| mcp_server_name: "feast-feature-store" | ||
| mcp_server_version: "1.0.0" | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| project: feast_mcp_example | ||
| registry: data/registry.db | ||
| provider: local | ||
|
|
||
| online_store: | ||
| type: sqlite | ||
| path: data/online_store.db | ||
|
|
||
| offline_store: | ||
| type: file | ||
|
|
||
| # MCP Feature Server Configuration | ||
| feature_server: | ||
| type: mcp | ||
| enabled: true | ||
| mcp_enabled: true # Enable MCP support - defaults to false | ||
| mcp_server_name: "feast-feature-store" | ||
| mcp_server_version: "1.0.0" | ||
| feature_logging: | ||
| enabled: false | ||
|
|
||
| entity_key_serialization_version: 3 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as mcp will only implement onlinstore, instead of make new section with feature_server is that possible we can add into into onlinstore section WDYT ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While embedding MCP config in the online_store:
type: sqlite
path: data/online_store.db
feature_server:
type: mcp
enabled: true
mcp_enabled: true
mcp_server_name: "feast-feature-store"
mcp_server_version: "1.0.0"
feature_logging:
enabled: falseWhy this approach is better:
What do u think @franciscojavierarceo @ntkathole
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm good with it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of these 3 fields my suggestion was if we change the name for example
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What @redhatHameed suggested 👍
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In short MCP online store config looks like: No hassle of enabling explicitely.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even if we can make like, that will remove extra type field.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @redhatHameed mind addressing in a follow up PR? I think this is good enough as an MVP
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @YassinNouh21 this item. Removing the |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # MCP (Model Context Protocol) server implementations for Feast | ||
|
|
||
| from .mcp_config import McpFeatureServerConfig | ||
| from .mcp_server import add_mcp_support_to_app | ||
|
|
||
| __all__ = [ | ||
| "McpFeatureServerConfig", | ||
| "add_mcp_support_to_app", | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| from typing import Literal, Optional | ||
|
|
||
| from pydantic import StrictBool, StrictStr | ||
|
|
||
| from feast.infra.feature_servers.base_config import BaseFeatureServerConfig | ||
|
|
||
|
|
||
| class McpFeatureServerConfig(BaseFeatureServerConfig): | ||
| """MCP (Model Context Protocol) Feature Server configuration.""" | ||
|
|
||
| # Feature server type selector | ||
| type: Literal["mcp"] = "mcp" | ||
|
|
||
| # Enable MCP server support - defaults to False as requested | ||
| mcp_enabled: StrictBool = False | ||
|
|
||
| # MCP server name for identification | ||
| mcp_server_name: StrictStr = "feast-mcp-server" | ||
|
|
||
| # MCP server version | ||
| mcp_server_version: StrictStr = "1.0.0" | ||
|
|
||
| # Optional MCP transport configuration | ||
| mcp_transport: Optional[StrictStr] = None | ||
|
|
||
| # The endpoint definition for transformation_service (inherited from base) | ||
| transformation_service_endpoint: StrictStr = "localhost:6566" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| """ | ||
| MCP (Model Context Protocol) integration for Feast Feature Server. | ||
|
|
||
| This module provides MCP support for Feast by integrating with fastapi_mcp | ||
| to expose Feast functionality through the Model Context Protocol. | ||
| """ | ||
|
|
||
| import logging | ||
| from typing import Optional | ||
|
|
||
| from feast.feature_store import FeatureStore | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| try: | ||
| from fastapi_mcp import FastApiMCP | ||
|
|
||
| MCP_AVAILABLE = True | ||
| except ImportError: | ||
| logger.warning( | ||
| "fastapi_mcp is not installed. MCP support will be disabled. " | ||
| "Install it with: pip install fastapi_mcp" | ||
| ) | ||
| MCP_AVAILABLE = False | ||
| # Create placeholder classes for testing | ||
| FastApiMCP = None | ||
|
|
||
|
|
||
| def add_mcp_support_to_app(app, store: FeatureStore, config) -> Optional["FastApiMCP"]: | ||
| """Add MCP support to the FastAPI app if enabled in configuration.""" | ||
| if not MCP_AVAILABLE: | ||
| logger.warning("MCP support requested but fastapi_mcp is not available") | ||
| return None | ||
|
|
||
| try: | ||
| # Create MCP server from the FastAPI app | ||
| mcp = FastApiMCP( | ||
| app, | ||
| name=getattr(config, "mcp_server_name", "feast-feature-store"), | ||
| description="Feast Feature Store MCP Server - Access feature store data and operations through MCP", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @YassinNouh21 can we check if we can use other parameters like |
||
| ) | ||
|
|
||
| # Mount the MCP server to the FastAPI app | ||
| mcp.mount() | ||
|
|
||
| logger.info( | ||
| "MCP support has been enabled for the Feast feature server at /mcp endpoint" | ||
| ) | ||
| logger.info( | ||
| f"MCP integration initialized for {getattr(config, 'mcp_server_name', 'feast-feature-store')} " | ||
| f"v{getattr(config, 'mcp_server_version', '1.0.0')}" | ||
| ) | ||
|
|
||
| return mcp | ||
|
|
||
| except Exception as e: | ||
| logger.error(f"Failed to initialize MCP integration: {e}") | ||
| return None | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this!
I'd also add this to the GenAI docs and make it an extra that we enable with
pip install feast[mcp]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@franciscojavierarceo done can u check it