update_work_item
Modify Azure DevOps work items by applying JSON patch operations to update fields, status, or other attributes.
Instructions
Update an existing work item using JSON patch operations
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | ID of the work item to update | |
| document | Yes | Array of JSON patch operations to apply |
Implementation Reference
- src/tools/work-item/update.ts:7-31 (handler)The main handler function that executes the update_work_item tool, validating inputs, initializing Azure DevOps connection, calling the API to update the work item, and returning the result.
export async function updateWorkItem(args: { id: number; document: JsonPatchOperation[] }, config: AzureDevOpsConfig) { if (!args.id || !args.document || !args.document.length) { throw new McpError(ErrorCode.InvalidParams, 'Work item ID and patch document are required'); } AzureDevOpsConnection.initialize(config); const connection = AzureDevOpsConnection.getInstance(); const workItemTrackingApi = await connection.getWorkItemTrackingApi(); const workItem = await workItemTrackingApi.updateWorkItem( undefined, args.document, args.id, config.project ); return { content: [ { type: 'text', text: JSON.stringify(workItem, null, 2), }, ], }; } - src/tools/work-item/index.ts:99-134 (schema)Input schema definition for the update_work_item tool, including name, description, and validation rules for id and document parameters.
{ name: 'update_work_item', description: 'Update an existing work item using JSON patch operations', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'ID of the work item to update', }, document: { type: 'array', items: { type: 'object', properties: { op: { type: 'string', enum: ['add', 'remove', 'replace', 'move', 'copy', 'test'], description: 'The patch operation to perform', }, path: { type: 'string', description: 'The path for the operation (e.g., /fields/System.Title)', }, value: { description: 'The value for the operation', }, }, required: ['op', 'path'], }, description: 'Array of JSON patch operations to apply', }, }, required: ['id', 'document'], }, }, - src/tools/work-item/index.ts:137-146 (registration)Registration of the workItemTools, including the updateWorkItem handler wrapper and shared definitions array containing the tool schema.
export const workItemTools = { initialize: (config: AzureDevOpsConfig) => ({ getWorkItem: (args: WorkItemBatchGetRequest) => getWorkItem(args, config), listWorkItems: (args: Wiql) => listWorkItems(args, config), createWorkItem: (args: { type: string; document: JsonPatchOperation[] }) => createWorkItem(args, config), updateWorkItem: (args: { id: number; document: JsonPatchOperation[] }) => updateWorkItem(args, config), definitions, }), definitions, };