Skip to main content
Glama
devrev

DevRev MCP Server

Official
by devrev

valid_stage_transition

Use this tool to retrieve valid stage transitions for a work item or part in DevRev. Ensure stage updates comply with valid transitions by checking before applying changes.

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
idYesThe DevRev ID of the work item (issue, ticket) or part (enhancement)
typeYes

Implementation Reference

  • Registers the "valid_stage_transition" tool, including its name, description, and input schema (type and id required).
    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"] } ),
  • Handler for valid_stage_transition: Fetches the current item (work or part), retrieves its schema to get stage_diagram_id, fetches the stage diagram, and returns valid 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" ), ]

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