Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

wit_add_child_work_items

Create multiple child work items under a parent work item in Azure DevOps. Specify the work item type, parent ID, project, and details like title, description, area, and iteration paths.

Instructions

Create one or many child work items from a parent by work item type and parent id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes
parentIdYesThe ID of the parent work item to create a child work item under.
projectYesThe name or ID of the Azure DevOps project.
workItemTypeYesThe type of the child work item to create.

Implementation Reference

  • The handler function that creates one or more child work items under a specified parent work item using the Azure DevOps WIT batch API. It constructs PATCH operations to set title, description, repro steps, link to parent, and optional area/iteration paths and markdown formatting.
    async ({ parentId, project, workItemType, items }) => {
      try {
        const connection = await connectionProvider();
        const orgUrl = connection.serverUrl;
        const accessToken = await tokenProvider();
    
        if (items.length > 50) {
          return {
            content: [{ type: "text", text: `A maximum of 50 child work items can be created in a single call.` }],
            isError: true,
          };
        }
    
        const body = items.map((item, x) => {
          const ops = [
            {
              op: "add",
              path: "/id",
              value: `-${x + 1}`,
            },
            {
              op: "add",
              path: "/fields/System.Title",
              value: item.title,
            },
            {
              op: "add",
              path: "/fields/System.Description",
              value: item.description,
            },
            {
              op: "add",
              path: "/fields/Microsoft.VSTS.TCM.ReproSteps",
              value: item.description,
            },
            {
              op: "add",
              path: "/relations/-",
              value: {
                rel: "System.LinkTypes.Hierarchy-Reverse",
                url: `${connection.serverUrl}/${project}/_apis/wit/workItems/${parentId}`,
              },
            },
          ];
    
          if (item.areaPath && item.areaPath.trim().length > 0) {
            ops.push({
              op: "add",
              path: "/fields/System.AreaPath",
              value: item.areaPath,
            });
          }
    
          if (item.iterationPath && item.iterationPath.trim().length > 0) {
            ops.push({
              op: "add",
              path: "/fields/System.IterationPath",
              value: item.iterationPath,
            });
          }
    
          if (item.format && item.format === "Markdown") {
            ops.push({
              op: "add",
              path: "/multilineFieldsFormat/System.Description",
              value: item.format,
            });
    
            ops.push({
              op: "add",
              path: "/multilineFieldsFormat/Microsoft.VSTS.TCM.ReproSteps",
              value: item.format,
            });
          }
    
          return {
            method: "PATCH",
            uri: `/${project}/_apis/wit/workitems/$${workItemType}?api-version=${batchApiVersion}`,
            headers: {
              "Content-Type": "application/json-patch+json",
            },
            body: ops,
          };
        });
    
        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) }],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
    
        return {
          content: [{ type: "text", text: `Error creating child work items: ${errorMessage}` }],
          isError: true,
        };
      }
    }
  • Zod schema defining the input parameters for the tool: parentId, project, workItemType, and an array of child item details (title, description, format, optional areaPath and iterationPath).
      parentId: z.number().describe("The ID of the parent work item to create a child work item under."),
      project: z.string().describe("The name or ID of the Azure DevOps project."),
      workItemType: z.string().describe("The type of the child work item to create."),
      items: z.array(
        z.object({
          title: z.string().describe("The title of the child work item."),
          description: z.string().describe("The description of the child work item."),
          format: z.enum(["Markdown", "Html"]).default("Html").describe("Format for the description on the child work item, e.g., 'Markdown', 'Html'. Defaults to 'Html'."),
          areaPath: z.string().optional().describe("Optional area path for the child work item."),
          iterationPath: z.string().optional().describe("Optional iteration path for the child work item."),
        })
      ),
    },
  • Registers the 'wit_add_child_work_items' tool with the MCP server using server.tool(), referencing WORKITEM_TOOLS.add_child_work_items, providing description, input schema, and handler function.
    server.tool(
      WORKITEM_TOOLS.add_child_work_items,
      "Create one or many child work items from a parent by work item type and parent id.",
      {
        parentId: z.number().describe("The ID of the parent work item to create a child work item under."),
        project: z.string().describe("The name or ID of the Azure DevOps project."),
        workItemType: z.string().describe("The type of the child work item to create."),
        items: z.array(
          z.object({
            title: z.string().describe("The title of the child work item."),
            description: z.string().describe("The description of the child work item."),
            format: z.enum(["Markdown", "Html"]).default("Html").describe("Format for the description on the child work item, e.g., 'Markdown', 'Html'. Defaults to 'Html'."),
            areaPath: z.string().optional().describe("Optional area path for the child work item."),
            iterationPath: z.string().optional().describe("Optional iteration path for the child work item."),
          })
        ),
      },
      async ({ parentId, project, workItemType, items }) => {
        try {
          const connection = await connectionProvider();
          const orgUrl = connection.serverUrl;
          const accessToken = await tokenProvider();
    
          if (items.length > 50) {
            return {
              content: [{ type: "text", text: `A maximum of 50 child work items can be created in a single call.` }],
              isError: true,
            };
          }
    
          const body = items.map((item, x) => {
            const ops = [
              {
                op: "add",
                path: "/id",
                value: `-${x + 1}`,
              },
              {
                op: "add",
                path: "/fields/System.Title",
                value: item.title,
              },
              {
                op: "add",
                path: "/fields/System.Description",
                value: item.description,
              },
              {
                op: "add",
                path: "/fields/Microsoft.VSTS.TCM.ReproSteps",
                value: item.description,
              },
              {
                op: "add",
                path: "/relations/-",
                value: {
                  rel: "System.LinkTypes.Hierarchy-Reverse",
                  url: `${connection.serverUrl}/${project}/_apis/wit/workItems/${parentId}`,
                },
              },
            ];
    
            if (item.areaPath && item.areaPath.trim().length > 0) {
              ops.push({
                op: "add",
                path: "/fields/System.AreaPath",
                value: item.areaPath,
              });
            }
    
            if (item.iterationPath && item.iterationPath.trim().length > 0) {
              ops.push({
                op: "add",
                path: "/fields/System.IterationPath",
                value: item.iterationPath,
              });
            }
    
            if (item.format && item.format === "Markdown") {
              ops.push({
                op: "add",
                path: "/multilineFieldsFormat/System.Description",
                value: item.format,
              });
    
              ops.push({
                op: "add",
                path: "/multilineFieldsFormat/Microsoft.VSTS.TCM.ReproSteps",
                value: item.format,
              });
            }
    
            return {
              method: "PATCH",
              uri: `/${project}/_apis/wit/workitems/$${workItemType}?api-version=${batchApiVersion}`,
              headers: {
                "Content-Type": "application/json-patch+json",
              },
              body: ops,
            };
          });
    
          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) }],
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
    
          return {
            content: [{ type: "text", text: `Error creating child work items: ${errorMessage}` }],
            isError: true,
          };
        }
      }
    );
  • Constant object mapping internal tool identifiers to MCP tool names, including add_child_work_items: 'wit_add_child_work_items'.
    const WORKITEM_TOOLS = {
      my_work_items: "wit_my_work_items",
      list_backlogs: "wit_list_backlogs",
      list_backlog_work_items: "wit_list_backlog_work_items",
      get_work_item: "wit_get_work_item",
      get_work_items_batch_by_ids: "wit_get_work_items_batch_by_ids",
      update_work_item: "wit_update_work_item",
      create_work_item: "wit_create_work_item",
      list_work_item_comments: "wit_list_work_item_comments",
      get_work_items_for_iteration: "wit_get_work_items_for_iteration",
      add_work_item_comment: "wit_add_work_item_comment",
      add_child_work_items: "wit_add_child_work_items",
      link_work_item_to_pull_request: "wit_link_work_item_to_pull_request",
      get_work_item_type: "wit_get_work_item_type",
      get_query: "wit_get_query",
      get_query_results_by_id: "wit_get_query_results_by_id",
      update_work_items_batch: "wit_update_work_items_batch",
      work_items_link: "wit_work_items_link",
      work_item_unlink: "wit_work_item_unlink",
      add_artifact_link: "wit_add_artifact_link",
    };
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 of behavioral disclosure. While it indicates a creation action ('Create'), it doesn't specify whether this requires specific permissions, what happens on success (e.g., returns IDs), or potential side effects like updating the parent work item. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 action ('Create one or many child work items') and includes key parameters. There is no wasted language or redundancy, making it highly concise and well-structured for quick comprehension.

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?

Given that this is a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't cover behavioral aspects like permissions, response format, or error handling, and it lacks usage guidance compared to sibling tools. The high schema coverage helps with parameters, but overall completeness is poor for a tool that creates multiple work items.

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 75%, providing good documentation for most parameters. The description adds minimal value by mentioning 'parent id' and 'work item type', which are already covered in the schema. It doesn't explain the 'items' array structure or the 'project' parameter beyond what the schema provides, so it meets the baseline for high schema coverage without enhancing parameter understanding.

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 ('Create one or many child work items') and the target resource ('from a parent by work item type and parent id'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'wit_create_work_item' or 'wit_update_work_item', which would require mentioning the parent-child relationship specificity.

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_create_work_item' for standalone work items or 'wit_update_work_item' for modifications. It lacks context about prerequisites, such as needing an existing parent work item, and doesn't mention any exclusions or scenarios where other tools might be more appropriate.

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