Repository navigation
Expand file tree
/
Copy pathregistry.py
More file actions
297 lines (250 loc) · 9.42 KB
/
Copy pathregistry.py
File metadata and controls
297 lines (250 loc) · 9.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
"""Registry MCP sub-server.
Exposes read-only tools that proxy to the Feast REST registry server
at ``/api/v1/``, letting an LLM discover what features, entities,
feature views, and feature services exist in a Feast project.
"""
from typing import Any, Dict, Optional
from fastmcp import FastMCP
from feast.mcp.auth import get_auth_token
from feast.mcp.client import FeastClient, path_segment
def create_registry_mcp(client: FeastClient) -> FastMCP:
registry_mcp = FastMCP("feast-registry")
# ------------------------------------------------------------------
# Projects
# ------------------------------------------------------------------
@registry_mcp.tool
async def list_projects() -> Any:
"""List all Feast projects in the registry.
Use this first to discover available projects before querying
other registry objects.
"""
return await client.request("GET", "/api/v1/projects", token=get_auth_token())
@registry_mcp.tool
async def get_project(name: str) -> Any:
"""Get details of a specific Feast project.
Args:
name: Project name.
"""
return await client.request(
"GET", f"/api/v1/projects/{path_segment(name)}", token=get_auth_token()
)
# ------------------------------------------------------------------
# Entities
# ------------------------------------------------------------------
@registry_mcp.tool
async def list_entities(project: str) -> Any:
"""List all entities in a project.
Entities define the join keys used to look up feature values
(e.g. customer_id, driver_id).
Args:
project: Feast project name.
"""
return await client.request(
"GET",
"/api/v1/entities",
token=get_auth_token(),
params={"project": project},
)
@registry_mcp.tool
async def get_entity(name: str, project: str) -> Any:
"""Get details of a specific entity.
Args:
name: Entity name.
project: Feast project name.
"""
return await client.request(
"GET",
f"/api/v1/entities/{path_segment(name)}",
token=get_auth_token(),
params={"project": project},
)
# ------------------------------------------------------------------
# Feature Views (all types: regular, stream, on-demand)
# ------------------------------------------------------------------
@registry_mcp.tool
async def list_feature_views(
project: str,
entity: Optional[str] = None,
feature: Optional[str] = None,
feature_service: Optional[str] = None,
data_source: Optional[str] = None,
) -> Any:
"""List all feature views in a project.
Returns regular, stream, and on-demand feature views.
Use the optional filters to narrow results.
Args:
project: Feast project name.
entity: Filter by entity name.
feature: Filter by feature name.
feature_service: Filter by feature service name.
data_source: Filter by data source name.
"""
params: Dict[str, str] = {"project": project}
if entity is not None:
params["entity"] = entity
if feature is not None:
params["feature"] = feature
if feature_service is not None:
params["feature_service"] = feature_service
if data_source is not None:
params["data_source"] = data_source
return await client.request(
"GET",
"/api/v1/feature_views",
token=get_auth_token(),
params=params,
)
@registry_mcp.tool
async def get_feature_view(name: str, project: str) -> Any:
"""Get details of a specific feature view.
Returns the feature view regardless of type (regular, stream,
or on-demand), including its schema, entities, and data source.
Args:
name: Feature view name.
project: Feast project name.
"""
return await client.request(
"GET",
f"/api/v1/feature_views/{path_segment(name)}",
token=get_auth_token(),
params={"project": project},
)
# ------------------------------------------------------------------
# Features (individual columns within feature views)
# ------------------------------------------------------------------
@registry_mcp.tool
async def list_features(
project: str,
feature_view: Optional[str] = None,
) -> Any:
"""List individual features (columns) across all feature views.
Args:
project: Feast project name.
feature_view: Filter by feature view name.
"""
params: Dict[str, str] = {"project": project}
if feature_view is not None:
params["feature_view"] = feature_view
return await client.request(
"GET",
"/api/v1/features",
token=get_auth_token(),
params=params,
)
# ------------------------------------------------------------------
# Feature Services
# ------------------------------------------------------------------
@registry_mcp.tool
async def list_feature_services(
project: str,
feature_view: Optional[str] = None,
) -> Any:
"""List all feature services in a project.
A feature service groups multiple feature views together for
serving as a single unit.
Args:
project: Feast project name.
feature_view: Filter by feature view name.
"""
params: Dict[str, str] = {"project": project}
if feature_view is not None:
params["feature_view"] = feature_view
return await client.request(
"GET",
"/api/v1/feature_services",
token=get_auth_token(),
params=params,
)
@registry_mcp.tool
async def get_feature_service(name: str, project: str) -> Any:
"""Get details of a specific feature service.
Args:
name: Feature service name.
project: Feast project name.
"""
return await client.request(
"GET",
f"/api/v1/feature_services/{path_segment(name)}",
token=get_auth_token(),
params={"project": project},
)
# ------------------------------------------------------------------
# Data Sources
# ------------------------------------------------------------------
@registry_mcp.tool
async def list_data_sources(project: str) -> Any:
"""List all data sources in a project.
Data sources define where feature data comes from (e.g.
BigQuery tables, Parquet files, Kafka topics).
Args:
project: Feast project name.
"""
return await client.request(
"GET",
"/api/v1/data_sources",
token=get_auth_token(),
params={"project": project},
)
@registry_mcp.tool
async def get_data_source(name: str, project: str) -> Any:
"""Get details of a specific data source.
Args:
name: Data source name.
project: Feast project name.
"""
return await client.request(
"GET",
f"/api/v1/data_sources/{path_segment(name)}",
token=get_auth_token(),
params={"project": project},
)
# ------------------------------------------------------------------
# Search & Lineage
# ------------------------------------------------------------------
@registry_mcp.tool
async def search_registry(query: str, project: Optional[str] = None) -> Any:
"""Full-text search across all registry objects.
Searches entities, feature views, feature services, data
sources, and other objects by name and metadata.
Args:
query: Search query string.
project: Optionally scope search to a project.
"""
params: Dict[str, str] = {"query": query}
if project is not None:
params["project"] = project
return await client.request(
"GET",
"/api/v1/search",
token=get_auth_token(),
params=params,
)
@registry_mcp.tool
async def get_lineage(
project: str,
object_type: Optional[str] = None,
object_name: Optional[str] = None,
) -> Any:
"""Get lineage relationships between registry objects.
Without filters, returns the complete lineage graph for the
project. With object_type and object_name, returns
relationships for a specific object.
Args:
project: Feast project name.
object_type: Filter by object type (e.g. 'feature_view', 'entity').
object_name: Filter by object name.
"""
if object_type and object_name:
return await client.request(
"GET",
f"/api/v1/lineage/objects/{path_segment(object_type)}/{path_segment(object_name)}",
token=get_auth_token(),
params={"project": project},
)
return await client.request(
"GET",
"/api/v1/lineage/complete",
token=get_auth_token(),
params={"project": project},
)
return registry_mcp