Prefect with OpenCode
Add Prefect’s local MCP server to OpenCode using your existing Prefect connection.

Before you start
Install OpenCode and uv, then configure a Prefect profile or environment variables for your Cloud workspace or self-hosted server. This uses OpenCode’s standard MCP configuration, not a dedicated Prefect plugin.
Setup
Configure your Prefect connection
Set up local authentication using Prefect’s MCP guide. The server inherits your active Prefect profile unless environment variables override it.
Prefect connection setupAdd Prefect to OpenCode
Merge this entry into your project’s opencode.json or existing opencode.jsonc. Preserve other configuration. OpenCode uses an mcp key and a command array.
opencode.json{ "$schema": "https://opencode.ai/config.json", "mcp": { "prefect": { "type": "local", "command": ["uvx", "--from", "prefect-mcp", "prefect-mcp-server"], "enabled": true } } }Check the connection
Reopen OpenCode in the project and check the server list. Ask it to use the Prefect tools to confirm the configured target and read five recent flow runs without changing anything.
Terminalopencode mcp list
Ask OpenCode to configure the connection
Paste this into your coding agent to walk through the setup.
Connect OpenCode to Prefect using https://docs.prefect.io/v3/how-to-guides/ai/use-prefect-mcp-server and https://opencode.ai/docs/mcp-servers/. Check for uvx and existing OpenCode configuration before editing. Ask which Prefect Cloud workspace or self-hosted server I want. With my approval, merge an mcp.prefect entry with type local, command ["uvx", "--from", "prefect-mcp", "prefect-mcp-server"], and enabled true into the appropriate existing config. Preserve other settings and keep credentials out of chat and version control. Check opencode mcp list, confirm the active Prefect target, and read five recent flow runs without changing workflows.
If the connection fails
Check opencode mcp list for startup failures. Confirm uvx is on PATH and the process can read your Prefect profile. If the first package download exceeds OpenCode’s startup timeout, use the timeout setting documented by OpenCode. Local stdio setup uses Prefect credentials, not opencode mcp auth.