logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

dify-mcp-gateway

A middleware layer facilitating secure connectivity between MCP Consumers and various Dify AI services. This component dynamically ingests application schemas from Dify APIs to materialize them as functional, unified interaction points (tools) within the MCP framework, featuring advanced resilience and automated interface provisioning.

Author

dify-mcp-gateway logo

zhuzhoulin

MIT License

Quick Info

GitHub GitHub Stars 4
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

toolstoolmcpdify apisbusiness toolsdify applications

Dify Model Context Protocol Orchestrator

English Version | 中文文档

This utility is a TypeScript implementation of an MCP (Model Context Protocol) bridge, specifically engineered to interface the MCP Client environment with remote Dify application instances. It abstracts Dify services, presenting them directly as executable tools callable by the MCP Client.

Core Functionality

This server adheres to the Model Context Protocol specification, serving as the conduit between the MCP Client and the Dify ecosystem. Its primary function is the real-time retrieval of application definitions from Dify endpoints, which are then instantly exposed as standardized MCP functional units. This design enables comprehensive management of disparate Dify services via a single, coherent interface within the consuming client.

Key Capabilities

Automated Dify Service Integration

  • Establishes connections to numerous Dify deployments utilizing distinct API credentials.
  • Performs automatic ingestion of operational metadata and required parameter specifications.
  • Generates tool definitions programmatically based on the retrieved Dify application blueprints.
  • Offers comprehensive support for diverse input modalities, ranging from simple text strings to structured paragraphs and enumerated selection controls.

Transaction Management

  • Implements sophisticated mechanisms for fault tolerance, including request re-attempt logic.
  • Handles both synchronous (blocking) and asynchronous (streaming) result delivery patterns.
  • Includes specialized serialization logic for 'BigInt' numeric data types encountered in JSON payloads.

Configuration Structure

  • Credentials (API keys) are provisioned via system environment variables.
  • Network configuration, including the Dify API base endpoint and connection timeouts, is customizable.
  • Graceful degradation to predefined default settings if environmental configuration parameters are absent.

Deployment Instructions

Prerequisites

  • Runtime Environment: Node.js, minimum version 16.
  • Package Manager: npm or yarn.

Initial Setup

  1. Obtain the source code repository:

bash git clone https://github.com/zhuzhoulin/dify-mcp-server.git cd dify-mcp-server

  1. Install requisite dependencies:

bash npm install

  1. Compile the source code:

bash npm run build

Integration with IDE Ecosystem (e.g., Windsurf)

To integrate this gateway with your MCP-aware IDE, incorporate the following configuration snippet into your client's settings file:

{ "mcpServers": { "dify-mcp-server": { "command": "node", "args": [ "/path/to/dify-mcp-server/build/index.js" ], "env": { "AGENT_API_KEYS": "key1,key2,key3", "BASE_URL": "https://api.dify.ai", "TIMEOUT": "60000" } } } }

Operational Variables

  • AGENT_API_KEYS: A string containing Dify access tokens, delimited by commas.
  • BASE_URL: The root address for accessing the Dify platform API (Default: https://api.dify.ai).
  • TIMEOUT: The maximum duration, in milliseconds, permitted for an API request (Default: 60000).

Credential Acquisition Notes

API 密钥(AGENT_API_KEYS): 多个以,分割

Operational Flow

Upon successful setup and initialization, the Dify MCP Gateway performs the following sequence:

  1. Authenticates with configured Dify services using the provided access tokens.
  2. Queries and caches the structural metadata and input/output schema for each associated application.
  3. Constructs standardized MCP tool definitions mirroring the fetched Dify application configurations.
  4. Registers these newly instantiated tools, making them accessible within the Windsurf development environment.

Each individual Dify deployment will manifest as a distinct callable tool, named conventionally as dify_app_info_{application_name}.

Development Lifecycle

Available Build Scripts

  • npm run build: Executes the project compilation process.
  • npm run prepare: Finalizes the project assets for package distribution.
  • npm run watch: Initiates continuous compilation upon source file modification.
  • npm run inspector: Launches the integrated MCP diagnostic utility.

Source Organization

  • src/index.ts: Primary entry point and server bootstrap logic.
  • src/request.ts: Module encapsulating the HTTP client responsible for Dify API interaction.
  • src/type.ts: Repository for all TypeScript interface definitions related to the Dify API contracts.

Debugging and Troubleshooting

Should operational difficulties arise, please follow this diagnostic sequence:

  1. Confirm the validity and authorization scope of all specified API credentials.
  2. Validate network accessibility to the configured BASE_URL from the execution environment.
  3. Examine the server console output for detailed error logging.
  4. Verify that the target Dify applications possess correct configuration and are reachable.

Licensing

This software is distributed under the terms documented in the accompanying LICENSE file.

WIKIPEDIA: Business management tools encompass all methodologies, applications, control systems, analytical solutions, and procedural frameworks utilized by commercial entities to effectively navigate evolving market conditions, secure a competitive market position, and enhance overall organizational efficacy.

== Strategic Viewpoint == Business tools can be segmented according to departmental function and management aspect. Examples include: strategic forethought utilities, workflow optimization instruments, record-keeping systems, personnel administration resources, executive decision support mechanisms, and performance monitoring assets. A functional taxonomy might categorize them by these general domains:

Instruments employed for data capture and integrity validation across all operational units. Solutions dedicated to governing and refining organizational workflows. Platforms for aggregating transactional data and facilitating strategic choices. Modern business technology has undergone radical transformation in the preceding decade, driven by rapid technological advancement, making the selection of optimal business instruments a complex challenge for any given corporate setting. This complexity is fueled by perpetual pressures to minimize expenditures while maximizing revenue, the imperative to deeply comprehend client requirements, and the necessity to deliver requisite products precisely as demanded by the market. In this dynamic environment, leadership must adopt a strategic posture toward business process enablement tools, rather than merely adopting the newest available technology. Over-reliance on unaltered, off-the-shelf solutions frequently results in operational instability. Consequently, business management systems must be chosen judiciously and subsequently tailored to meet the specific, unique requirements of the adopting organization, not the reverse.

== Prevalent Instrumentation (2013 Benchmark) == Bain & Company conducted a global survey in 2013 detailing the adoption landscape of business instruments, reflecting regional needs modulated by prevailing economic climates. The ten most frequently cited instruments included:

Strategic blueprinting Client relationship lifecycle management Personnel sentiment assessment via surveys Competitive metric analysis (Benchmarking) Integrated performance measurement (Balanced Scorecard) Identification of core organizational competencies Strategic outsourcing management Structured organizational transformation programs Logistics and inventory coordination (Supply Chain Management) Formalized organizational purpose articulation (Mission/Vision) Target audience delineation (Market Segmentation) Comprehensive quality assurance frameworks (TQM)

== Corporate Software Solutions == Software, or a suite of interconnected programs designed for professional utilization, is termed business software or an enterprise application. These applications are leveraged to augment productivity levels, quantify performance metrics, and execute various organizational functions with high precision. The evolution progressed from rudimentary Management Information Systems (MIS) to expansive Enterprise Resource Planning (ERP) frameworks. Subsequently, Customer Relationship Management (CRM) functionalities were integrated, culminating in the current era of cloud-native enterprise management platforms. While a verifiable link exists between IT investment and organizational output, two factors are critical determinants of achieved value: the efficacy of the deployment process itself and the judicious selection and customization of the employed tools.

== Instruments Tailored for SMBs == Tools specifically designed for Small and Medium-sized Businesses (SMBs) are vital as they supply mechanisms to conserve operational resources, allowing...

See Also

`