Skip to main content
Glama
JLKmach

ServiceNow MCP Server

by JLKmach

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
NameRequiredDescriptionDefault
workflow_idYesWorkflow ID or sys_id
include_versionsNoInclude 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")
  • 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
    ),

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/JLKmach/servicenow-mcp'

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