Dify MCP server

Integrates Dify's AI application development platform with MCP-compatible tools and services, enabling seamless extension of Dify applications with external capabilities while maintaining the familiar environment.
Back to servers
Provider
Yevan Chen
Release date
Mar 18, 2025
Language
Python
Stats
33 stars

This MCP server plugin allows you to expose your Dify workflows as tools to AI clients that support the Model Context Protocol (MCP), such as Claude Desktop and Cursor. This enables AI assistants to discover and interact with your workflows without requiring any modifications to them.

Installation

To set up the Dify MCP server plugin:

  1. Install the plugin through the Dify plugin interface
  2. Configure the plugin settings:
    • Application ID: The ID of the Dify application you want to expose
    • Other settings: Configure as needed

Usage

Setting Up in Dify

Before using the MCP server, ensure your Dify application contains at least one workflow that has been properly configured.

Connecting with Claude Desktop

  1. Open Claude Desktop
  2. Navigate to Settings > MCP Servers
  3. Add a new MCP server with the URL:
    https://your-dify-instance-address/difyapp_as_mcp_server
    
  4. Save and enable the server

Connecting with Cursor

  1. Open Cursor
  2. Go to Settings > AI > MCP
  3. Add the server address:
    https://your-dify-instance-address/difyapp_as_mcp_server
    
  4. Save and enable
  5. Use your tools within Cursor Agent

Troubleshooting

Connection Issues

  • Verify that the URL is correct and accessible
  • Check if your server is behind a firewall or proxy

Tools Not Visible

  • Ensure the application ID is configured correctly
  • Verify that workflows have been published
  • Confirm your Dify API key has sufficient permissions

Tool Execution Failures

  • Check the Dify application logs
  • Verify that workflows run properly in Dify itself

Technical Information

Features

  • ✅ JSON-RPC interface supporting MCP standard
  • ✅ Automatic tool discovery and registration
  • ✅ Compatibility with Claude Desktop/Cursor clients
  • ✅ Secure SSE connection implementation
  • ✅ Server-side session management
  • 🔄 Compliance with latest MCP Streamable HTTP specification

Architecture

The plugin implements an MCP server using two endpoints:

  • GET endpoint: Handles SSE connections and HTML pages
  • POST endpoint: Processes JSON-RPC requests

The implementation includes:

  • Server-side session ID generation
  • Limited heartbeat mode (approximately 5 minutes)
  • Automatic reconnection after client disconnects
  • Compliance with the latest Streamable HTTP specification

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later