Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

wit_work_items_link

Batch link work items in Azure DevOps projects using specified relationships like parent, child, or related, with optional comments for context.

Instructions

Link work items together in batch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesThe name or ID of the Azure DevOps project.
updatesYes

Implementation Reference

  • Handler function that links work items together in batch by grouping updates by work item ID, constructing JSON patch documents to add relations, and sending a batch PATCH request to the Azure DevOps Work Item Tracking API.
    async ({ project, updates }) => { const connection = await connectionProvider(); const orgUrl = connection.serverUrl; const accessToken = await tokenProvider(); // Extract unique IDs from the updates array const uniqueIds = Array.from(new Set(updates.map((update) => update.id))); const body = uniqueIds.map((id) => ({ method: "PATCH", uri: `/_apis/wit/workitems/${id}?api-version=${batchApiVersion}`, headers: { "Content-Type": "application/json-patch+json", }, body: updates .filter((update) => update.id === id) .map(({ linkToId, type, comment }) => ({ op: "add", path: "/relations/-", value: { rel: `${getLinkTypeFromName(type)}`, url: `${orgUrl}/${project}/_apis/wit/workItems/${linkToId}`, attributes: { comment: comment || "", }, }, })), })); const response = await fetch(`${orgUrl}/_apis/wit/$batch?api-version=${batchApiVersion}`, { method: "PATCH", headers: { "Authorization": `Bearer ${accessToken.token}`, "Content-Type": "application/json", "User-Agent": userAgentProvider(), }, body: JSON.stringify(body), }); if (!response.ok) { throw new Error(`Failed to update work items in batch: ${response.statusText}`); } const result = await response.json(); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
  • Zod schema defining the input parameters for the tool: project name/ID and an array of updates each specifying work item IDs to link and link type.
    { project: z.string().describe("The name or ID of the Azure DevOps project."), updates: z .array( z.object({ id: z.number().describe("The ID of the work item to update."), linkToId: z.number().describe("The ID of the work item to link to."), type: z .enum(["parent", "child", "duplicate", "duplicate of", "related", "successor", "predecessor", "tested by", "tests", "affects", "affected by"]) .default("related") .describe( "Type of link to create between the work items. Options include 'parent', 'child', 'duplicate', 'duplicate of', 'related', 'successor', 'predecessor', 'tested by', 'tests', 'affects', and 'affected by'. Defaults to 'related'." ), comment: z.string().optional().describe("Optional comment to include with the link. This can be used to provide additional context for the link being created."), }) ) .describe(""), },
  • Constant definition mapping the internal tool identifier 'work_items_link' to the MCP tool name 'wit_work_items_link'.
    work_items_link: "wit_work_items_link",
  • Helper function mapping user-friendly link type names to Azure DevOps internal link type reference names, used in the handler to construct relation objects.
    function getLinkTypeFromName(name: string) { switch (name.toLowerCase()) { case "parent": return "System.LinkTypes.Hierarchy-Reverse"; case "child": return "System.LinkTypes.Hierarchy-Forward"; case "duplicate": return "System.LinkTypes.Duplicate-Forward"; case "duplicate of": return "System.LinkTypes.Duplicate-Reverse"; case "related": return "System.LinkTypes.Related"; case "successor": return "System.LinkTypes.Dependency-Forward"; case "predecessor": return "System.LinkTypes.Dependency-Reverse"; case "tested by": return "Microsoft.VSTS.Common.TestedBy-Forward"; case "tests": return "Microsoft.VSTS.Common.TestedBy-Reverse"; case "affects": return "Microsoft.VSTS.Common.Affects-Forward"; case "affected by": return "Microsoft.VSTS.Common.Affects-Reverse"; case "artifact": return "ArtifactLink"; default: throw new Error(`Unknown link type: ${name}`); } }

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