Skip to main content
Glama
andydukes
by andydukes

list_chatflows

Retrieve all available chatflows from the Flowise API with optional filtering based on configured whitelist or blacklist settings.

Instructions

List all available chatflows from the Flowise API.

This function respects optional whitelisting or blacklisting if configured
via FLOWISE_CHATFLOW_WHITELIST or FLOWISE_CHATFLOW_BLACKLIST.

Returns:
    str: A JSON-encoded string of filtered chatflows.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler for the 'list_chatflows' MCP tool. Decorated with @mcp.tool() for registration. Fetches chatflows using the helper fetch_chatflows(), applies additional whitelist and blacklist filtering based on FLOWISE_CHATFLOW_* environment variables, and returns a JSON-encoded string of the filtered list.
    @mcp.tool()
    def list_chatflows() -> str:
        """
        List all available chatflows from the Flowise API.
    
        This function respects optional whitelisting or blacklisting if configured
        via FLOWISE_CHATFLOW_WHITELIST or FLOWISE_CHATFLOW_BLACKLIST.
    
        Returns:
            str: A JSON-encoded string of filtered chatflows.
        """
        logger.debug("Handling list_chatflows tool.")
        chatflows = fetch_chatflows()
    
        # Apply whitelisting
        if FLOWISE_CHATFLOW_WHITELIST:
            whitelist = set(FLOWISE_CHATFLOW_WHITELIST.split(","))
            chatflows = [cf for cf in chatflows if cf["id"] in whitelist]
            logger.debug(f"Applied whitelist filter: {whitelist}")
    
        # Apply blacklisting
        if FLOWISE_CHATFLOW_BLACKLIST:
            blacklist = set(FLOWISE_CHATFLOW_BLACKLIST.split(","))
            chatflows = [cf for cf in chatflows if cf["id"] not in blacklist]
            logger.debug(f"Applied blacklist filter: {blacklist}")
    
        logger.debug(f"Filtered chatflows: {chatflows}")
        return json.dumps(chatflows)
  • Supporting helper function used by the list_chatflows handler to fetch chatflows from the Flowise API (/api/v1/chatflows), simplify to id/name, apply filter_chatflows() based on FLOWISE_WHITELIST_* / BLACKLIST_* env vars, and return the filtered list or empty on error.
    def fetch_chatflows() -> list[dict]:
        """
        Fetch a list of all chatflows from the Flowise API.
    
        Returns:
            list of dict: Each dict contains the 'id' and 'name' of a chatflow.
                          Returns an empty list if there's an error.
        """
        logger = logging.getLogger(__name__)
    
        # Construct the Flowise API URL for fetching chatflows
        url = f"{FLOWISE_API_ENDPOINT.rstrip('/')}/api/v1/chatflows"
        headers = {}
        if FLOWISE_API_KEY:
            headers["Authorization"] = f"Bearer {FLOWISE_API_KEY}"
    
        logger.debug(f"Fetching chatflows from {url}")
    
        try:
            # Send GET request to the Flowise API
            response = requests.get(url, headers=headers, timeout=30)
            response.raise_for_status()
    
            # Parse and simplify the response data
            chatflows_data = response.json()
            simplified_chatflows = [{"id": cf["id"], "name": cf["name"]} for cf in chatflows_data]
    
            logger.debug(f"Fetched chatflows: {simplified_chatflows}")
            return filter_chatflows(simplified_chatflows)
        #except requests.exceptions.RequestException as e:
        except Exception as e:
            # Log and return an empty list on error
            logger.error(f"Error fetching chatflows: {e}")
            return []
  • Additional helper function filter_chatflows() invoked by fetch_chatflows(). Filters the chatflow list using environment variables like FLOWISE_WHITELIST_ID, FLOWISE_BLACKLIST_ID, *_NAME_REGEX. Whitelist has precedence; supports ID matching and name regex.
    def filter_chatflows(chatflows: list[dict]) -> list[dict]:
        """
        Filters chatflows based on whitelist and blacklist criteria.
        Whitelist takes precedence over blacklist.
    
        Args:
            chatflows (list[dict]): A list of chatflow dictionaries.
    
        Returns:
            list[dict]: Filtered list of chatflows.
        """
        logger = logging.getLogger(__name__)
    
        # Dynamically fetch filtering criteria
        whitelist_ids = set(filter(bool, os.getenv("FLOWISE_WHITELIST_ID", "").split(",")))
        blacklist_ids = set(filter(bool, os.getenv("FLOWISE_BLACKLIST_ID", "").split(",")))
        whitelist_name_regex = os.getenv("FLOWISE_WHITELIST_NAME_REGEX", "")
        blacklist_name_regex = os.getenv("FLOWISE_BLACKLIST_NAME_REGEX", "")
    
        filtered_chatflows = []
    
        for chatflow in chatflows:
            chatflow_id = chatflow.get("id", "")
            chatflow_name = chatflow.get("name", "")
    
            # Flags to determine inclusion
            is_whitelisted = False
    
            # Check Whitelist
            if whitelist_ids or whitelist_name_regex:
                if whitelist_ids and chatflow_id in whitelist_ids:
                    is_whitelisted = True
                if whitelist_name_regex and re.search(whitelist_name_regex, chatflow_name):
                    is_whitelisted = True
    
                if is_whitelisted:
                    # If whitelisted, include regardless of blacklist
                    logger.debug("Including whitelisted chatflow '%s' (ID: '%s').", chatflow_name, chatflow_id)
                    filtered_chatflows.append(chatflow)
                    continue  # Skip blacklist checks
                else:
                    # If not whitelisted, exclude regardless of blacklist
                    logger.debug("Excluding non-whitelisted chatflow '%s' (ID: '%s').", chatflow_name, chatflow_id)
                    continue
            else:
                # If no whitelist, apply blacklist directly
                if blacklist_ids and chatflow_id in blacklist_ids:
                    logger.debug("Skipping chatflow '%s' (ID: '%s') - In blacklist.", chatflow_name, chatflow_id)
                    continue  # Exclude blacklisted by ID
                if blacklist_name_regex and re.search(blacklist_name_regex, chatflow_name):
                    logger.debug("Skipping chatflow '%s' (ID: '%s') - Name matches blacklist regex.", chatflow_name, chatflow_id)
                    continue  # Exclude blacklisted by name
    
                # Include the chatflow if it passes all filters
                logger.debug("Including chatflow '%s' (ID: '%s').", chatflow_name, chatflow_id)
                filtered_chatflows.append(chatflow)
    
        logger.debug("Filtered chatflows: %d out of %d", len(filtered_chatflows), len(chatflows))
        return filtered_chatflows
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses important behavioral traits: it respects optional whitelisting/blacklisting configuration via environment variables, and specifies the return format ('JSON-encoded string of filtered chatflows'). This adds valuable context beyond basic functionality, though it doesn't cover aspects like error handling or performance characteristics.

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 perfectly concise and well-structured: three sentences that each earn their place. The first states the core purpose, the second adds important configuration context, and the third specifies the return format. No wasted words, front-loaded with essential information.

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

Completeness4/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is quite complete. It covers what the tool does, important configuration behavior, and the return format. For a list operation with no parameters, this provides sufficient context, though it could potentially mention pagination or ordering if relevant.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage. The description doesn't need to compensate for any parameter gaps. It appropriately focuses on behavioral aspects rather than parameter documentation. The baseline for 0 parameters is 4, and the description meets this standard.

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: 'List all available chatflows from the Flowise API.' It specifies the verb ('List') and resource ('chatflows'), but doesn't explicitly differentiate from its sibling 'create_prediction' beyond the obvious list vs. create distinction. The description is specific but lacks explicit sibling comparison.

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

Usage Guidelines3/5

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

The description implies usage context through the mention of whitelisting/blacklisting configuration, suggesting this tool is for retrieving chatflows with optional filtering. However, it doesn't provide explicit guidance on when to use this tool versus alternatives or any prerequisites. The usage is implied rather than explicitly stated.

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/andydukes/mcp-flowise'

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