batch_assign_timeframes
Assign timeframes to multiple todos in bulk for weekly planning. Use JSON input to specify todo-timeframe pairs and receive update summaries.
Instructions
Bulk assign timeframes to multiple todos (for weekly planning).
Args: assignments_json: JSON array of {todo_id, timeframe} objects
Example:
[
{"todo_id": 10, "timeframe": "this_week"},
{"todo_id": 15, "timeframe": "next_sprint"},
{"todo_id": 20, "timeframe": "someday"}
]Returns: Summary of updates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignments_json | Yes |
Implementation Reference
- src/coach_ai/server.py:401-457 (handler)The `batch_assign_timeframes` tool handler implementation. It validates input JSON, checks against allowed timeframes, and updates the database.
@mcp.tool() async def batch_assign_timeframes(assignments_json: str) -> str: """Bulk assign timeframes to multiple todos (for weekly planning). Args: assignments_json: JSON array of {todo_id, timeframe} objects Example: ``` [ {"todo_id": 10, "timeframe": "this_week"}, {"todo_id": 15, "timeframe": "next_sprint"}, {"todo_id": 20, "timeframe": "someday"} ] ``` Returns: Summary of updates """ db = await storage.get_db() try: assignments = json.loads(assignments_json) except json.JSONDecodeError as e: return f"Error: Invalid JSON: {e}" valid_timeframes = ["this_week", "next_sprint", "this_month", "this_quarter", "someday"] updated = 0 errors = [] for assignment in assignments: todo_id = assignment.get("todo_id") timeframe = assignment.get("timeframe") if not todo_id or not timeframe: errors.append(f"Missing todo_id or timeframe in: {assignment}") continue if timeframe not in valid_timeframes: errors.append(f"Invalid timeframe '{timeframe}' for todo #{todo_id}") continue await db.execute( "UPDATE todos SET timeframe = ? WHERE id = ?", (timeframe, todo_id), ) updated += 1 await db.commit() response = f"✓ Updated {updated} todos with timeframes" if errors: response += f"\n\n⚠️ {len(errors)} errors:\n" for error in errors[:5]: response += f" • {error}\n" return response