list_deployments
Retrieve a list of deployments from the Prefect API, allowing filtering by flow ID and pagination with limit and offset parameters for efficient results management.
Instructions
Get a list of deployments from the Prefect API.
Args:
limit: Maximum number of deployments to return (default 20).
offset: Number of deployments to skip (default 0).
flow_id: Optional ID of the flow to filter deployments by.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flow_id | No | ||
| limit | No | ||
| offset | No |
Implementation Reference
- prefect_mcp_server_pkg/server.py:298-322 (handler)The main handler function for the 'list_deployments' tool. It fetches deployments from the Prefect API using the client, applies an optional flow_id filter via DeploymentFilter, paginates with limit/offset, and returns the list of deployments (model_dump) along with the count.@mcp.tool() async def list_deployments( ctx: Context, limit: int = 20, offset: int = 0, flow_id: Optional[str] = None ) -> Dict[str, Any]: """Get a list of deployments from the Prefect API. Args: limit: Maximum number of deployments to return (default 20). offset: Number of deployments to skip (default 0). flow_id: Optional ID of the flow to filter deployments by. """ filter_dict = {} if flow_id: filter_dict["flow_id"] = {"equals": flow_id} async with get_client() as client: deployment_filter = DeploymentFilter(**filter_dict) if filter_dict else None deployments = await client.read_deployments( deployment_filter=deployment_filter, limit=limit, offset=offset ) return { "deployments": [depl.model_dump() for depl in deployments], "count": len(deployments), }
- prefect_mcp_server_pkg/server.py:298-298 (registration)Registers the list_deployments function as an MCP tool using the @mcp.tool() decorator.@mcp.tool()