list_chatflows
Retrieve a filtered list of available chatflows from the Flowise API, honoring configured whitelist or blacklist settings, and return results as a JSON-encoded string.
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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_flowise/server_fastmcp.py:39-66 (handler)The handler function for the 'list_chatflows' tool, decorated with @mcp.tool() for registration. It fetches chatflows, applies whitelist and blacklist filters from environment variables, and returns a JSON 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)
- mcp_flowise/utils.py:229-262 (helper)Supporting utility function that fetches the list of chatflows from the Flowise API, simplifies the response to id and name, applies filtering through filter_chatflows, and handles errors by returning an empty list.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 []