1.5.2 • Published 1 year ago

@liangshen/dify-mcp-server v1.5.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Dify MCP Server

这是一个用于访问 Dify API 的 Model Context Protocol (MCP) 服务实现,可以让支持 MCP 协议的 AI 助手(如 Claude, Cursor, Clion, Cherry Studio)直接与 Dify 工作流进行交互。

功能特点

  • 支持通过 SSE (Server-Sent Events) 方式部署为网络服务
  • 支持通过 stdio (标准输入/输出) 方式在本地使用
  • 支持自定义用户 ID,方便追踪和管理
  • 完全兼容 Model Context Protocol 规范

安装方法(STDIO模式运行不需要安装)

全局安装

npm install -g @liangshen/dify-mcp-server

使用方法

方式一:作为 SSE 服务运行

SSE 模式适合部署为网络服务,允许多个客户端同时连接。

准备一个.env文件放在一个目录中

DIFY_API_KEY=your_api_key                # 必填,Dify API 密钥
DIFY_API_BASE=https://your-dify-url      # Dify API 地址,默认为 https://cloud.dify.ai
DIFY_USER_ID=your_user_id                # 用户 ID,用于识别请求用户
DIFY_DESC=搜索BI相关内容                    # 工具描述,默认为"执行工作流"

1. 启动服务

在目录下运行以下脚本

dify-mcp-sse-server
dify-mcp-sse-server & #后台运行

服务将在 http://localhost:3001 上启动。

2. 客户端使用

在支持SSE的MCP客户端使用如下URL:

http://localhost:3001/sse

方式二:使用 stdio 本地运行

stdio 模式适合在本地直接使用,常用于开发测试或与其他支持 stdio 通信的应用集成。

{
  "mcpServers": {
    "BI Search": {
      "command": "npx",
      "args": [
        "-y",
        "@liangshen/dify-mcp-server"
      ],
      "env": {
        "DIFY_DESC": "搜索BI相关内容",
        "DIFY_API_KEY": "xxx",
        "DIFY_API_BASE": "xxx",
        "DIFY_USER_ID": "your_user_id"
      }
    }
  }
}

在 stdio 模式下,程序将通过标准输入/输出与调用程序通信。

开发与构建

# 安装依赖
npm install

# 构建项目
npm run build

# 启动 SSE 服务
npm start

许可证

ISC

作者

Wang Liang 850598163@qq.com

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago