Skip to main content
Glama

update_work_item

Modifies work items in Azure DevOps by updating fields like title, description, priority, state, assigned user, and area or iteration paths.

Instructions

Update an existing work item

Input Schema

NameRequiredDescriptionDefault
additionalFieldsNoAdditional fields to update on the work item
areaPathNoThe updated area path for the work item
assignedToNoThe email or name of the user to assign the work item to
descriptionNoThe updated description of the work item
iterationPathNoThe updated iteration path for the work item
priorityNoThe updated priority of the work item
stateNoThe updated state of the work item
titleNoThe updated title of the work item
workItemIdYesThe ID of the work item to update

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "additionalFields": { "additionalProperties": {}, "description": "Additional fields to update on the work item", "type": "object" }, "areaPath": { "description": "The updated area path for the work item", "type": "string" }, "assignedTo": { "description": "The email or name of the user to assign the work item to", "type": "string" }, "description": { "description": "The updated description of the work item", "type": "string" }, "iterationPath": { "description": "The updated iteration path for the work item", "type": "string" }, "priority": { "description": "The updated priority of the work item", "type": "number" }, "state": { "description": "The updated state of the work item", "type": "string" }, "title": { "description": "The updated title of the work item", "type": "string" }, "workItemId": { "description": "The ID of the work item to update", "type": "number" } }, "required": [ "workItemId" ], "type": "object" }

Implementation Reference

  • The core handler function that performs the work item update by building a JSON patch document from the provided options and calling the Azure DevOps API.
    export async function updateWorkItem( connection: WebApi, workItemId: number, options: UpdateWorkItemOptions, ): Promise<WorkItem> { try { const witApi = await connection.getWorkItemTrackingApi(); // Create the JSON patch document const document = []; // Add optional fields if provided if (options.title) { document.push({ op: 'add', path: '/fields/System.Title', value: options.title, }); } if (options.description) { document.push({ op: 'add', path: '/fields/System.Description', value: options.description, }); } if (options.assignedTo) { document.push({ op: 'add', path: '/fields/System.AssignedTo', value: options.assignedTo, }); } if (options.areaPath) { document.push({ op: 'add', path: '/fields/System.AreaPath', value: options.areaPath, }); } if (options.iterationPath) { document.push({ op: 'add', path: '/fields/System.IterationPath', value: options.iterationPath, }); } if (options.priority) { document.push({ op: 'add', path: '/fields/Microsoft.VSTS.Common.Priority', value: options.priority, }); } if (options.state) { document.push({ op: 'add', path: '/fields/System.State', value: options.state, }); } // Add any additional fields if (options.additionalFields) { for (const [key, value] of Object.entries(options.additionalFields)) { document.push({ op: 'add', path: `/fields/${key}`, value: value, }); } } // If no fields to update, throw an error if (document.length === 0) { throw new Error('At least one field must be provided for update'); } // Update the work item const updatedWorkItem = await witApi.updateWorkItem( {}, // customHeaders document, workItemId, undefined, // project false, // validateOnly false, // bypassRules false, // suppressNotifications WorkItemExpand.All, // expand ); if (!updatedWorkItem) { throw new AzureDevOpsResourceNotFoundError( `Work item '${workItemId}' not found`, ); } return updatedWorkItem; } catch (error) { if (error instanceof AzureDevOpsError) { throw error; } throw new Error( `Failed to update work item: ${error instanceof Error ? error.message : String(error)}`, ); } }
  • Zod schema defining the input schema for the update_work_item tool, used for validation in the handler.
    export const UpdateWorkItemSchema = z.object({ workItemId: z.number().describe('The ID of the work item to update'), title: z.string().optional().describe('The updated title of the work item'), description: z .string() .optional() .describe( 'Work item description in HTML format. Multi-line text fields (i.e., System.History, AcceptanceCriteria, etc.) must use HTML format. Do not use CDATA tags.', ), assignedTo: z .string() .optional() .describe('The email or name of the user to assign the work item to'), areaPath: z .string() .optional() .describe('The updated area path for the work item'), iterationPath: z .string() .optional() .describe('The updated iteration path for the work item'), priority: z .number() .optional() .describe('The updated priority of the work item'), state: z.string().optional().describe('The updated state of the work item'), additionalFields: z .record(z.string(), z.any()) .optional() .describe( 'Additional fields to update on the work item. Multi-line text fields (i.e., System.History, AcceptanceCriteria, etc.) must use HTML format. Do not use CDATA tags.', ), });
  • The ToolDefinition registration for the update_work_item tool, providing name, description, and JSON schema for MCP.
    { name: 'update_work_item', description: 'Update an existing work item', inputSchema: zodToJsonSchema(UpdateWorkItemSchema), },
  • Dispatch handler case in the work-items request handler that parses arguments with the schema and delegates to the core updateWorkItem function.
    case 'update_work_item': { const args = UpdateWorkItemSchema.parse(request.params.arguments); const result = await updateWorkItem(connection, args.workItemId, { title: args.title, description: args.description, assignedTo: args.assignedTo, areaPath: args.areaPath, iterationPath: args.iterationPath, priority: args.priority, state: args.state, additionalFields: args.additionalFields, }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
  • TypeScript interface defining the options passed to the updateWorkItem handler function.
    export interface UpdateWorkItemOptions { title?: string; description?: string; assignedTo?: string; areaPath?: string; iterationPath?: string; priority?: number; state?: string; additionalFields?: Record<string, string | number | boolean | null>; }

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/Tiberriver256/mcp-server-azure-devops'

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