update_work_item
Modify Azure DevOps work items by updating fields and managing relationships between items to track project progress and dependencies.
Instructions
Updates a work item by its ID with field changes and relation management.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | No | A list of relations to other work items. | |
| updates | Yes | A dictionary of fields to update. | |
| work_item_id | Yes | The ID of the work item to update. |
Implementation Reference
- mcp_azure_devops/server.py:124-160 (schema)Input schema and tool definition for 'update_work_item', defining required parameters work_item_id and updates, optional relations.types.Tool( name="update_work_item", description="Updates a work item by its ID with field changes and relation management.", inputSchema={ "type": "object", "properties": { "work_item_id": { "type": "integer", "description": "The ID of the work item to update." }, "updates": { "type": "object", "description": "A dictionary of fields to update." }, "relations": { "type": "array", "description": "A list of relations to other work items.", "items": { "type": "object", "properties": { "rel": { "type": "string", "description": "The relation type (e.g., 'System.LinkTypes.Dependency-Forward')." }, "url": { "type": "string", "description": "The URL of the related work item." } }, "required": ["rel", "url"] } } }, "required": ["work_item_id", "updates"], "additionalProperties": False } ),
- mcp_azure_devops/server.py:912-919 (handler)MCP tool handler dispatch for 'update_work_item' in _execute_tool method, calls AzureDevOpsClient.update_work_item and returns formatted response with id, url, title, state.elif name == "update_work_item": work_item = self.client.update_work_item(**arguments) return { "id": work_item.id, "url": work_item.url, "title": work_item.fields.get('System.Title', 'N/A'), "state": work_item.fields.get('System.State', 'N/A') }
- Core helper method implementing update_work_item logic: constructs JsonPatchOperation from updates dict and optional relations list, invokes Azure DevOps work_item_tracking_client.update_work_item API.def update_work_item(self, work_item_id, updates, relations=None): patch_document = [ JsonPatchOperation( op="add", path=f"/fields/{field}", value=value ) for field, value in updates.items() ] if relations: for relation in relations: patch_document.append( JsonPatchOperation( op="add", path="/relations/-", value={ "rel": relation["rel"], "url": relation["url"] } ) ) return self.work_item_tracking_client.update_work_item( document=patch_document, id=work_item_id )