home / mcp / prefect mcp server

Prefect MCP Server

An MCP implementation for Prefect

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "allen-munsch-mcp-prefect": {
      "command": "mcp-prefect",
      "args": [
        "--transport",
        "stdio"
      ],
      "env": {
        "MCP_PORT": "8000",
        "PREFECT_API_KEY": "your_api_key_here",
        "PREFECT_API_URL": "http://localhost:4200/api"
      }
    }
  }
}

You can run a Prefect MCP Server to let AI assistants interact with Prefect by sending natural-language requests. The MCP server exposes a lightweight bridge that translates your queries into Prefect actions, such as creating flows, managing deployments, and reading logs, so you can control your Prefect environment from chat or automation tools.

How to use

Run the MCP server locally using stdio transport so you can connect compatible MCP clients that speak the MCP protocol. This setup lets you issue natural-language requests like listing flows, starting a flow run, pausing schedules, or querying logs, and have them executed by Prefect.

How to install

Prerequisites: you need Python and a working internet connection to install the MCP client library. You also need access to your Prefect API endpoint and an API key to authorize requests.

pip install mcp-prefect
```

# Alternative: install from source
```
git clone https://github.com/allen-munsch/mcp-prefect
cd mcp-prefect
pip install -e .
```

# Quick start (stdio transport)
```
PREFECT_API_URL=http://localhost:4200/api \
PREFECT_API_KEY=your_api_key_here \
MCP_PORT=8000 \
mcp-prefect --transport stdio

Additional configuration and examples

To connect a client, use a stdio configuration that specifies the command and environment variables shown below. This enables a local MCP server for Prefect interactions.

{
  "mcpServers": {
    "prefect": {
      "command": "mcp-prefect",
      "args": ["--transport", "stdio"],
      "env": {
        "PREFECT_API_URL": "http://localhost:4200/api",
        "PREFECT_API_KEY": "your_api_key_here"
      }
    }
  }
}

Security and best practices

Keep your Prefect API key confidential. Use environment-scoped keys when possible and restrict MCP access to trusted clients. If you expose the MCP server over a network, enable firewalls and rotate API keys periodically.

Troubleshooting

If the MCP server fails to start, verify that the required environment variables are set correctly and that the Prefect API URL is reachable. Check that the MCP port you choose is not blocked by your firewall. If you switch transport backends, ensure the corresponding command and arguments are updated in your client configuration.

Available tools

create_artifact

Create a new artifact and store its metadata in Prefect.

delete_artifact

Remove an artifact from Prefect storage.

get_artifact

Retrieve a specific artifact by its ID.

get_artifacts

List artifacts matching given criteria.

get_latest_artifacts

Fetch the most recently created artifacts.

update_artifact

Update metadata or content for an artifact.

create_automation

Create a new automation workflow.

delete_automation

Delete an existing automation workflow.

get_automation

Retrieve a single automation by ID.

get_automations

List all automations.

pause_automation

Pause an automation workflow.

resume_automation

Resume a paused automation.

update_automation

Update parameters of an automation.

delete_block_document

Remove a block document.

get_block_document

Retrieve a block document by ID.

get_block_documents

List block documents.

get_block_type

Fetch details about a block type.

get_block_types

List available block types.

delete_deployment

Delete a deployment.

get_deployment

Get deployment details.

get_deployment_schedule

Retrieve deployment schedules.

get_deployments

List deployments.

pause_deployment_schedule

Pause a deployment schedule.

resume_deployment_schedule

Resume a deployment schedule.

set_deployment_schedule

Set or update deployment schedules.

update_deployment

Update deployment parameters.

cancel_flow_run

Cancel an ongoing flow run.

create_flow_run_from_deployment

Create a flow run associated with a deployment.

delete_flow

Remove a flow definition.

delete_flow_run

Delete a specific flow run.

get_flow

Fetch a flow definition.

get_flow_run

Get details about a specific flow run.

get_flow_run_logs

Retrieve logs for a flow run.

get_flow_runs

List flow runs.

get_flow_runs_by_flow

List runs for a specific flow.

get_flows

List all flows.

get_task_runs_by_flow_run

List task runs within a flow run.

restart_flow_run

Restart a flow run.

set_flow_run_state

Set the state of a flow run.

create_log

Create a log entry.

get_logs

Fetch logs.

get_health

Check server health.

get_task_run

Retrieve a task run.

get_task_run_logs

Get logs for a task run.

get_task_runs

List task runs.

set_task_run_state

Update the state of a task run.

create_variable

Create a variable in the workspace.

delete_variable

Delete a variable.

get_variable

Get a specific variable.

get_variables

List all variables.

update_variable

Update a variable.

create_work_queue

Create a new work queue.

delete_work_queue

Delete a work queue.

get_current_workspace

Fetch the current workspace.

get_work_queue

Retrieve a work queue by ID.

get_work_queue_by_name

Find a work queue by name.

get_work_queue_runs

List runs for a work queue.

get_work_queues

List all work queues.

get_workspace

Get workspace details.

get_workspace_by_handle

Find a workspace by handle.

get_workspaces

List workspaces.

pause_work_queue

Pause a work queue.

resume_work_queue

Resume a paused work queue.

update_work_queue

Update work queue settings.