Skip to main content
Glama

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
NameRequiredDescriptionDefault
work_item_idYesThe ID of the work item to update.
updatesYesA dictionary of fields to update.
relationsNoA 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
        )
  • 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 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')
        }
  • 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

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

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