create_flow_run_from_deployment
Execute a Prefect workflow by triggering a flow run from an existing deployment, with optional parameters, tags, and idempotency controls.
Instructions
Create a flow run from a deployment.
Args: deployment_id: The deployment UUID parameters: Optional parameters to pass to the flow run name: Optional name for the flow run tags: Optional tags for the flow run idempotency_key: Optional idempotency key
Returns: Details of the created flow run
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deployment_id | Yes | ||
| idempotency_key | No | ||
| name | No | ||
| parameters | No | ||
| tags | No |
Implementation Reference
- src/mcp_prefect/deployment.py:115-152 (handler)The handler function for the 'create_flow_run_from_deployment' tool, decorated with @mcp.tool for registration. It uses the Prefect client to create a flow run from the specified deployment, adds a UI URL, and returns the flow run details as text content.@mcp.tool async def create_flow_run_from_deployment( deployment_id: str, parameters: Optional[Dict[str, Any]] = None, name: Optional[str] = None, tags: Optional[List[str]] = None, idempotency_key: Optional[str] = None, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: """ Create a flow run from a deployment. Args: deployment_id: The deployment UUID parameters: Optional parameters to pass to the flow run name: Optional name for the flow run tags: Optional tags for the flow run idempotency_key: Optional idempotency key Returns: Details of the created flow run """ async with get_client() as client: parameters = parameters or {} flow_run = await client.create_flow_run_from_deployment( deployment_id=UUID(deployment_id), parameters=parameters, name=name, tags=tags, idempotency_key=idempotency_key, ) # Add URL flow_run_dict = flow_run.model_dump() flow_run_dict["ui_url"] = PREFECT_API_URL.replace("/api", "") + f"/flow-runs/{flow_run.id}" return [types.TextContent(type="text", text=str(flow_run_dict))]
- src/mcp_prefect/deployment.py:115-115 (registration)The @mcp.tool decorator registers the create_flow_run_from_deployment function as an MCP tool.@mcp.tool