Skip to main content
Glama
jupiterbak

AYX-MCP-Wrapper

by jupiterbak

get_workflow_tool_list

Retrieve all tools used in an Alteryx workflow by providing the workflow ID. This helps users analyze and manage workflow components.

Instructions

Get the list of tools in a workflow by the workflow ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workflow_idYes

Implementation Reference

  • The core handler function in the Tools class that implements the logic for get_workflow_tool_list. It retrieves the workflow, downloads and unzips it, parses the XML, extracts tool nodes, cleans properties, and returns a pretty-formatted dictionary of tools.
    def get_workflow_tool_list(self, workflow_id: str):
        """Get the list of the workflow tools and the tool properties by the workflow ID"""
        try:
            api_response = self.workflows_api.workflows_get_workflow(workflow_id)
            if api_response is None:
                return "Error: Workflow not found"
            
            # Download the workflow file
            api_response = self.workflows_api.workflows_download_workflow(workflow_id)
            if api_response is None:
                return "Error: Failed to download workflow"
                
            temp_directory = self.configuration.temp_directory
            # normalize the temp directory
            temp_directory = os.path.normpath(temp_directory)
            if not os.path.exists(temp_directory):
                os.makedirs(temp_directory)
            
            with open(
                f"{temp_directory}/{workflow_id}.yxzp",
                "wb" if not os.path.exists(f"{temp_directory}/{workflow_id}.yxzp") else "wb+",
            ) as f:
                f.write(api_response)
    
            new_directory = f"{temp_directory}/{workflow_id}"
            if os.path.exists(new_directory):
                shutil.rmtree(new_directory)
            os.makedirs(new_directory)
            
            with zipfile.ZipFile(f"{temp_directory}/{workflow_id}.yxzp", "r") as zip_ref:
                zip_ref.extractall(new_directory)
            
            yxmd_files = [file for file in os.listdir(new_directory) if file.endswith(".yxmd") or file.endswith(".yxwz")]
            if len(yxmd_files) == 0:
                return "Error: Workflow XML file not found after unzipping"
            
            yxmd_file = yxmd_files[0]
    
            # Read as binary first, then decode as UTF-8
            with open(f"{new_directory}/{yxmd_file}", "rb") as f:
                binary_content = f.read()
                try:
                    # Try to decode as UTF-8
                    xml_content = binary_content.decode('utf-8')
                except UnicodeDecodeError:
                    # If UTF-8 fails, return the binary content as a string representation
                    xml_content = binary_content
    
            # Parse the XML content using xmltodict
            xml_dict = xmltodict.parse(xml_content)
    
            # extract the tools list
            tools_list = xml_dict['AlteryxDocument']['Nodes']['Node']
            # if tools_list is a list, then we need to iterate through it
            tools_dict = {}
            if isinstance(tools_list, list):
                for tool in tools_list:
                    tool_id = tool['@ToolID']
                    tool_type = tool['GuiSettings']['@Plugin']
                    tool_dict = tool['Properties']['Configuration']
                    # Add the tool type to the tool dictionary
                    tool_dict['ToolType'] = tool_type
    
                    # Remove all properties BG_Image, Font, TextColor, FillColor, Justification, TextSize
                    tool_dict.pop('BG_Image', None)
                    tool_dict.pop('Font', None)
                    tool_dict.pop('TextColor', None)
                    tool_dict.pop('FillColor', None)
                    tool_dict.pop('Justification', None)
                    tool_dict.pop('TextSize', None)
    
                    # Remove the data encoded in the tool
                    tool_dict.pop('Data', None)
    
                    tools_dict[tool_id] = tool_dict
            else:
                tool_id = tools_list['@ToolID']
                tool_type = tools_list['GuiSettings']['@Plugin']
                tool_dict = tools_list['Properties']['Configuration']
                # Add the tool type to the tool dictionary
                tool_dict['ToolType'] = tool_type
    
                # Remove all properties BG_Image, Font, TextColor, FillColor, Justification, TextSize
                tool_dict.pop('BG_Image', None)
                tool_dict.pop('Font', None)
                tool_dict.pop('TextColor', None)
                tool_dict.pop('FillColor', None)
                tool_dict.pop('Justification', None)
                tool_dict.pop('TextSize', None)
    
                # Remove the data encoded in the tool
                tool_dict.pop('Data', None)
    
                # Add the tool dictionary to the tools dictionary
                tools_dict[tool_id] = tool_dict
            return pprint.pformat(tools_dict)
                    
        except Exception as e:
            return f"Error: {str(e)}"
  • The MCP tool registration in register_tools method using @self.app.tool() decorator, which defines the tool schema implicitly from the function signature and delegates execution to the Tools instance.
    @self.app.tool()
    def get_workflow_tool_list(workflow_id: str):
        """Get the list of tools in a workflow by the workflow ID"""
        return self.tools.get_workflow_tool_list(workflow_id)

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/jupiterbak/AYX-MCP-Wrapper'

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