Specify MCP delete results and accept hydration decimal precision

This commit is contained in:
Joren de Graaf
2026-11-04 00:41:59 +01:00
parent 92687cd82b
commit 01133370e6
4 changed files with 40 additions and 4 deletions
+18 -3
View File
@@ -18,6 +18,21 @@ from mcp.server.mcpserver import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
from mcp.server.transport_security import TransportSecuritySettings
from pydantic import AnyHttpUrl, BaseModel, ConfigDict, Field
from typing_extensions import TypedDict
class FoodDeleteResult(TypedDict):
success: bool
deleted_entry_id: str
class InventoryRemoveResult(TypedDict):
success: bool
removed_item_id: str
class HydrationDeleteResult(TypedDict):
deleted: bool
API_BASE = os.environ.get('TASKNEST_API_BASE_URL', 'http://127.0.0.1:1234/api/v1').rstrip('/')
MCP_PUBLIC_URL = os.environ.get('TASKNEST_MCP_PUBLIC_URL', 'https://tasksnest.jorendegraaf.eu/mcp')
@@ -519,7 +534,7 @@ def create_server() -> MCPServer:
return {'success': True, 'entry': _entry(data)}
@server.tool(structured_output=True, description='Permanently delete one food log entry belonging to the authenticated user. This is destructive and also removes its image attachments. Require the user’s clear intent.')
async def food_delete_entry(entry_id: str) -> dict[str, Any]:
async def food_delete_entry(entry_id: str) -> FoodDeleteResult:
await api_request('DELETE', f'food/log/{entry_id}/')
return {'success': True, 'deleted_entry_id': entry_id}
@@ -642,7 +657,7 @@ def create_server() -> MCPServer:
return {**data, 'idempotency_key': idempotency_key}
@server.tool(structured_output=True, description='Permanently remove one kitchen inventory item belonging to the authenticated user. This is destructive; require the user’s clear intent.')
async def inventory_remove(item_id: str) -> dict[str, Any]:
async def inventory_remove(item_id: str) -> InventoryRemoveResult:
await api_request('DELETE', f'kitchen/items/{item_id}/')
return {'success': True, 'removed_item_id': item_id}
@@ -695,7 +710,7 @@ def create_server() -> MCPServer:
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 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]:
async def hydration_delete(entry_id: str) -> HydrationDeleteResult:
return await api_request('DELETE', f'hydration/manual/{entry_id}/')
@server.tool(structured_output=True, description='Read hydration goal and automatic drink counting settings for the authenticated user.')