Skip to main content
Glama

list_chatflows

Retrieve all available chatflows from Flowise API with optional filtering, returning a JSON list for integration and execution.

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 and registration for the 'list_chatflows' tool using FastMCP's @mcp.tool() decorator. It fetches chatflows, applies custom whitelist/blacklist filtering, and returns a JSON string of available chatflows.
    @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)
  • Core helper function called by the list_chatflows handler to retrieve and filter chatflows from the Flowise API.
    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 []
  • Supporting filter function used by fetch_chatflows to apply whitelist and blacklist rules based on environment variables.
    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 of behavioral disclosure. It effectively describes key behavioral traits: it's a read operation (implied by 'List'), respects configuration-based filtering, and returns JSON-encoded data. However, it doesn't mention potential rate limits, authentication needs, or error handling, leaving some gaps in behavioral context.

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 with zero waste. The first sentence states the purpose, the second explains configuration behavior, and the third specifies the return format. Every sentence earns its place and information is appropriately front-loaded.

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 provides good contextual completeness. It covers purpose, behavioral constraints (filtering), and return format. However, without annotations or output schema, it could benefit from more detail about the structure of returned JSON or error conditions for a fully complete picture.

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 input schema has 0 parameters with 100% coverage, so the description doesn't need to compensate for parameter documentation. The description appropriately focuses on behavioral aspects rather than parameter semantics, which is correct for a parameterless tool. It adds value by explaining the filtering behavior beyond what the empty schema provides.

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.' This specifies the verb ('List') and resource ('chatflows'), though it doesn't explicitly differentiate from its sibling tool 'create_prediction' beyond the obvious action difference. The purpose is clear 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 by mentioning whitelisting/blacklisting configuration, but it doesn't provide explicit guidance on when to use this tool versus alternatives. There's no mention of when not to use it or direct comparison to 'create_prediction', leaving usage context somewhat implied rather than clearly articulated.

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

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