addTask
Create new tasks for today's list or backlog by specifying task descriptions and target locations in a structured knowledge base.
Instructions
Add a new task to today's list or the backlog
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The task description | |
| target | No | Where to add the task | today |
Implementation Reference
- src/core/brain.ts:141-165 (handler)The core business logic that adds a task to either the 'today' or 'backlog' section, handling atomic updates and file creation.
async addTask(text: string, target: "today" | "backlog"): Promise<Task> { const log = getLogger(); const section: BrainSection = `tasks/${target}`; try { const result = await this.sync.atomicUpdate( section, (current) => appendTask(current, text), `feat(ai): add task to ${target}` ); const tasks = parseTasks(result.content, section); log.info("addTask", { target, text }); return tasks[tasks.length - 1]; } catch (err) { if (isNotFound(err)) { const title = target === "today" ? "Today" : "Backlog"; const content = `# ${title}\n\n- [ ] ${text}\n`; await this.sync.createSection( section, content, `feat(ai): create ${target} with new task` ); log.info("addTask: created file", { target, text }); const tasks = parseTasks(content, section); return tasks[tasks.length - 1]; - src/tools/tasks.ts:38-55 (registration)Tool registration and interface for the 'addTask' MCP tool.
server.registerTool( "addTask", { description: "Add a new task to today's list or the backlog", inputSchema: { text: z.string().describe("The task description"), target: z .enum(["today", "backlog"]) .optional() .default("today") .describe("Where to add the task"), }, }, toolHandler("addTask", async ({ text, target }) => { const task = await brain.addTask(text, target); return { success: true, task }; }) );