Skip to main content

MCP server for interacting with Prefect

Project description

prefect-mcp-server

[!WARNING] This project is under active development and may change drastically at any time.

This is an experimental MCP server for Prefect. APIs, features, and behaviors are subject to change without notice. We encourage you to try it out, provide feedback, and contribute! Please create issues or open PRs with your ideas and suggestions.

An MCP server for interacting with prefect resources.

Quick start

Deploy on FastMCP Cloud

  1. Fork this repository on GitHub (gh repo fork prefecthq/prefect-mcp-server)
  2. Go to fastmcp.cloud and sign in
  3. Create a new server pointing to your fork:
    • server path: src/prefect_mcp_server/server.py
    • requirements: pyproject.toml (or leave blank)
    • environment variables:
      • PREFECT_API_URL: https://api.prefect.cloud/api/accounts/[ACCOUNT_ID]/workspaces/[WORKSPACE_ID]
      • PREFECT_API_KEY: your Prefect Cloud API key (or PREFECT_API_AUTH_STRING for OSS with basic auth)
  4. get your server URL (e.g., https://your-server-name.fastmcp.app/mcp)
  5. Add to your favorite MCP client (e.g., Claude Code):
# add to claude code with http transport
claude mcp add prefect --transport http https://your-server-name.fastmcp.app/mcp

[!NOTE] 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.

Multi-tenant deployments with HTTP headers

For centrally-hosted deployments where multiple users connect to the same MCP server instance, credentials can be passed via HTTP headers instead of environment variables. This enables each user to authenticate with their own Prefect workspace.

Supported headers:

  • X-Prefect-Api-Url: Prefect API URL (required for both Cloud and OSS)
  • X-Prefect-Api-Key: Prefect Cloud API key
  • X-Prefect-Api-Auth-String: Basic auth credentials for OSS (format: username:password)

Claude Code CLI:

claude mcp add-json prefect '{
  "type": "http",
  "url": "https://your-server.fastmcp.app/mcp",
  "headers": {
    "X-Prefect-Api-Url": "https://api.prefect.cloud/api/accounts/[ACCOUNT_ID]/workspaces/[WORKSPACE_ID]",
    "X-Prefect-Api-Key": "your-api-key"
  }
}'

Claude Desktop app:

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "prefect": {
      "type": "http",
      "url": "https://your-server.fastmcp.app/mcp",
      "headers": {
        "X-Prefect-Api-Url": "https://api.prefect.cloud/api/accounts/[ACCOUNT_ID]/workspaces/[WORKSPACE_ID]",
        "X-Prefect-Api-Key": "your-api-key"
      }
    }
  }
}

Python with FastMCP client:

from fastmcp.client import Client
from fastmcp.client.transports import StreamableHttpTransport

headers = {
    "X-Prefect-Api-Url": "https://api.prefect.cloud/api/accounts/[ACCOUNT_ID]/workspaces/[WORKSPACE_ID]",
    "X-Prefect-Api-Key": "your-api-key",
}

transport = StreamableHttpTransport(url="https://your-server.fastmcp.app/mcp", headers=headers)
client = Client(transport=transport)

async with client:
    result = await client.call_tool("get_identity", {})
    print(result)

[!TIP] Find your Prefect Cloud credentials in your dashboard or in ~/.prefect/profiles.toml

[!NOTE] When HTTP headers are provided, they take precedence over environment variables. If no headers are present, the server falls back to using the configured environment variables.

run locally

When running the MCP server locally (via stdio transport), it will automatically use your local Prefect configuration from ~/.prefect/profiles.toml if available.

# minimal setup - inherits from local prefect profile
claude mcp add prefect \
  -- uvx --from prefect-mcp prefect-mcp-server

# or explicitly set credentials
claude mcp add prefect \
  -e PREFECT_API_URL=https://api.prefect.cloud/api/accounts/[ACCOUNT_ID]/workspaces/[WORKSPACE_ID] \
  -e PREFECT_API_KEY=your-cloud-api-key \
  -- uvx --from prefect-mcp prefect-mcp-server

[!NOTE] For open-source servers with basic auth, use PREFECT_API_AUTH_STRING instead of PREFECT_API_KEY

[!TIP] Prefect Cloud users on Team, Pro, and Enterprise plans can use service accounts for API authentication. Pro and Enterprise users can restrict service accounts to read-only access (only see_* permissions) since this MCP server requires no write permissions.

Capabilities

This server enables MCP clients like Claude Code to interact with your Prefect instance:

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

Enable CLI usage

  • Allows AI assistants to effectively use the prefect CLI to manage Prefect resources
  • Create automations, trigger deployment runs, and more while maintaining proper attribution

Intelligent debugging

  • Get contextual guidance for troubleshooting failed flow runs
  • Diagnose deployment issues, including concurrency problems
  • Identify root causes of workflow failures

Development

Setup & testing
# clone the repo
gh repo clone prefecthq/prefect-mcp-server && cd prefect-mcp-server

# install dev deps and pre-commit hooks
just setup

# run tests (uses ephemeral prefect database via prefect_test_harness)
just test

Links


mcp-name: io.github.PrefectHQ/prefect-mcp-server

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prefect_mcp-0.0.1b9.tar.gz (365.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prefect_mcp-0.0.1b9-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

Details for the file prefect_mcp-0.0.1b9.tar.gz.

File metadata

  • Download URL: prefect_mcp-0.0.1b9.tar.gz
  • Upload date:
  • Size: 365.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for prefect_mcp-0.0.1b9.tar.gz
Algorithm Hash digest
SHA256 9cf6733fa8ebaba91f3a11b75b05450a8b2e9665c5f0e5cef471640e088a78bb
MD5 9f85336fa70d9527bb64c97756a9c414
BLAKE2b-256 87923ec030bdfd98ed92a8a5f9cef61a55262c9b93d618d5b257a9853489925c

See more details on using hashes here.

File details

Details for the file prefect_mcp-0.0.1b9-py3-none-any.whl.

File metadata

File hashes

Hashes for prefect_mcp-0.0.1b9-py3-none-any.whl
Algorithm Hash digest
SHA256 bfd6268e567812b4e69ea9f3bd22a09cc0a7d287ebb646cc9e06f19d3e56bebb
MD5 6f256b9fc20f00ecc786bc43457afdb1
BLAKE2b-256 a302eeae7ef87e47a747e9d6e7856f7be947aeaa09feaf6a6704cee81b0d3f2f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page