get_deployment_by_name
Retrieve a specific deployment by its name using the Model Context Protocol, enabling precise access to workflow configurations in the Prefect MCP Server for targeted automation tasks.
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, decorated with @mcp.tool() for registration. Retrieves a Prefect deployment by parsing the name as 'flow_name/deployment_name', filters deployments using DeploymentFilter, and returns the first matching deployment 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)}"}