Skip to main content
Glama

get_work_item_transitions

Retrieve valid state transitions for Azure DevOps work items to maintain proper workflow compliance when moving between statuses.

Instructions

Get valid state transitions for a work item type from a specific state to ensure proper workflow.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectYesThe name or ID of the project.
work_item_typeYesThe work item type (e.g., 'Bug', 'User Story', 'Task').
from_stateYesThe current state to get valid transitions from.

Implementation Reference

  • The core handler function that retrieves valid state transitions for a work item type from a specific state using the Azure DevOps API.
    def get_work_item_transitions(self, project, work_item_type, from_state):
        """
        Get valid state transitions for a work item type from a specific state.
        """
        try:
            # This requires calling the process configuration API
            # which might not be directly available in the Python SDK
            # We'll use the work item type to get transition info
            work_item_type_obj = self.work_item_tracking_client.get_work_item_type(
                project=project,
                type=work_item_type
            )
            
            # Extract transition rules if available
            transitions = []
            if hasattr(work_item_type_obj, 'transitions') and work_item_type_obj.transitions:
                transitions = [
                    {
                        "to": getattr(transition, 'to', None),
                        "actions": getattr(transition, 'actions', [])
                    }
                    for transition in work_item_type_obj.transitions
                    if hasattr(transition, 'from') and getattr(transition, 'from', None) == from_state
                ]
            else:
                # Fallback: return all available states as potential transitions
                if hasattr(work_item_type_obj, 'states') and work_item_type_obj.states:
                    transitions = [
                        {
                            "to": state.name,
                            "actions": []
                        }
                        for state in work_item_type_obj.states
                        if state.name != from_state
                    ]
            
            return transitions
        except Exception as e:
            # Fallback: return empty transitions with error info
            return {"error": str(e), "transitions": []}
  • Input schema definition for the get_work_item_transitions tool, specifying required parameters: project, work_item_type, from_state.
    types.Tool(
        name="get_work_item_transitions",
        description="Get valid state transitions for a work item type from a specific state to ensure proper workflow.",
        inputSchema={
            "type": "object",
            "properties": {
                "project": {
                    "type": "string", 
                    "description": "The name or ID of the project."
                },
                "work_item_type": {
                    "type": "string", 
                    "description": "The work item type (e.g., 'Bug', 'User Story', 'Task')."
                },
                "from_state": {
                    "type": "string", 
                    "description": "The current state to get valid transitions from."
                },
            },
            "required": ["project", "work_item_type", "from_state"],
            "additionalProperties": False
        }
    ),
  • Registration and dispatch logic in the MCP server's _execute_tool method, which calls the client handler with unpacked arguments.
    elif name == "get_work_item_transitions":
        return self.client.get_work_item_transitions(**arguments)

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