Skip to main content
Glama
devrev

DevRev MCP Server

Official
by devrev

valid_stage_transition

Check valid stage transitions for work items before updating to ensure proper workflow progression in DevRev.

Instructions

gets a list of valid stage transition for a given work item (issue, ticket) or part (enhancement). Use this before updating stage of the work item or part to ensure the transition is valid.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYes
idYesThe DevRev ID of the work item (issue, ticket) or part (enhancement)

Implementation Reference

  • Handler function for the 'valid_stage_transition' tool. Fetches the current stage of the given work item or part, retrieves the relevant schema and stage diagram, and returns the valid stage transitions from the current stage.
    elif name == "valid_stage_transition":
        if not arguments:
            raise ValueError("Missing arguments")
    
        payload = {}
    
        id = arguments.get("id")
        if not id:
            raise ValueError("Missing id parameter")
        payload["id"] = id
    
        type = arguments.get("type")
        if not type:
            raise ValueError("Missing type parameter")
        payload["type"] = type
    
        current_stage_id = None
        leaf_type = None
        subtype = None
    
        if(type == "issue" or type == "ticket"):
            response = make_devrev_request(
                "works.get",
                {
                    "id": id
                }
            )
    
            if response.status_code != 200:
                error_text = response.text
                return [
                    types.TextContent(
                        type="text",
                        text=f"Get work item failed with status {response.status_code}: {error_text}"
                    )
                ]
            
            current_stage_id = response.json().get("work", {}).get("stage", {}).get("stage", {}).get("id", {})
            leaf_type = response.json().get("work", {}).get("type", {})
            subtype = response.json().get("work", {}).get("subtype", {})
    
        elif(type == "enhancement"):
            response = make_devrev_request(
                "parts.get",
                {
                    "id": id
                }
            )
    
            if response.status_code != 200:
                error_text = response.text
                return [
                    types.TextContent(
                        type="text",
                        text=f"Get part failed with status {response.status_code}: {error_text}"
                    )
                ]
    
            current_stage_id = response.json().get("part", {}).get("stage_v2", {}).get("stage", {}).get("id", {})
            leaf_type = response.json().get("part", {}).get("type", {})
            subtype = response.json().get("part", {}).get("subtype", {})
        else:
            raise ValueError("Invalid type parameter")
        
        if(current_stage_id == {} or leaf_type == {}):
            raise ValueError("Could not get current stage or leaf type")
        
        schema_payload = {}
        if(leaf_type != {}):
            schema_payload["leaf_type"] = leaf_type
        if(subtype != {}):
            schema_payload["custom_schema_spec"] = {"subtype": subtype}
        
        schema_response = make_devrev_request(
            "schemas.aggregated.get",
            schema_payload
        )
    
        if schema_response.status_code != 200:
            error_text = schema_response.text
            return [
                types.TextContent(
                    type="text",
                    text=f"Get schema failed with status {schema_response.status_code}: {error_text}"
                )
            ]
        
        stage_diagram_id = schema_response.json().get("schema", {}).get("stage_diagram_id", {}).get("id", {})
        if stage_diagram_id == None:
            raise ValueError("Could not get stage diagram id")
        
        stage_transitions_response = make_devrev_request(
            "stage-diagrams.get",
            {"id": stage_diagram_id}
        )
    
        if stage_transitions_response.status_code != 200:
            error_text = stage_transitions_response.text
            return [
                types.TextContent(
                    type="text",
                    text=f"Get stage diagram for Get stage transitions failed with status {stage_transitions_response.status_code}: {error_text}"
                )
            ]
    
        stages = stage_transitions_response.json().get("stage_diagram", {}).get("stages", [])
        for stage in stages:
            if stage.get("stage", {}).get("id") == current_stage_id:
                transitions = stage.get("transitions", [])
                return [
                    types.TextContent(
                        type="text",
                        text=f"Valid Transitions for '{id}' from current stage:\n{transitions}"
                    )
                ]
    
        return [
            types.TextContent(
                type="text",
                text=f"No valid transitions found for '{id}' from current stage"
            ),
        ]
  • Registration of the 'valid_stage_transition' tool in the list_tools handler, including its name, description, and input schema.
    types.Tool(
        name="valid_stage_transition",
        description="gets a list of valid stage transition for a given work item (issue, ticket) or part (enhancement). Use this before updating stage of the work item or part to ensure the transition is valid.",
        inputSchema={
            "type": "object",
            "properties": {
                "type": {"type": "string", "enum": ["issue", "ticket", "enhancement"]},
                "id": {"type": "string", "description": "The DevRev ID of the work item (issue, ticket) or part (enhancement)"},
            },
            "required": ["type", "id"]
        }
    ),
  • Input schema definition for the 'valid_stage_transition' tool, specifying required parameters: type (issue, ticket, enhancement) and id.
    inputSchema={
        "type": "object",
        "properties": {
            "type": {"type": "string", "enum": ["issue", "ticket", "enhancement"]},
            "id": {"type": "string", "description": "The DevRev ID of the work item (issue, ticket) or part (enhancement)"},
        },
        "required": ["type", "id"]
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves a list for validation purposes, which implies a read-only, non-destructive operation, but doesn't cover aspects like authentication needs, rate limits, error handling, or the format of the returned list. For a tool with no annotations, this leaves significant gaps in behavioral understanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence and adds usage guidance in the second. Both sentences earn their place by providing essential information without redundancy or fluff, making it efficiently structured and appropriately sized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 required parameters, no output schema, no annotations), the description covers the basic purpose and usage context adequately. However, it lacks details on behavioral traits (e.g., response format, errors) and doesn't fully address parameter semantics, leaving room for improvement in completeness for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 50% (only the 'id' parameter has a description). The description adds some value by clarifying that 'type' refers to 'work item (issue, ticket) or part (enhancement)' and 'id' is 'The DevRev ID', but it doesn't fully compensate for the lack of schema details on 'type' or explain parameter interactions. With 2 parameters and partial coverage, the baseline is met but not exceeded.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'gets a list of valid stage transition for a given work item (issue, ticket) or part (enhancement).' It specifies the verb ('gets'), resource ('valid stage transition'), and target objects, though it doesn't explicitly differentiate from siblings like 'update_work' or 'update_part' beyond the 'before updating' hint.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: 'Use this before updating stage of the work item or part to ensure the transition is valid.' It implies an alternative (directly updating without checking) but doesn't explicitly name sibling tools like 'update_work' or 'update_part' as alternatives, nor does it specify exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/devrev/mcp-server'

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