add_task_comment
Add a comment to a task for status updates, AI rationale, or notes, using markdown formatting.
Instructions
Add a comment to a task for status updates, AI rationale, or notes. Supports markdown formatting.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dart_id | Yes | Task dart_id (also accepts "id" or "task_id") | |
| text | Yes | Comment text (markdown supported) |
Implementation Reference
- src/tools/add_task_comment.ts:31-100 (handler)Main handler function `handleAddTaskComment` that validates input (dart_id and text), then calls DartClient.addComment() to add a comment to a task. Handles 404 errors for missing tasks.
export async function handleAddTaskComment( input: unknown ): Promise<AddTaskCommentOutput> { const DART_TOKEN = process.env.DART_TOKEN; if (!DART_TOKEN) { throw new DartAPIError( 'DART_TOKEN environment variable is required. Get your token from: https://app.dartai.com/?settings=account', 401 ); } // Defensive input validation if (!input || typeof input !== 'object') { throw new ValidationError('Input must be a non-null object'); } const typedInput = input as Partial<AddTaskCommentInput>; // Accept id, task_id, or taskId as aliases for dart_id const dartId = resolveDartId(input as unknown as Record<string, unknown>); if (!dartId) { throw new ValidationError( 'dart_id cannot be empty or whitespace-only', 'dart_id' ); } // Validate text if (!typedInput.text || typeof typedInput.text !== 'string') { throw new ValidationError( 'text is required and must be a non-empty string', 'text' ); } // Validate text is not empty/whitespace-only, but preserve original formatting if (typedInput.text.trim() === '') { throw new ValidationError( 'text cannot be empty or whitespace-only', 'text' ); } const dartClient = new DartClient({ token: DART_TOKEN }); try { // Call DartClient.addComment() - use original text to preserve formatting const comment = await dartClient.addComment(dartId, typedInput.text); // Return structured output return { comment_id: comment.comment_id, dart_id: comment.dart_id, text: comment.text, author: comment.author, }; } catch (error) { // Enhanced error handling for 404 (task not found) if (error instanceof DartAPIError && error.statusCode === 404) { throw new DartAPIError( `Task not found: dart_id '${dartId}' does not exist. Check the dart_id or use list_tasks to find valid tasks.`, 404 ); } // Re-throw other errors throw error; } } - src/types/index.ts:740-743 (schema)Input type `AddTaskCommentInput` with dart_id (string) and text (string) fields.
export interface AddTaskCommentInput { dart_id: string; text: string; } - src/types/index.ts:745-750 (schema)Output type `AddTaskCommentOutput` with comment_id, dart_id, text, and author fields.
export interface AddTaskCommentOutput { comment_id: string; dart_id: string; text: string; author: string; } - src/index.ts:804-822 (registration)Tool registration with name 'add_task_comment', description, and inputSchema (dart_id and text required).
// Task Comments { name: 'add_task_comment', description: 'Add a comment to a task for status updates, AI rationale, or notes. Supports markdown formatting.', inputSchema: { type: 'object', properties: { dart_id: { type: 'string', description: 'Task dart_id (also accepts "id" or "task_id")', }, text: { type: 'string', description: 'Comment text (markdown supported)', }, }, required: ['dart_id', 'text'], }, }, - src/index.ts:1184-1194 (registration)Tool dispatch case for 'add_task_comment' calling handleAddTaskComment and returning JSON-stringified result.
case 'add_task_comment': { const result = await handleAddTaskComment((args || {}) as any); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }