get_flow_by_name
Retrieve a specific workflow by its name from the Prefect MCP Server, enabling efficient management and execution of automated tasks through the Model Context Protocol.
Instructions
Get a flow by its name.
Args:
name: Name of the flow to retrieve.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- prefect_mcp_server_pkg/server.py:74-97 (handler)The handler function for the 'get_flow_by_name' tool. It retrieves a Prefect flow by name using the Prefect client, filters flows matching the name, returns the first one or an error. Registered with the @mcp.tool() decorator.@mcp.tool() async def get_flow_by_name(ctx: Context, name: str) -> Dict[str, Any]: """Get a flow by its name. Args: name: Name of the flow to retrieve. """ if not name: return {"error": "Missing required argument: name"} async with get_client() as client: try: # Use correct flow_filter parameter flow_filter = FlowFilter(name=FlowFilterName(any_=[name])) flows = await client.read_flows(flow_filter=flow_filter) if not flows: return {"error": f"No flow found with name: {name}"} # Return the first matching flow return {"flow": flows[0].model_dump()} except Exception as e: return {"error": f"Failed to get flow: {str(e)}"}