get_workflow_details
Retrieve comprehensive details about a specific ServiceNow workflow, including its configuration and optional version history, to analyze and manage automation processes.
Instructions
Get detailed information about a specific workflow
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workflow_id | Yes | Workflow ID or sys_id | |
| include_versions | No | Include workflow versions |
Implementation Reference
- The handler function that executes the get_workflow_details tool logic, making an API call to retrieve workflow details from ServiceNow.def get_workflow_details( auth_manager: AuthManager, server_config: ServerConfig, params: Dict[str, Any], ) -> Dict[str, Any]: """ Get detailed information about a specific workflow. Args: auth_manager: Authentication manager server_config: Server configuration params: Parameters for getting workflow details Returns: Dictionary containing the workflow details """ params = _unwrap_params(params, GetWorkflowDetailsParams) # Get the correct auth_manager and server_config try: auth_manager, server_config = _get_auth_and_config(auth_manager, server_config) except ValueError as e: logger.error(f"Error getting auth and config: {e}") return {"error": str(e)} workflow_id = params.get("workflow_id") if not workflow_id: return {"error": "Workflow ID is required"} # Make the API request try: headers = auth_manager.get_headers() url = f"{server_config.instance_url}/api/now/table/wf_workflow/{workflow_id}" response = requests.get(url, headers=headers) response.raise_for_status() result = response.json() return { "workflow": result.get("result", {}), } except requests.RequestException as e: logger.error(f"Error getting workflow details: {e}") return {"error": str(e)} except Exception as e: logger.error(f"Unexpected error getting workflow details: {e}") return {"error": str(e)}
- Pydantic model defining the input schema for the get_workflow_details tool, including required workflow_id and optional include_versions.class GetWorkflowDetailsParams(BaseModel): """Parameters for getting workflow details.""" workflow_id: str = Field(..., description="Workflow ID or sys_id") include_versions: Optional[bool] = Field(False, description="Include workflow versions")
- src/servicenow_mcp/utils/tool_utils.py:543-549 (registration)Registers the 'get_workflow_details' tool in the MCP server's tool_definitions dictionary, linking the handler function, input schema, description, and output serialization method."get_workflow_details": ( get_workflow_details_tool, GetWorkflowDetailsParams, str, # Expects JSON string "Get detailed information about a specific workflow", "json", # Tool returns list/dict ),