Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

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
NameRequiredDescriptionDefault
commentYesThe text of the comment to add to the work item.
formatNohtml
projectYesThe name or ID of the Azure DevOps project.
workItemIdYesThe ID of the work item to add a comment to.

Implementation Reference

  • 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 }], }; }
  • 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"), },
  • 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 }], }; } );
  • Definition of the tool name constant in WORKITEM_TOOLS object.
    add_work_item_comment: "wit_add_work_item_comment",

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ennuiii/DevOpsMcpPAT'

If you have feedback or need assistance with the MCP directory API, please join our Discord server