Prefect MCP Server allows you to run a Model Context Protocol server for Prefect workflows. It provides a reliable configuration using the prefect-mcp-server
package with uvx
as the running mechanism, specifically optimized for the Cursor IDE.
Create and activate a virtual environment, then install the Prefect MCP Server:
uv venv --python 3.12 && source .venv/bin/activate
uv pip install -U prefect-mcp-server
Configure the server by creating a .cursor/mcp.json
file with the following content:
{
"mcpServers": {
"prefect": {
"command": "uvx",
"args": [
"prefect-mcp-server"
],
"env": {}
}
}
}
This configuration ensures that the server runs with the exact package version installed via uv, providing enhanced reliability in your development environment.
Set up your Prefect environment by creating a .env
file in your project root:
PREFECT_API_URL=http://localhost:4200/api
If you're connecting to Prefect Cloud or a secured Prefect server, you may also need to set:
PREFECT_API_KEY=your-api-key-here
To manually start the server, run:
uv run <script>
When using the Cursor IDE with the proper configuration, the server will automatically start using the command specified in your .cursor/mcp.json
file.
Once running, the Prefect MCP Server provides Model Context Protocol functionality for your Prefect workflows. You can interact with it through the Cursor IDE or any other MCP client.
The server runs locally by default. Your Prefect client should be configured to connect to the API URL specified in your environment variables.
With the server running, you can create and execute Prefect workflows that leverage the MCP capabilities, allowing for enhanced context-aware automation and intelligence in your workflow executions.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.