get_deployment_by_name
Retrieve a specific deployment by its name to inspect or manage workflow automation configurations in Prefect.
Instructions
Get a deployment by its name.
Args:
name: Name of the deployment to retrieve, in format "flow_name/deployment_name".
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- prefect_mcp_server_pkg/server.py:264-296 (handler)Handler function for the 'get_deployment_by_name' tool. It retrieves a Prefect deployment by its name in 'flow_name/deployment_name' format using the Prefect client and DeploymentFilter. Returns the deployment details or an error.@mcp.tool() async def get_deployment_by_name(ctx: Context, name: str) -> Dict[str, Any]: """Get a deployment by its name. Args: name: Name of the deployment to retrieve, in format "flow_name/deployment_name". """ if not name: return {"error": "Missing required argument: name"} if "/" not in name: return {"error": "Name should be in format 'flow_name/deployment_name'"} async with get_client() as client: try: flow_name, deployment_name = name.split("/", 1) # Use filters to find deployment by name deployment_filter = DeploymentFilter( name={"equals": deployment_name}, flow_name={"equals": flow_name} ) deployments = await client.read_deployments( deployment_filter=deployment_filter ) if not deployments: return {"error": f"No deployment found with name: {name}"} # Return the first matching deployment return {"deployment": deployments[0].model_dump()} except Exception as e: return {"error": f"Failed to get deployment: {str(e)}"}