Skip to main content
Glama

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
NameRequiredDescriptionDefault
assignments_jsonYes

Implementation Reference

  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/94aharris/coach-ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server