add_task
Create a new task in your project by specifying title, priority, and optional details like description and tags.
Instructions
Add a new task to the project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID | |
| title | Yes | Task title | |
| description | No | Task description | |
| priority | Yes | Task priority | |
| tags | No | Task tags |
Implementation Reference
- src/server.ts:188-219 (handler)The handler function for the MCP 'add_task' tool. It takes input parameters, calls the ContextManager's addTask method, and returns a formatted response or error message.async ({ projectId, title, description, priority, tags }) => { try { const task = await this.contextManager.addTask(projectId, { title, description: description || "", status: "todo", priority, tags: tags || [], blockers: [], dependencies: [], }); return { content: [ { type: "text", text: `Task "${task.title}" added with ID: ${task.id}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error adding task: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } }
- src/server.ts:175-187 (schema)Zod input schema defining parameters for the 'add_task' tool: projectId, title, optional description, priority, and tags.{ title: "Add Task", description: "Add a new task to the project", inputSchema: { projectId: z.string().describe("Project ID"), title: z.string().describe("Task title"), description: z.string().optional().describe("Task description"), priority: z .enum(["low", "medium", "high", "critical"]) .describe("Task priority"), tags: z.array(z.string()).default([]).describe("Task tags"), }, },
- src/server.ts:174-220 (registration)Registration of the 'add_task' tool with the MCP server, including name, schema, and handler reference."add_task", { title: "Add Task", description: "Add a new task to the project", inputSchema: { projectId: z.string().describe("Project ID"), title: z.string().describe("Task title"), description: z.string().optional().describe("Task description"), priority: z .enum(["low", "medium", "high", "critical"]) .describe("Task priority"), tags: z.array(z.string()).default([]).describe("Task tags"), }, }, async ({ projectId, title, description, priority, tags }) => { try { const task = await this.contextManager.addTask(projectId, { title, description: description || "", status: "todo", priority, tags: tags || [], blockers: [], dependencies: [], }); return { content: [ { type: "text", text: `Task "${task.title}" added with ID: ${task.id}`, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error adding task: ${ error instanceof Error ? error.message : "Unknown error" }`, }, ], }; } } );
- Helper method in ContextManager that implements the core logic for adding a task: fetches project, creates task with UUID and timestamps, appends to tasks array, and persists via store.async addTask( projectId: string, taskData: Omit<Task, "id" | "createdAt" | "updatedAt"> ): Promise<Task> { const project = await this.store.getProject(projectId); if (!project) { throw new Error("Project not found"); } const now = new Date().toISOString(); const task: Task = { ...taskData, id: uuidv4(), createdAt: now, updatedAt: now, }; project.tasks.push(task); await this.store.updateProject(project); return task; }