wit_add_work_item_comment
Add comments to Azure DevOps work items using ID, specifying text and format (markdown or HTML) for efficient task collaboration and updates.
Instructions
Add comment to a work item by ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| comment | Yes | The text of the comment to add to the work item. | |
| format | No | html | |
| project | Yes | The name or ID of the Azure DevOps project. | |
| workItemId | Yes | The ID of the work item to add a comment to. |
Implementation Reference
- src/tools/workitems.ts:231-261 (handler)The handler function that implements the tool logic: adds a comment to a work item by making a POST request to the Azure DevOps Comments API.async ({ project, workItemId, comment, format }) => { const connection = await connectionProvider(); const orgUrl = connection.serverUrl; const accessToken = await tokenProvider(); const body = { text: comment, }; const formatParameter = format === "markdown" ? 0 : 1; const response = await fetch(`${orgUrl}/${project}/_apis/wit/workItems/${workItemId}/comments?format=${formatParameter}&api-version=${markdownCommentsApiVersion}`, { method: "POST", headers: { "Authorization": `Bearer ${accessToken.token}`, "Content-Type": "application/json", "User-Agent": userAgentProvider(), }, body: JSON.stringify(body), }); if (!response.ok) { throw new Error(`Failed to add a work item comment: ${response.statusText}}`); } const comments = await response.text(); return { content: [{ type: "text", text: comments }], }; }
- src/tools/workitems.ts:225-230 (schema)Zod input schema defining parameters: project, workItemId, comment, and optional format (markdown or html).{ project: z.string().describe("The name or ID of the Azure DevOps project."), workItemId: z.number().describe("The ID of the work item to add a comment to."), comment: z.string().describe("The text of the comment to add to the work item."), format: z.enum(["markdown", "html"]).optional().default("html"), },
- src/tools/workitems.ts:222-262 (registration)Registration of the tool using McpServer.tool() call with name from WORKITEM_TOOLS.add_work_item_comment, description, schema, and handler.server.tool( WORKITEM_TOOLS.add_work_item_comment, "Add comment to a work item by ID.", { project: z.string().describe("The name or ID of the Azure DevOps project."), workItemId: z.number().describe("The ID of the work item to add a comment to."), comment: z.string().describe("The text of the comment to add to the work item."), format: z.enum(["markdown", "html"]).optional().default("html"), }, async ({ project, workItemId, comment, format }) => { const connection = await connectionProvider(); const orgUrl = connection.serverUrl; const accessToken = await tokenProvider(); const body = { text: comment, }; const formatParameter = format === "markdown" ? 0 : 1; const response = await fetch(`${orgUrl}/${project}/_apis/wit/workItems/${workItemId}/comments?format=${formatParameter}&api-version=${markdownCommentsApiVersion}`, { method: "POST", headers: { "Authorization": `Bearer ${accessToken.token}`, "Content-Type": "application/json", "User-Agent": userAgentProvider(), }, body: JSON.stringify(body), }); if (!response.ok) { throw new Error(`Failed to add a work item comment: ${response.statusText}}`); } const comments = await response.text(); return { content: [{ type: "text", text: comments }], }; } );
- src/tools/workitems.ts:22-22 (registration)Definition of the tool name constant in WORKITEM_TOOLS object.add_work_item_comment: "wit_add_work_item_comment",