import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { api } from "../api/client.js";
import { formatResponse } from "../utils/index.js";
import { CommentTypeSchema } from "../types/index.js";
export function registerCommentTools(server: McpServer) {
// Add a comment to a task
server.tool(
"add_comment",
"Add a comment to a task",
{
board_id: z.number().int().positive().describe("Board ID"),
task_id: z.number().int().positive().describe("Task ID"),
comment: z.string().min(1).describe("Comment text"),
comment_type: CommentTypeSchema.default("comment").describe(
"Comment type - 'comment' for new comments, 'reply' for replies"
),
parent_id: z
.number()
.int()
.positive()
.optional()
.describe("Parent comment ID (required for replies)"),
notify_users: z
.array(z.number().int().positive())
.optional()
.describe("User IDs to notify"),
},
async (args) => {
const {
board_id,
task_id,
comment,
comment_type,
parent_id,
notify_users,
} = args;
const commentData: any = {
comment: comment,
comment_type: comment_type,
};
if (parent_id) {
commentData.parent_id = parent_id;
}
if (notify_users && notify_users.length > 0) {
commentData.notify_users = notify_users;
}
const response = await api.post(
`/projects/${board_id}/tasks/${task_id}/comments`,
commentData
);
return formatResponse(response.data);
}
);
}