# Prefect MCP

> Prefect provides your AI agent deep visibility into complex data pipelines and cloud infrastructure. Audit Python workflows, debug failed runs using full tracebacks, and map out secure connections to AWS or GCP—all without leaving your chat window.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** data-orchestration, workflow-automation, pipeline-monitoring, python-automation, etl-management, task-scheduling

## Description

This MCP gives any AI client direct access to the guts of your Prefect Cloud environment. Your agent can now parse complex data pipelines, telling you exactly why a workflow crashed or where an ETL flow stalled. You don't have to jump between dashboards and log files anymore; instead, ask your AI client to check the status of your entire operation.

When things go wrong, it pulls absolute tracing details from a failed run so you can read the exact Python traceback. You can also get a complete picture of which secure infrastructure blocks, like AWS or GCP credentials, are actually connecting your Prefect environments. It even lists all automations that trigger flows based on webhooks. Because Vinkius hosts this MCP in their catalog, you connect once from Claude, Cursor, or any compatible client and gain instant access to full pipeline oversight. This lets data teams stop guessing about failure points and start fixing them immediately.

## Tools

### list_flows
Retrieves a list of all Python workflows registered within your Prefect Cloud account.

### list_deployments
Lists active deployments, showing scheduled or triggered physical instances of your workflows.

### list_flow_runs
Shows a list of recent flow runs, including status (failed, running, etc.) and execution limits.

### get_flow_run
Pulls all contextual metadata for one specific run, allowing you to read the full Python traceback.

### list_work_pools
Lists physical work pools that act as destinations for dynamically running flows.

### list_blocks
Retrieves all secure infrastructure blocks, defining secrets or cloud credentials (AWS, GCP).

### list_automations
Lists all Cloud Automations that use webhooks to trigger flows based on external events.

## Prompt Examples

**Prompt:** 
```
Did the 'DB Sync Hourly' flow experience any failed runs today? Provide the traceback.
```

**Response:** 
```
Accessing `list_flow_runs`, I see a FAILED state roughly 2 hours ago. Pulling metadata via `get_flow_run` under ID `f391...`, the worker returned `psycopg2.OperationalError: server closed the connection unexpectedly`. Looks like a database timeout.
```

**Prompt:** 
```
Show me what infrastructure is tied to our 'Production Data Warehouse' deployment.
```

**Response:** 
```
Looking at `list_deployments` and `list_work_pools`, the 'Production Data Warehouse' deployment routes exclusively to the Work Pool named `eks-primary-cluster`. This compute layer strictly consumes infrastructure bounds listed in your `AWS-ECS-Credentials` Block.
```

**Prompt:** 
```
List all active automations tracking webhook payloads.
```

**Response:** 
```
Running `list_automations` globally. I discovered 2 explicit rules: 'Slack Incident Notifier' reacting to Flow FAILED triggers, and 'K8s Pod Cleanup' executing automatically when an ECS cluster returns 'Destroyed' payloads.
```

## Capabilities

### List all defined workflows
See a catalog of every Python workflow you've registered in Prefect Cloud.

### Check recent run history and status
Get lists of past flow runs—whether they were scheduled, active, or failed—to understand the full execution timeline.

### Retrieve detailed failure data
Pull all contextual metadata for a specific run to read the exact Python traceback and variables that caused a crash.

### Audit infrastructure connections
List secure connection blocks, including details on AWS or GCP credentials used by your environment.

### Review automated triggers
See which webhooks and events are set up to automatically start a flow when something else happens.

## Use Cases

### Debugging a sudden data sync failure
A data scientist notices that the 'Nightly Stripe Sync' failed. They ask their agent to check recent flow runs and get_flow_run, which immediately returns a specific `psycopg2.OperationalError`, telling them it’s a database timeout issue.

### Verifying cluster credentials before deployment
A DevOps engineer needs to know if the 'Production Data Warehouse' is using the correct secrets. They ask the agent to list_blocks, confirming that the job pulls its necessary AWS-ECS-Credentials from the right secure location.

### Mapping external flow triggers
A team lead wants to know what services can start a pipeline. They prompt the agent to list_automations, which reveals that 'Slack Incident Notifier' is active and reacting to Flow FAILED triggers.

### Checking job routing paths
A team questions why a new batch job isn’t running. They ask the agent to list_work_pools, identifying that the intended destination pool was misspelled or decommissioned.

## Benefits

- Stop digging through scattered logs. Instead, ask your agent to check the run history via list_flow_runs, instantly seeing if a sync failed and when.
- Get immediate root cause analysis using get_flow_run. You pull the full Python traceback directly from Prefect Cloud without needing SSH access or manual log parsing.
- Audit your entire setup by listing all secure infrastructure blocks (list_blocks). Verify exactly which AWS keys or GCP configurations are tied to running jobs.
- Understand how your system is triggered. Use list_automations to see every webhook that can kick off a flow, preventing unexpected job runs.
- Track the source of execution. List work pools tells you where a job is physically supposed to run, helping DevOps Ops verify routing paths.

## How It Works

The bottom line is that you get immediate visibility into pipeline health without opening any separate dashboard or terminal.

1. Subscribe to this MCP and provide your Prefect API Key, Account ID, and Workspace ID.
2. Engage with your data flows using your AI client, asking specific questions like 'Why did the Stripe Sync fail?'
3. Your agent uses the configured tools to fetch run metadata and error logs directly from Prefect Cloud.

## Frequently Asked Questions

**How do I check if my workflow ran successfully using Prefect MCP?**
You use list_flow_runs to get a history of all runs. You can filter this data by time or status (like 'success') to see recent activity.

**Can I see the actual Python error message with Prefect MCP?**
Yes, you use get_flow_run. This tool pulls all contextual metadata and the specific variables tied to a run, letting you read the complete traceback.

**What is list_blocks for in Prefect MCP?**
list_blocks lets you audit secure infrastructure connections. It lists critical items like AWS or GCP credentials so you know what secrets your workflows are using.

**Does the Prefect MCP help me debug webhooks?**
Yes, you use list_automations to review every active rule. This shows exactly which webhook event is mapped to trigger a flow in real-time.

**Is this helpful for DevOps Ops managing job routing?**
Absolutely. You can run list_work_pools to see all physical destination pools, confirming that jobs are correctly routed to the intended Kubernetes or Docker cluster.