add_task
Adds a task to a specific development phase, enabling structured workflow tracking for coding projects by defining feature requirements and implementation steps.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| featureId | Yes | ||
| phaseId | Yes | ||
| description | Yes |
Implementation Reference
- src/mcp-server.ts:455-496 (registration)Registration of the 'add_task' MCP tool, including inline input schema and execution handler function.server.tool( "add_task", { featureId: z.string().min(1), phaseId: z.string().min(1), description: z.string().min(1) }, async ({ featureId, phaseId, description }) => { const feature = getFeature(featureId); if (!feature) { throw new Error(`Feature ${featureId} not found`); } const phase = feature.phases.find(p => p.id === phaseId); if (!phase) { throw new Error(`Phase ${phaseId} not found in feature ${featureId}`); } const task = addTaskDirectly(feature, phaseId, description); updateFeature(featureId, feature); // Debug log console.error(`DEBUG: Task created with ID: ${task.id}, type: ${typeof task.id}`); console.error(`DEBUG: Task object: ${JSON.stringify(task)}`); // Ensure task.id is explicitly converted to string and check if it's an object let taskId: string; if (typeof task.id === 'object') { taskId = JSON.stringify(task.id); } else { taskId = String(task.id); } return { content: [{ type: "text", text: `Added task "${description.substring(0, 30)}${description.length > 30 ? '...' : ''}" with ID: ${taskId} to phase "${phase.name}"` }] }; } );
- src/mcp-server.ts:76-93 (handler)Helper function used by the add_task handler to directly mutate the feature object by adding a new task to the specified phase.function addTaskDirectly(feature: Feature, phaseId: string, description: string): Task { const phase = feature.phases.find(p => p.id === phaseId); if (!phase) { throw new Error(`Phase ${phaseId} not found`); } const newTask = createTaskObject(description); // Convert task ID to string to ensure it's not an object if (typeof newTask.id !== 'string') { newTask.id = String(newTask.id); } phase.tasks.push(newTask); phase.updatedAt = now(); feature.updatedAt = now(); return newTask; }
- src/phases.ts:89-110 (helper)Supporting function from phases module to add a task to a phase and persist via updateFeature. Similar logic to addTaskDirectly but returns updated feature.export function addTask( featureId: string, phaseId: string, description: string ): Feature | undefined { const feature = getFeature(featureId); if (!feature) return undefined; const phaseIndex = feature.phases.findIndex(p => p.id === phaseId); if (phaseIndex === -1) return undefined; const newTask = createTaskObject(description); const updatedPhases = [...feature.phases]; updatedPhases[phaseIndex] = { ...updatedPhases[phaseIndex], tasks: [...updatedPhases[phaseIndex].tasks, newTask], updatedAt: now() }; return updateFeature(featureId, { phases: updatedPhases }); }