comment_add
Add a comment to a task to maintain a chronological discussion thread, enabling context preservation across sessions.
Instructions
Add a comment to a task. Comments create a chronological discussion thread — useful for leaving breadcrumbs across sessions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | Task ID to comment on | |
| content | Yes | Comment text | |
| author | No | Author name (optional) |
Implementation Reference
- src/tools/comments.ts:6-21 (schema)Tool definition and input schema for 'comment_add' — requires task_id (integer) and content (string), with optional author (string).
export const definitions: Tool[] = [ { name: 'comment_add', description: 'Add a comment to a task. Comments create a chronological discussion thread — useful for leaving breadcrumbs across sessions.', annotations: { title: 'Add Comment', readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }, inputSchema: { type: 'object', properties: { task_id: { type: 'integer', description: 'Task ID to comment on' }, content: { type: 'string', description: 'Comment text' }, author: { type: 'string', description: 'Author name (optional)' }, }, required: ['task_id', 'content'], }, }, - src/tools/comments.ts:36-55 (handler)Handler function 'handleCommentAdd' that validates the task exists, inserts a comment into the 'comments' table, logs activity, and returns the created comment.
function handleCommentAdd(args: Record<string, unknown>) { const db = getDb(); const taskId = args.task_id as number; const content = args.content as string; const author = (args.author as string) ?? null; // Verify task exists const task = db.prepare('SELECT id, title FROM tasks WHERE id = ?').get(taskId) as { id: number; title: string } | undefined; if (!task) throw new Error(`Task ${taskId} not found`); const comment = db .prepare('INSERT INTO comments (task_id, author, content) VALUES (?, ?, ?) RETURNING *') .get(taskId, author, content); const row = comment as Record<string, unknown>; logActivity(db, 'comment', row.id as number, 'created', null, null, null, `Comment added to task '${task.title}'${author ? ` by ${author}` : ''}`); return comment; } - src/tools/comments.ts:66-69 (registration)Exported handlers mapping 'comment_add' to handleCommentAdd, imported and spread into ALL_HANDLERS in src/index.ts.
export const handlers: Record<string, ToolHandler> = { comment_add: handleCommentAdd, comment_list: handleCommentList, }; - src/index.ts:23-35 (registration)Global ALL_TOOLS array that includes commentDefs, registering the comment_add tool with the MCP server.
const ALL_TOOLS: Tool[] = [ ...projectDefs, ...epicDefs, ...taskDefs, ...subtaskDefs, ...noteDefs, ...commentDefs, ...templateDefs, ...dashboardDefs, ...searchDefs, ...activityDefs, ...exportImportDefs, ]; - src/index.ts:37-49 (registration)Global ALL_HANDLERS record merging all tool handlers, including commentHandlers which maps 'comment_add' to handleCommentAdd.
const ALL_HANDLERS: Record<string, (args: Record<string, unknown>) => unknown> = { ...projectHandlers, ...epicHandlers, ...taskHandlers, ...subtaskHandlers, ...noteHandlers, ...commentHandlers, ...templateHandlers, ...dashboardHandlers, ...searchHandlers, ...activityHandlers, ...exportImportHandlers, };