create_task
Create new tasks with unique IDs, descriptions, and dependency tracking for coordinated workflow management.
Instructions
Create a new task
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique identifier for the task | |
| description | Yes | Description of the task | |
| dependencies | No | IDs of tasks that must be completed first |
Implementation Reference
- src/index.ts:90-129 (handler)The core handler logic for the 'create_task' tool. It extracts arguments, checks if task ID exists, validates dependencies exist, creates a new pending Task, saves to persistent storage, and returns the task as JSON text.case "create_task": { const { id, description, dependencies } = request.params.arguments as { id: string; description: string; dependencies?: string[]; }; debug(`Creating task ${id}: ${description}`); if (tasks[id]) { throw new McpError(ErrorCode.InvalidRequest, `Task ${id} already exists`); } // Verify dependencies exist if (dependencies) { for (const depId of dependencies) { if (!tasks[depId]) { throw new McpError(ErrorCode.InvalidRequest, `Dependency task ${depId} not found`); } } } const task: Task = { id, description, status: 'pending', dependencies }; tasks[id] = task; saveTasks(); debug(`Created task ${id}`); return { content: [{ type: "text", text: JSON.stringify(task, null, 2) }] }; }
- src/index.ts:338-362 (schema)The input schema and metadata for the 'create_task' tool, defined in the ListToolsRequestSchema response. Specifies required id and description, optional dependencies array.{ name: "create_task", description: "Create a new task", inputSchema: { type: "object", properties: { id: { type: "string", description: "Unique identifier for the task" }, description: { type: "string", description: "Description of the task" }, dependencies: { type: "array", items: { type: "string" }, description: "IDs of tasks that must be completed first" } }, required: ["id", "description"] } },
- src/index.ts:21-28 (schema)TypeScript interface defining the structure of a Task object used throughout the task management tools, including create_task.interface Task { id: string; description: string; status: 'pending' | 'in_progress' | 'completed'; assignedTo?: string; result?: string; dependencies?: string[]; }
- src/index.ts:49-62 (helper)Helper function to persist the tasks object to tasks.json file. Called after creating, updating, or completing tasks to ensure durability.function saveTasks() { try { // Create data directory if it doesn't exist const dataDir = dirname(TASKS_FILE); if (!existsSync(dataDir)) { const { mkdirSync } = require('fs'); mkdirSync(dataDir, { recursive: true }); } writeFileSync(TASKS_FILE, JSON.stringify(tasks, null, 2)); debug('Saved tasks to file'); } catch (error) { console.error('Error saving tasks:', error); } }