Dify as MCP Server logo

Dify as MCP Server

by Yevanchen

This project implements a Dify plugin to expose Dify workflows as a Model Context Protocol (MCP) server for AI clients like Claude. It allows AI clients to discover and use your Dify workflows as tools.

View on GitHub

Last updated: N/A

What is Dify as MCP Server?

This is a Dify plugin that acts as a Model Context Protocol (MCP) server, allowing AI clients like Claude Desktop and Cursor to access and utilize Dify workflows as tools.

How to use Dify as MCP Server?

  1. Configure your Dify application with at least one workflow. 2. In the AI client (e.g., Claude, Cursor), add a new MCP server with the URL https://your_dify_instance_address/difyapp_as_mcp_server. 3. Save and enable the server in the client settings. 4. Use the tools in the AI client.

Key features of Dify as MCP Server

  • Supports MCP standard JSON-RPC interface

  • Automatic tool discovery and registration

  • Compatible with Claude Desktop/Cursor

  • Secure SSE connection implementation

  • Server-side session management

  • Compliant with the latest MCP Streamable HTTP specification

Use cases of Dify as MCP Server

  • Providing Dify workflows as tools to Claude and other AI clients

  • Enabling AI clients to discover and use Dify workflows

  • Integrating Dify workflows into AI assistants without modifying the workflows

  • Exposing Dify applications as tools in Cursor Agent

FAQ from Dify as MCP Server

What if I have connection problems?

Ensure the URL is correct and accessible. Check for firewalls or proxies.

Why are the tools not visible?

Ensure the application ID is configured correctly. Check if the workflow is published. Confirm the Dify API key has sufficient permissions.

What if tool execution fails?

Check the Dify application logs. Confirm the workflow runs normally in Dify.

How does the server handle sessions?

The server generates and manages session IDs, supporting a stateless server mode suitable for Dify's plugin environment.

What is the architecture of the plugin?

The plugin uses two endpoints: a GET endpoint for SSE connections and HTML pages, and a POST endpoint for JSON-RPC requests.