Skip to main content
Glama

get_flows

Retrieve and filter workflow flows from Prefect by name, tags, or creation date to manage automation processes.

Instructions

Get a list of flows with optional filtering.

Args: limit: Maximum number of flows to return offset: Number of flows to skip flow_name: Filter flows by name tags: Filter flows by tags created_after: ISO formatted datetime string for filtering flows created after this time created_before: ISO formatted datetime string for filtering flows created before this time

Returns: A list of flows with their details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
created_afterNo
created_beforeNo
flow_nameNo
limitNo
offsetNo
tagsNo

Implementation Reference

  • The handler function for the 'get_flows' MCP tool. It queries Prefect flows using the client with optional filters and returns results with UI links.
    @mcp.tool
    async def get_flows(
        limit: Optional[int] = None,
        offset: Optional[int] = None,
        flow_name: Optional[str] = None,
        tags: Optional[List[str]] = None,
        created_after: Optional[str] = None,
        created_before: Optional[str] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Get a list of flows with optional filtering.
        
        Args:
            limit: Maximum number of flows to return
            offset: Number of flows to skip
            flow_name: Filter flows by name
            tags: Filter flows by tags
            created_after: ISO formatted datetime string for filtering flows created after this time
            created_before: ISO formatted datetime string for filtering flows created before this time
            
        Returns:
            A list of flows with their details
        """
        try:
            async with get_client() as client:
                # Build flow filter
                flow_filter = None
                if any([flow_name, tags, created_after, created_before]):
                    from prefect.client.schemas.filters import FlowFilter
                    
                    filter_dict = {}
                    if flow_name:
                        filter_dict["name"] = {"like_": f"%{flow_name}%"}
                    if tags:
                        filter_dict["tags"] = {"all_": tags}
                    
                    # Handle date filters
                    if created_after or created_before:
                        created_filters = {}
                        if created_after:
                            created_filters["ge_"] = created_after
                        if created_before:
                            created_filters["le_"] = created_before
                        filter_dict["created"] = created_filters
                    
                    flow_filter = FlowFilter(**filter_dict)
                
                # Query using proper filter object
                flows = await client.read_flows(
                    flow_filter=flow_filter,
                    limit=limit,
                    offset=offset,
                )
                
                # Handle empty results
                if not flows:
                    return [types.TextContent(type="text", text=str({"flows": []}))]
                
                # Add UI links to each flow
                flows_with_links = []
                for flow in flows:
                    flow_dict = flow.model_dump()
                    flow_dict["ui_url"] = get_flow_url(str(flow.id))
                    flows_with_links.append(flow_dict)
                    
                flows_result = {"flows": flows_with_links}
                
                return [types.TextContent(type="text", text=str(flows_result))]        
        except Exception as e:
            error_message = f"Error fetching flows: {str(e)}"
            return [types.TextContent(type="text", text=error_message)]
  • The import statement in main.py that loads the flow module, thereby registering the @mcp.tool decorated get_flows function.
    # Import modules to register their decorated tools
    if APIType.FLOW.value in apis:
        info("Loading Flow API...")
        from . import flow
  • Helper function used within get_flows to generate UI URLs for flows.
    def get_flow_url(flow_id: str) -> str:
        """Generate a UI URL for a flow."""
        base_url = PREFECT_API_URL.replace("/api", "")
        return f"{base_url}/flows/{flow_id}"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the tool returns 'a list of flows with their details,' it doesn't specify important behavioral traits like whether this is a read-only operation, potential rate limits, authentication requirements, pagination behavior (beyond limit/offset), or what happens when no filters are applied. For a list operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by organized parameter documentation. It's appropriately sized for a tool with 6 parameters. The only improvement would be front-loading more critical information about when to use this tool versus siblings, but the current structure is efficient with zero wasted sentences.

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

Completeness3/5

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

Given the complexity (6 parameters, no annotations, no output schema), the description is partially complete. It thoroughly documents parameters but lacks behavioral context and usage guidance relative to siblings. The description doesn't explain what 'flows' represent in this context or what details are returned. For a list operation in a rich ecosystem, it should provide more context about the resource being retrieved and how it differs from similar tools.

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 description provides detailed parameter documentation in the Args section, explaining the purpose of all 6 parameters (limit, offset, flow_name, tags, created_after, created_before). Since schema description coverage is 0%, this documentation compensates fully by adding meaning beyond the bare schema. The only minor gap is that it doesn't specify format details for 'tags' (e.g., exact tag structure) or datetime formats beyond 'ISO formatted'.

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: 'Get a list of flows with optional filtering.' This specifies the verb ('Get') and resource ('flows'), making it immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'get_flow' (singular) or 'get_flow_runs', which might retrieve different types of flow-related data.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools like 'get_flow', 'get_flow_runs', and 'get_flow_runs_by_flow', there's no indication of which tool to choose for different scenarios (e.g., retrieving metadata vs. execution data). The description only mentions optional filtering but doesn't help the agent navigate the tool ecosystem.

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/allen-munsch/mcp-prefect'

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