What is the Prefect MCP server?
The Prefect MCP server is an MCP server that provides AI assistants with tools to:- Monitor & inspect: View system health, query deployments, flow runs, task runs, work pools, and execution logs
- Debug intelligently: Get contextual guidance for troubleshooting failed flows and deployment issues
- Access documentation: Query up-to-date Prefect documentation through an integrated docs proxy
prefect CLI.
Security considerations
The Prefect MCP server provides read-only access to your Prefect instance. It can only access information available to the account you authenticate with—it cannot access data outside those bounds. For detailed answers to common security questions—including authentication patterns, RBAC, file access requirements, and recommendations for internal pilots—see the Security FAQ.Quick start
The fastest way to get started depends on your AI assistant:Claude Code
Claude Code
Recommended: Use the marketplaceThis installs both the MCP server and a CLI skill for working with Prefect.Alternative: Manual setup
Cursor
Cursor
Add this configuration to
.cursor/mcp.json in your project:Codex CLI
Codex CLI
Gemini CLI
Gemini CLI
Test your setup
Once configured, try these prompts to verify the connection:- “Show me my recent flow runs”
- “What deployments are available?”
- “Debug my last failed flow run”
Installation options
Local installation (stdio transport)
The default setup runs the MCP server locally usinguvx. The server automatically inherits credentials from your active Prefect profile:
~/.prefect/profiles.toml by default
Cloud deployment (HTTP transport)
Deploy the MCP server to FastMCP Cloud for remote access from any client:Fork the repository
Fork the prefect-mcp-server repository on GitHub
Deploy to FastMCP Cloud
- Sign in to fastmcp.cloud
- Create a new server pointing to your fork
- Configure:
- Server path:
src/prefect_mcp_server/server.py - Requirements:
pyproject.toml(or leave blank)
- Server path:
Set environment variables
Configure credentials in the FastMCP Cloud interface:
| Environment Variable | Prefect Cloud | Self-hosted Prefect |
|---|---|---|
PREFECT_API_URL | https://api.prefect.cloud/api/accounts/[ACCOUNT_ID]/workspaces/[WORKSPACE_ID] | Your server URL (e.g., http://your-server:4200/api) |
PREFECT_API_KEY | Your Prefect Cloud API key | Not used |
PREFECT_API_AUTH_STRING | Not used | Your authentication string (if using basic auth) |
When deploying to FastMCP Cloud, environment variables are configured on the FastMCP Cloud server itself, not in your client configuration. FastMCP’s authentication secures access to your MCP server, while the MCP server uses your Prefect API key to access your Prefect instance.
Client configuration
Configuration basics
All MCP clients need these components to connect:- Command:
uvx - Arguments:
--from prefect-mcp prefect-mcp-server - Environment variables (optional): Explicit Prefect credentials
Claude Code
Claude Code
- Marketplace (Recommended)
- Manual CLI Setup
The easiest way to install:This installs both the MCP server (for read-only diagnostics) and a CLI skill (for mutations like triggering deployments or cancelling runs).
The plugin uses your local Prefect configuration from
~/.prefect/profiles.toml. For explicit credentials, use the manual CLI setup.Cursor
Cursor
- Basic Setup
- With Explicit Credentials
- HTTP Transport (FastMCP)
Create or edit Uses credentials from
.cursor/mcp.json in your project:~/.prefect/profiles.tomlCodex CLI
Codex CLI
- CLI Setup
- Config File
Basic setup:With explicit Prefect Cloud credentials:
Gemini CLI
Gemini CLI
- CLI Setup
- Config File
Basic setup (stdio):With explicit Prefect Cloud credentials:HTTP transport (FastMCP Cloud):
Credentials configuration
The Prefect MCP server authenticates with your Prefect instance using the same configuration as the Prefect SDK.Default behavior
When running locally without environment variables, the server inherits credentials from your active Prefect profile:- Profile configuration:
~/.prefect/profiles.toml - Uses the same API URL and authentication as your current
prefectCLI commands
Environment variables
Override the default credentials by setting environment variables: For Prefect Cloud:Credential precedence
Environment variables take precedence over profile settings:- Environment variables (
PREFECT_API_URL,PREFECT_API_KEY) - Active Prefect profile (
~/.prefect/profiles.toml)
Available capabilities
The Prefect MCP server provides these main capabilities:Monitoring & inspection
- View dashboard overviews with flow run statistics and work pool status
- Query deployments, flow runs, task runs, and work pools with advanced filtering
- Retrieve detailed execution logs from flow runs
- Track events across your workflow ecosystem
- Review automations and their configurations
Orchestration & actions
- Trigger deployment runs with custom parameters and tags
- Pass dynamic configurations to workflows at runtime
Intelligent debugging
- Get contextual guidance for troubleshooting failed flow runs
- Diagnose deployment issues including concurrency problems
- Identify root causes of workflow failures
- Analyze rate limiting issues (Prefect Cloud only)
Documentation access
The MCP server includes a built-in docs proxy that provides AI assistants with up-to-date information from the Prefect documentation. This enables your AI assistant to:- Look up current API syntax and usage patterns
- Find the correct
prefectCLI commands for creating and updating resources - Access the latest best practices and examples
Prompting tips
To get the most out of the Prefect MCP server, guide your AI assistant with these patterns:Use the prefect CLI for write operations
The MCP tools are optimized for reading and monitoring. For creating or updating resources, prompt your assistant to use theprefect CLI:
Example prompts:
- “Use the
prefectCLI to create a new deployment” - “Show me how to update this deployment’s schedule using
prefect” - “Create an automation using the
prefectCLI”
Leverage the docs proxy
The integrated docs proxy gives your assistant access to current Prefect documentation: Example prompts:- “Look up the latest syntax for creating a work pool”
- “Find documentation on how to configure Docker work pools”
- “What are the current best practices for deployment configuration?”
Ask diagnostic questions
The MCP server excels at helping diagnose issues: Example prompts:- “Why is my deployment not running?”
- “Debug the last failed flow run”
- “Why are my flow runs delayed?”
- “Show me which work pools have no active workers”