Document MCP tool catalog and clarify discovery guidance
This commit is contained in:
+10
-10
@@ -451,7 +451,7 @@ async def _attach(entry_id, image_base64, image_file, mime_type, filename, capti
|
||||
|
||||
|
||||
def create_server() -> MCPServer:
|
||||
server = MCPServer('TaskNest', description='Food, kitchen, and private stress and dream journals for the authenticated TaskNest user.',
|
||||
server = MCPServer('TaskNest', description='Private TasksNest tools for Food Diary, saved products, hydration, kitchen inventory, groceries, recipes, nutrition sources, dietary preferences, and stress and dream journals. Read tools inspect the authenticated user’s data; write tools change it and require the corresponding OAuth scope. Search or preview before ambiguous or consequential writes, and reuse idempotency keys on retries. Never infer permission to delete, consume stock, log a meal, or accept a dietary warning from tool availability alone.',
|
||||
token_verifier=ApiTokenVerifier(), auth=AuthSettings(
|
||||
issuer_url=AnyHttpUrl(OAUTH_ISSUER_URL), resource_server_url=AnyHttpUrl(MCP_PUBLIC_URL),
|
||||
required_scopes=[], validate_token_resource=False))
|
||||
@@ -478,7 +478,7 @@ def create_server() -> MCPServer:
|
||||
'protein_100', 'fat_100', 'fibre_100', 'sugars_100', 'salt_100', 'portions')
|
||||
return {'count': data['count'], 'products': [{k: item.get(k) for k in fields} for item in data['results']]}
|
||||
|
||||
@server.tool(structured_output=True, description='Find food product candidates in your saved products and optionally Open Food Facts. Read only: never saves a search result. Exact barcodes rank first; ambiguous matches are candidates for user selection. External lookup may be unavailable.')
|
||||
@server.tool(structured_output=True, description='Find food product candidates in saved products and optionally Open Food Facts. Requires food:read. Use for “identify this barcode”; use food_search_products for saved-only search. Read only: never saves a result. Exact barcodes rank first; ask the user to choose an ambiguous match. External lookup may be unavailable.')
|
||||
async def food_lookup_product(query: str = '', barcode: str | None = None, brand: str = '',
|
||||
package_quantity: Decimal | None = None,
|
||||
package_unit: Literal['g', 'ml'] | None = None,
|
||||
@@ -498,7 +498,7 @@ def create_server() -> MCPServer:
|
||||
payload=product.model_dump(mode='json', exclude_none=True), idempotency_key=key)
|
||||
return {**data, 'idempotency_key': key}
|
||||
|
||||
@server.tool(structured_output=True, description='Save a selected Open Food Facts product by numeric barcode into your product catalogue. Changes data; uses the configured cached external import. Does not invent missing nutrition. Returns a local product_id, or a structured not-found/error response. Reuse idempotency_key on retries.')
|
||||
@server.tool(structured_output=True, description='Save a selected Open Food Facts product by numeric barcode into your product catalogue. Requires food:write. Use after the user selects a lookup candidate; do not use for manual facts or an ambiguous barcode. Changes data, does not invent missing nutrition, and returns a local product_id or a failed-status result. Reuse idempotency_key on retries.')
|
||||
async def food_import_product(barcode: str, idempotency_key: str | None = None) -> dict[str, Any]:
|
||||
key = _key(idempotency_key)
|
||||
try:
|
||||
@@ -652,13 +652,13 @@ def create_server() -> MCPServer:
|
||||
params = {'product_id': product_id, 'query': query, 'location_id': location_id}
|
||||
return await api_request('GET', 'kitchen/stock/', params={k: v for k, v in params.items() if v is not None})
|
||||
|
||||
@server.tool(structured_output=True, description='Preview package deductions for one owned product without changing stock. Supports pieces and inner_packs when packaging is configured, plus matching g/ml amounts. Nested per-piece weights are estimates derived from measured inner-pack amounts; unsupported conversions return a clear error.')
|
||||
@server.tool(structured_output=True, description='Preview package deductions for one owned product without changing stock. Requires inventory:read even though the underlying API uses POST. Use before inventory_consume, especially when stock may be short. Supports configured pieces, inner_packs and matching g/ml; derived per-piece weights are estimates. Unsupported conversions return an error.')
|
||||
async def inventory_preview_consumption(product_id: str, amount: Decimal, unit: str,
|
||||
package_id: str | None = None) -> dict[str, Any]:
|
||||
return await api_request('POST', 'kitchen/consumption/preview/', payload={
|
||||
'product_id': product_id, 'amount': str(amount), 'unit': unit, 'package_id': package_id})
|
||||
|
||||
@server.tool(structured_output=True, description='Consume an exact quantity from owned inventory packages atomically. Requires a unique idempotency key. If stock is short, preview first and use allow_partial only with explicit user choice.')
|
||||
@server.tool(structured_output=True, description='Consume an exact quantity from owned inventory packages atomically. Requires inventory:write, the user’s clear intent and a unique idempotency key. Preview with inventory_preview_consumption first; use allow_partial only if the user accepts the specific shortage. This changes stock but does not log a Food Diary meal.')
|
||||
async def inventory_consume(product_id: str, amount: Decimal, unit: str, idempotency_key: str,
|
||||
package_id: str | None = None, source_reference: str = '',
|
||||
description: str = '', allow_partial: bool = False) -> dict[str, Any]:
|
||||
@@ -694,7 +694,7 @@ def create_server() -> MCPServer:
|
||||
return await api_request('PATCH', f'hydration/manual/{entry_id}/',
|
||||
payload={k: v for k, v in changes.items() if v is not None})
|
||||
|
||||
@server.tool(structured_output=True, description='Delete an owned standalone manual hydration entry. Does not affect Food Diary entries.')
|
||||
@server.tool(structured_output=True, description='Delete an owned standalone manual hydration entry by ID. Requires food:write and the user’s clear intent. Does not affect Food Diary entries. Use hydration_update to correct an entry instead of deleting it.')
|
||||
async def hydration_delete(entry_id: str) -> dict[str, Any]:
|
||||
return await api_request('DELETE', f'hydration/manual/{entry_id}/')
|
||||
|
||||
@@ -737,7 +737,7 @@ def create_server() -> MCPServer:
|
||||
async def recipe_link_remove(recipe_id: str, link_id: str) -> dict[str, Any]:
|
||||
return await api_request('DELETE', f'recipes/{recipe_id}/links/{link_id}/')
|
||||
|
||||
@server.tool(structured_output=True, description='Preview an explicitly selected set of owned component recipes. Returns ingredient details, nutrition completeness, duplicate ingredient warnings, and issues. Suggestion links are excluded; this does not create a recipe, log a meal, or deduct inventory.')
|
||||
@server.tool(structured_output=True, description='Preview an explicitly selected set of owned component recipes. Requires food:read, although the API uses POST. Returns ingredient details, nutrition completeness, duplicate ingredient warnings, and issues. Suggestion links are excluded; this does not create a recipe, log a meal, or deduct inventory.')
|
||||
async def recipe_composition_preview(components: list[RecipeComponentInput]) -> dict[str, Any]:
|
||||
return await api_request('POST', 'recipes/compositions/preview/',
|
||||
payload={'components': [item.model_dump(mode='json') for item in components]})
|
||||
@@ -763,7 +763,7 @@ def create_server() -> MCPServer:
|
||||
return await api_request('GET', 'recipes/cook-later/',
|
||||
params={'search': search, 'limit': limit, 'offset': offset})
|
||||
|
||||
@server.tool(structured_output=True, description='List your grocery items by needed, purchased, or all status. Read only.')
|
||||
@server.tool(structured_output=True, description='List your grocery items by needed, purchased, or all status. Requires inventory:read and changes nothing. This is a shopping list, not current kitchen stock; use inventory_search for stock.')
|
||||
async def grocery_list(status: Literal['needed', 'purchased', 'all'] = 'needed', limit: int = 30,
|
||||
offset: int = 0) -> dict[str, Any]:
|
||||
return await api_request('GET', 'groceries/', params={'status': status, 'limit': limit, 'offset': offset})
|
||||
@@ -775,7 +775,7 @@ def create_server() -> MCPServer:
|
||||
return await api_request('GET', 'groceries/', params={'query': query, 'category': category,
|
||||
'product_id': product_id or '', 'status': status, 'limit': limit, 'offset': offset})
|
||||
|
||||
@server.tool(structured_output=True, description='Add one item to your grocery list. Does not change Kitchen Inventory. Reuse the idempotency key on retries.')
|
||||
@server.tool(structured_output=True, description='Add one item to your grocery list. Requires inventory:write. Use for “put milk on my shopping list”; use inventory_add only for food already owned. Does not change Kitchen Inventory. Reuse the same idempotency key and payload on retries.')
|
||||
async def grocery_add(item: GroceryItemInput, idempotency_key: str | None = None) -> dict[str, Any]:
|
||||
key = _key(idempotency_key)
|
||||
data = await api_request('POST', 'groceries/', payload=item.model_dump(mode='json', exclude_none=True),
|
||||
@@ -791,7 +791,7 @@ def create_server() -> MCPServer:
|
||||
async def grocery_delete(item_id: str) -> dict[str, Any]:
|
||||
return await api_request('DELETE', f'groceries/{item_id}/')
|
||||
|
||||
@server.tool(structured_output=True, description='Preview or confirm missing ingredients for an owned recipe, scaled to servings and selected substitutions. Omit confirm to preview. Set confirm true to add; uncertain matches additionally require confirm_uncertain true after review. Does not change Kitchen Inventory.')
|
||||
@server.tool(structured_output=True, description='Preview or confirm missing ingredients for an owned recipe, scaled to servings and selected substitutions. Preview requires inventory:read; confirm=true requires inventory:write and the user’s approval of the reviewed list. Uncertain matches additionally require confirm_uncertain=true. This changes groceries only, never Kitchen Inventory.')
|
||||
async def grocery_add_recipe(recipe_id: str, options: RecipeAnalysisInput | None = None,
|
||||
confirm: bool = False, confirm_uncertain: bool = False,
|
||||
idempotency_key: str | None = None) -> dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user