@@ -110,13 +110,13 @@ async def get_book_author(book_id: int) -> "Author":
110110
111111
112112# Define root resources
113- @app.resource
113+ @app.retrieve
114114async def list_authors () -> list[Author]:
115115 """ List all authors in the catalog."""
116116 return [Author(** author_data) for author_data in AUTHORS ]
117117
118118
119- @app.resource
119+ @app.retrieve
120120async def get_author (author_id : int ) -> Author:
121121 """ Get a specific author by ID."""
122122 author_data = next ((a for a in AUTHORS if a[" id" ] == author_id), None )
@@ -126,13 +126,13 @@ async def get_author(author_id: int) -> Author:
126126 return Author(id = - 1 , name = " Not Found" , bio = " Author not found" , birth_date = date(1900 , 1 , 1 ))
127127
128128
129- @app.resource
129+ @app.retrieve
130130async def list_books () -> list[Book]:
131131 """ List all books in the catalog."""
132132 return [Book(** book_data) for book_data in BOOKS ]
133133
134134
135- @app.resource
135+ @app.retrieve
136136async def search_books (title_contains : str ) -> list[Book]:
137137 """ Search for books by title."""
138138 matching_books = [book for book in BOOKS if title_contains.lower() in book[" title" ].lower()]
@@ -283,13 +283,13 @@ async def get_task_project(task_id: int) -> "Project":
283283
284284
285285# Resources
286- @app.resource
286+ @app.retrieve
287287async def list_projects () -> list[Project]:
288288 """ List all projects."""
289289 return [Project(** project_data) for project_data in PROJECTS ]
290290
291291
292- @app.resource
292+ @app.retrieve
293293async def list_tasks (status : Status | None = None , priority : Priority | None = None ) -> list[Task]:
294294 """ List tasks with optional filtering."""
295295 filtered_tasks = TASKS
@@ -303,7 +303,7 @@ async def list_tasks(status: Status | None = None, priority: Priority | None = N
303303 return [Task(** task_data) for task_data in filtered_tasks]
304304
305305
306- @app.resource
306+ @app.retrieve
307307async def get_project_summary (project_id : int ) -> dict :
308308 """ Get summary statistics for a project."""
309309 project_tasks = [t for t in TASKS if t[" project_id" ] == project_id]
@@ -421,13 +421,13 @@ async def get_ingredient_recipes(ingredient_id: int) -> list["Recipe"]:
421421
422422
423423# Resources
424- @app.resource
424+ @app.retrieve
425425async def list_recipes () -> list[Recipe]:
426426 """ List all recipes."""
427427 return [Recipe(** recipe_data) for recipe_data in RECIPES ]
428428
429429
430- @app.resource
430+ @app.retrieve
431431async def search_recipes_by_ingredient (ingredient_name : str ) -> list[Recipe]:
432432 """ Find recipes containing a specific ingredient."""
433433 # Find ingredient
@@ -442,7 +442,7 @@ async def search_recipes_by_ingredient(ingredient_name: str) -> list[Recipe]:
442442 return await get_ingredient_recipes(ingredient[" id" ])
443443
444444
445- @app.resource
445+ @app.retrieve
446446async def get_quick_recipes (max_time : int = 30 ) -> list[Recipe]:
447447 """ Get recipes that can be made quickly."""
448448 quick_recipes = [
@@ -459,7 +459,7 @@ These examples demonstrate:
459459- Basic entity definition with ` @app.entity `
460460- Relationship definition with ` Relationship() `
461461- Resolver implementation with ` @Entity.field.resolver `
462- - Resource creation with ` @app.resource `
462+ - Resource creation with ` @app.retrieve `
463463- Simple in-memory data storage
464464- Filtering and searching patterns
465465
@@ -472,4 +472,4 @@ can generate entities and resolvers directly from SQLAlchemy models. It works
472472with any async database backend supported by SQLAlchemy (for example
473473PostgreSQL with ` asyncpg ` ).
474474
475- The ` examples/shop_api_gateway ` project shows how EnrichMCP can act as a simple API gateway in front of another FastAPI service.
475+ The ` examples/shop_api_gateway ` project shows how EnrichMCP can act as a simple API gateway in front of another FastAPI service.
0 commit comments