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}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'link work items together in batch' implies a write operation, it doesn't disclose important behavioral traits like whether this requires specific permissions, whether links are reversible, what happens on partial failures in batch operations, rate limits, or what the response format looks like. The description is insufficient for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just 6 words, with zero wasted language. It's front-loaded with the core action and immediately specifies the batch scope. Every word earns its place in this minimal but complete statement of function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a batch mutation tool with no annotations, no output schema, and incomplete parameter documentation, the description is inadequate. It should explain more about the batch operation behavior, error handling, permissions required, and what constitutes a successful response. The current description leaves too many operational questions unanswered for a tool that modifies data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50%, with the 'project' parameter well-described but the 'updates' array having only partial documentation. The description adds no parameter semantics beyond what's in the schema - it doesn't explain the structure of batch updates, provide examples of valid link types, or clarify how multiple updates are processed. The baseline 3 reflects that the schema does some work but the description doesn't compensate for the coverage gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('link work items together') and scope ('in batch'), which provides a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'wit_link_work_item_to_pull_request' or 'wit_work_item_unlink', which would require mentioning the batch nature or specific linking context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites like required permissions, when batch linking is appropriate versus single operations, or how it differs from related sibling tools such as 'wit_link_work_item_to_pull_request' or 'wit_work_item_unlink'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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