Dify MCP 服务器
基于 TypeScript 的 MCP(模型上下文协议)服务器,用于连接 MCP 客户端和 Dify 应用。该服务器动态地将 Dify 应用公开为可在 MCP 客户端中直接使用的工具。
概述
该服务器实现了模型上下文协议 (MCP),用于连接 MCP 客户端和 Dify 应用。它动态地从 Dify API 获取应用规范,并将其公开为 MCP 工具。该服务器允许用户通过 MCP 客户端内的统一界面与多个 Dify 应用进行交互。
特征
动态 Dify 集成
- 使用 API 密钥连接到多个 Dify 应用程序
- 自动获取应用程序元数据和参数
- 根据Dify应用规范动态生成工具界面
- 支持各种输入类型,包括文本、段落和选择下拉菜单
请求处理
- 通过请求重试实现强大的错误处理
- 支持阻塞和流式响应模式
- JSON BigInt 处理大数值
配置
- 通过环境变量配置的 API 密钥
- 可配置基本 URL 和超时设置
- 当环境变量不可用时回退到默认值
安装
先决条件
- Node.js(v16 或更高版本)
- npm 或 yarn
设置
- 克隆存储库
- 安装依赖项
- 构建项目
与 Windsurf IDE 集成
要与 Windsurf IDE 一起使用,请将服务器配置添加到您的 MCP 设置中:
环境变量
AGENT_API_KEYS
:Dify API 密钥的逗号分隔列表BASE_URL
:Dify API 的基本 URL(默认值: https ://api.dify.ai )TIMEOUT
:请求超时(以毫秒为单位)(默认值:60000)
如何获取环境变量
APISSH(AGENT_API_KEYS):多个以,分割
用法
配置完成后,Dify MCP 服务器将:
- 使用提供的 API 密钥连接到指定的 Dify 应用程序
- 获取应用程序元数据和参数规范
- 根据Dify应用配置生成MCP工具接口
- 使这些工具在 Windsurf IDE 中可用
每个 Dify 应用程序将作为一个单独的工具公开,其名称格式为dify_app_info_{application_name}
。
发展
可用脚本
npm run build
:构建项目npm run prepare
:准备分发项目npm run watch
:观察变化并重建npm run inspector
:运行 MCP 检查器进行调试
项目结构
src/index.ts
:主服务器实现src/request.ts
:用于 Dify API 通信的 HTTP 客户端src/type.ts
:Dify API 的 TypeScript 接口
故障排除
如果您遇到问题:
- 验证您的 API 密钥是否正确并具有必要的权限
- 检查 BASE_URL 是否可以从您的环境访问
- 查看服务器日志以获取详细的错误消息
- 确保 Dify 应用程序配置正确且可访问
执照
该项目根据 LICENSE 文件中指定的条款进行许可。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
基于 TypeScript 的服务器,将 MCP 客户端连接到 Dify 应用程序,动态地将 Dify 应用程序公开为可在 MCP 客户端内直接使用的工具。
Related MCP Servers
- -securityFlicense-qualityServer for using Dify. It achieves the invocation of the Dify workflow by calling the tools of MCP.Last updated -189Python
- AsecurityFlicenseAqualityA TypeScript-based MCP server designed for experimentation and integration with Calude Desktop and Cursor IDE, offering a modular playground for extending server capabilities.Last updated -29324JavaScript
- -securityFlicense-qualityExposes Dify applications (both Chatflow and Workflow) as MCP (Model Context Protocol) servers, allowing Claude and other MCP clients to directly interact with Dify apps through a standardized protocol.Last updated -18Python
- -securityAlicense-qualityA TypeScript framework for building MCP servers with client session management capabilities, supporting tools definition, authentication, image content, logging, and error handling.Last updated -6,371TypeScriptMIT License