create_task
Create a new task with a required title and optional project, category, due date, and notes.
Instructions
Create a new task in Amazing Marvin.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Task title (required) | |
| project_id | No | Optional project ID to assign task to | |
| category_id | No | Optional category ID for organization | |
| due_date | No | Optional due date in YYYY-MM-DD format | |
| note | No | Optional task notes/description | |
| debug | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | ||
| metadata | Yes | Metadata about the data itself | |
| summary | Yes | Human-readable insights | |
| debug | Yes | ||
| success | Yes | ||
| api_version | No | current | |
| response_version | No | 1.0 |
Implementation Reference
- src/amazing_marvin_mcp/main.py:320-367 (handler)The main tool handler for 'create_task'. It is decorated with @mcp.tool(), accepts title (required), project_id, category_id, due_date, note, and debug parameters. It builds task_data dict, calls api_client.create_task(), and returns a StandardResponse via create_simple_response().
@mcp.tool() async def create_task( title: str, project_id: str | None = None, category_id: str | None = None, due_date: str | None = None, note: str | None = None, debug: bool = False, ) -> StandardResponse: """Create a new task in Amazing Marvin. Args: title: Task title (required) project_id: Optional project ID to assign task to category_id: Optional category ID for organization due_date: Optional due date in YYYY-MM-DD format note: Optional task notes/description For creating multiple tasks, use batch_create_tasks() instead. For creating a project with tasks, use create_project_with_tasks(). """ start_time = time.time() try: api_client = create_api_client() task_data = {"title": title} if project_id: task_data["parentId"] = project_id if category_id: task_data["categoryId"] = category_id if due_date: task_data["dueDate"] = due_date if note: task_data["note"] = note created_task = api_client.create_task(task_data) return create_simple_response( data={"created_task": created_task}, summary_text=f"Created task: {title}", api_endpoint="/addTask", api_calls_made=1, debug=debug, start_time=start_time, ) except Exception as e: logger.exception("Failed to create task '%s'", title) return create_error_response(e, "/addTask", debug, start_time) - src/amazing_marvin_mcp/main.py:320-320 (registration)The tool is registered via the @mcp.tool() decorator on the create_task function. The mcp instance is FastMCP(name='amazing-marvin-mcp') at line 43.
@mcp.tool() - The MarvinAPIClient.create_task() method that actually calls the external API endpoint /addTask via POST request, accepting a task_data dict.
def create_task(self, task_data: dict) -> dict: """Create a new task (uses /addTask endpoint)""" return self._make_request("post", "/addTask", data=task_data) - create_simple_response() is used by the create_task handler to format the StandardResponse. Also create_error_response() for error cases. Note: create_task_response() is NOT used by create_task (it's for get_tasks).
def create_simple_response( data: Any, summary_text: str, api_endpoint: str, api_calls_made: int = 1, debug: bool = False, start_time: float | None = None, ) -> StandardResponse: """Create a simple StandardResponse for non-task data.""" response_time = int((time.time() - start_time) * 1000) if start_time else 0 # Determine count based on data type if isinstance(data, list): count = len(data) elif isinstance(data, dict): count = len(data) if data else 0 else: count = 1 if data else 0 return StandardResponse( data=data, metadata=ResponseMetadata( count=count, source=api_endpoint.replace("/", "").replace("_", " "), data_freshness="real_time", ), summary=ResponseSummary( text=summary_text, status="success", action_completed="data_retrieved" ), debug=ResponseDebug( api_endpoint=api_endpoint, response_time_ms=response_time, api_calls_made=api_calls_made, cache_hit=False, ) if debug else None, success=True, api_version="current", response_version="1.0", )