update_work_item
Modify work items in Azure DevOps by updating fields and managing relationships between items to track 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 |
|---|---|---|---|
| work_item_id | Yes | The ID of the work item to update. | |
| updates | Yes | A dictionary of fields to update. | |
| relations | No | A list of relations to other work items. |
Implementation Reference
- Core handler function that constructs the JSON patch operations for field updates and relations, then invokes the Azure DevOps API to update the work item.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 )
- mcp_azure_devops/server.py:124-160 (schema)Defines the input schema and description for the update_work_item tool, specifying parameters work_item_id, updates, and 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 server dispatch handler that calls the client.update_work_item method with tool arguments and formats the response.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') }
- mcp_azure_devops/server.py:857-862 (registration)Registers the list of tools including update_work_item via the MCP list_tools handler.@self.server.list_tools() async def list_tools() -> List[types.Tool]: """Return the list of available tools.""" logger.info(f"Tools requested - returning {len(self.tools)} tools") self.tools_registered = True return self.tools