add_task_tool
Create a new task with a title and optional description to organize your workflow using the Tasks MCP Server.
Instructions
Add a new task. Args: title (str): The title of the task. description (str): The description of the task. optional value.
Returns: Task: The newly created task object.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | ||
| description | No |
Implementation Reference
- src/tools/tasks.py:40-57 (handler)The async handler function implementing the 'add_task_tool' logic: retrieves database from context, adds task with title and optional description (normalized to empty string if None), and returns the created Task instance.@mcp.tool() async def add_task_tool( ctx: Context[ServerSession, AppContext], title: str, description: str | None = None, ) -> Task: """Add a new task. Args: title (str): The title of the task. description (str): The description of the task. optional value. Returns: Task: The newly created task object. """ database: DatabaseABC = ctx.request_context.lifespan_context.db # Normalize None to empty string for storage compatibility task = database.add_task(title=title, description=description or "") return Task(**task.__dict__)
- src/models/tasks.py:12-18 (schema)Pydantic BaseModel defining the Task structure, used as the return type for add_task_tool and for serializing database task objects.class Task(BaseModel): id: int = Field(default=None) title: str = Field(..., description="The title of the task") description: str = Field(default="", description="The description of the task") status: TaskStatus = TaskStatus.CREATED created_at: str = Field(default=None)
- src/config/server.py:35-35 (registration)Invocation of create_tasks_tools(mcp) within the MCP server creation, which defines and registers the add_task_tool (via @mcp.tool() decorator inside create_tasks_tools) along with other task tools.create_tasks_tools(mcp)