Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

wit_link_work_item_to_pull_request

Link a specific work item to an existing pull request in Azure DevOps using project, repository, and work item IDs for streamlined tracking and collaboration.

Instructions

Link a single work item to an existing pull request.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesThe project ID of the Azure DevOps project (note: project name is not valid).
pullRequestIdYesThe ID of the pull request to link to.
pullRequestProjectIdNoThe project ID containing the pull request. If not provided, defaults to the work item's project ID (for same-project linking).
repositoryIdYesThe ID of the repository containing the pull request. Do not use the repository name here, use the ID instead.
workItemIdYesThe ID of the work item to link to the pull request.

Implementation Reference

  • Maps the friendly name 'link_work_item_to_pull_request' to the MCP tool name 'wit_link_work_item_to_pull_request' in the WORKITEM_TOOLS constant used for registration.
    link_work_item_to_pull_request: "wit_link_work_item_to_pull_request",
  • Zod schema defining the input parameters for the tool.
    {
      projectId: z.string().describe("The project ID of the Azure DevOps project (note: project name is not valid)."),
      repositoryId: z.string().describe("The ID of the repository containing the pull request. Do not use the repository name here, use the ID instead."),
      pullRequestId: z.number().describe("The ID of the pull request to link to."),
      workItemId: z.number().describe("The ID of the work item to link to the pull request."),
      pullRequestProjectId: z.string().optional().describe("The project ID containing the pull request. If not provided, defaults to the work item's project ID (for same-project linking)."),
    },
  • The handler function that executes the tool: constructs a VSTFS URI for the pull request (vstfs:///Git/PullRequestId/...), creates a PATCH document to add an 'ArtifactLink' relation to the work item, and updates the work item via the Azure DevOps WorkItemTrackingApi.
      async ({ projectId, repositoryId, pullRequestId, workItemId, pullRequestProjectId }) => {
        try {
          const connection = await connectionProvider();
          const workItemTrackingApi = await connection.getWorkItemTrackingApi();
    
          // Create artifact link relation using vstfs format
          // Format: vstfs:///Git/PullRequestId/{project}/{repositoryId}/{pullRequestId}
          const artifactProjectId = pullRequestProjectId && pullRequestProjectId.trim() !== "" ? pullRequestProjectId : projectId;
          const artifactPathValue = `${artifactProjectId}/${repositoryId}/${pullRequestId}`;
          const vstfsUrl = `vstfs:///Git/PullRequestId/${encodeURIComponent(artifactPathValue)}`;
    
          // Use the PATCH document format for adding a relation
          const patchDocument = [
            {
              op: "add",
              path: "/relations/-",
              value: {
                rel: "ArtifactLink",
                url: vstfsUrl,
                attributes: {
                  name: "Pull Request",
                },
              },
            },
          ];
    
          // Use the WorkItem API to update the work item with the new relation
          const workItem = await workItemTrackingApi.updateWorkItem({}, patchDocument, workItemId, projectId);
    
          if (!workItem) {
            return { content: [{ type: "text", text: "Work item update failed" }], isError: true };
          }
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(
                  {
                    workItemId,
                    pullRequestId,
                    success: true,
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
    
          return {
            content: [{ type: "text", text: `Error linking work item to pull request: ${errorMessage}` }],
            isError: true,
          };
        }
      }
    );
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the tool creates a link (a write operation) but doesn't disclose behavioral traits like required permissions, whether the link is reversible, error conditions, or rate limits. This is a significant gap 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 a single, efficient sentence that front-loads the core purpose with zero waste. Every word earns its place, making it easy to parse quickly.

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 mutation tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral aspects like permissions, side effects, or response format, leaving critical gaps for an AI agent to understand how to invoke it correctly.

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 100%, so the schema already documents all 5 parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, such as explaining relationships between parameters or usage nuances. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Link'), the resource ('a single work item'), and the target ('to an existing pull request'). It distinguishes from sibling tools like 'wit_work_items_link' (which might link multiple items) and 'wit_work_item_unlink' (which does the opposite).

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 like 'wit_add_artifact_link' or 'wit_work_items_link', nor does it mention prerequisites or exclusions. It simply states what the tool does without contextual usage information.

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