Skip to content

feat: turn chatflow into MCP server#5930

Open
prd-hoang-doan wants to merge 1 commit intoFlowiseAI:mainfrom
prd-hoang-doan:feat/chatflow-mcp-server
Open

feat: turn chatflow into MCP server#5930
prd-hoang-doan wants to merge 1 commit intoFlowiseAI:mainfrom
prd-hoang-doan:feat/chatflow-mcp-server

Conversation

@prd-hoang-doan
Copy link
Contributor

Ticket:

Flowise Roadmap (view)

Overview:

Adds first-class Model Context Protocol (MCP) support so a chatflow/agentflow can be exposed as an MCP server, including server-side endpoints (Streamable HTTP + deprecated SSE transport), persisted configuration, and a UI configuration tab.

Changes:

  • Added '@modelcontextprotocol/sdk' version 1.12.0
  • Added 'zod' version 3.25.32
  • Added migrations for MCP server config
  • Added MCP endpoints (Streamable HTTP and SSE)
  • Added MCP server configuration tab
  • Added unit tests for MCP endpoints and services

Testing

Unit test

image

Integration test

Scenario: Conversational Agent -> Github MCP -> Flowise Chatflow -> Custom MCP -> Third Party Platform

Platform Streamable HTTP MCP SSE Note
n8n ✅ Pass ✅ Pass There is warning message on n8n UI, but the request is successful
dify ✅ Pass ✅ Pass
activepieces ✅ Pass ✅ Pass
make ✅ Pass ✅ Pass
langsmith ❌ Fail ❌ Fail Langsmith don't send the request with Authorization

Demo Recording:

Youtube: https://youtu.be/l7R2xRm0-XQ

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands Flowise's interoperability by transforming chatflows into Model Context Protocol (MCP) servers. This allows other applications and AI agents to discover and utilize Flowise chatflows as specialized tools, enhancing the platform's integration capabilities and enabling more complex, multi-agent workflows. The changes include the necessary backend infrastructure, API endpoints, database schema updates, and a user-friendly interface for configuring these new server functionalities.

Highlights

  • Model Context Protocol (MCP) Server Support: Introduced first-class support for exposing Flowise chatflows and agentflows as MCP servers, enabling external applications to interact with them as tools.
  • MCP Endpoints and Transports: Implemented server-side endpoints for both the Streamable HTTP protocol and the deprecated Server-Sent Events (SSE) transport, ensuring compatibility with various MCP clients.
  • Persisted Configuration and UI: Added functionality to persist MCP server configurations, including tool name, description, and access tokens, along with a new UI tab for easy management within the chatflow settings.
  • New Dependencies and Database Migrations: Integrated @modelcontextprotocol/sdk for MCP server functionality and zod for schema validation. Database migrations were added to store MCP server configurations for each chatflow.
  • Enhanced Security and Rate Limiting: Included MCP_CORS_ORIGINS environment variable for fine-grained control over cross-origin requests to MCP endpoints and integrated rate limiting for endpoint protection.
  • Comprehensive Testing: Provided unit tests for the new MCP controllers and services, alongside integration tests demonstrating compatibility with various platforms like n8n, Dify, Activepieces, and Make.
Changelog
  • CONTRIBUTING.md
    • Added documentation for the new MCP_CORS_ORIGINS environment variable.
  • docker/.env.example
    • Updated the example environment file to include MCP_CORS_ORIGINS.
  • docker/docker-compose-queue-prebuilt.yml
    • Configured the Docker Compose file to pass MCP_CORS_ORIGINS to the Flowise service.
  • docker/docker-compose.yml
    • Configured the Docker Compose file to pass MCP_CORS_ORIGINS to the Flowise service.
  • packages/server/.env.example
    • Updated the example environment file to include MCP_CORS_ORIGINS.
  • packages/server/package.json
    • Added @modelcontextprotocol/sdk for MCP server implementation and zod for schema validation.
  • packages/server/src/Interface.ts
    • Extended the IChatFlow interface with an optional mcpServerConfig field.
  • packages/server/src/commands/base.ts
    • Added MCP_CORS_ORIGINS as a configurable flag for server commands.
  • packages/server/src/controllers/mcp-endpoint/index.ts
    • Introduced a new controller to handle incoming MCP endpoint requests, including Streamable HTTP and SSE transports.
  • packages/server/src/controllers/mcp-server/index.ts
    • Created a new controller for managing MCP server configurations (get, create, update, delete, refresh token).
  • packages/server/src/database/entities/ChatFlow.ts
    • Added a mcpServerConfig column to the ChatFlow entity for storing MCP server settings.
  • packages/server/src/database/migrations/mariadb/1767000000000-AddMcpServerConfigToChatFlow.ts
    • Added a MariaDB migration to introduce the mcpServerConfig column.
  • packages/server/src/database/migrations/mariadb/index.ts
    • Registered the new MariaDB migration.
  • packages/server/src/database/migrations/mysql/1767000000000-AddMcpServerConfigToChatFlow.ts
    • Added a MySQL migration to introduce the mcpServerConfig column.
  • packages/server/src/database/migrations/mysql/index.ts
    • Registered the new MySQL migration.
  • packages/server/src/database/migrations/postgres/1767000000000-AddMcpServerConfigToChatFlow.ts
    • Added a PostgreSQL migration to introduce the mcpServerConfig column.
  • packages/server/src/database/migrations/postgres/index.ts
    • Registered the new PostgreSQL migration.
  • packages/server/src/database/migrations/sqlite/1767000000000-AddMcpServerConfigToChatFlow.ts
    • Added a SQLite migration to introduce the mcpServerConfig column.
  • packages/server/src/database/migrations/sqlite/index.ts
    • Registered the new SQLite migration.
  • packages/server/src/routes/index.ts
    • Integrated new routes for MCP server configuration and endpoint handling.
  • packages/server/src/routes/mcp-endpoint/index.ts
    • Defined API routes for MCP endpoint interactions, including CORS and rate limiting middleware.
  • packages/server/src/routes/mcp-server/index.ts
    • Defined API routes for managing MCP server settings.
  • packages/server/src/services/mcp-server/endpoint.ts
    • Implemented the core logic for processing MCP requests and SSE streams, including tool registration and chatflow execution callbacks.
  • packages/server/src/services/mcp-server/index.ts
    • Developed the service layer for MCP server configuration management, token generation, and validation.
  • packages/server/src/utils/buildAgentflow.ts
    • Adjusted agentflow input validation to correctly handle empty form objects.
  • packages/server/src/utils/constants.ts
    • Whitelisted the new MCP chatflow endpoint to allow unauthenticated access for external clients.
  • packages/server/src/utils/mockRequest.ts
    • Added a utility to create mock Express request objects for internal testing purposes.
  • packages/server/test/controllers/mcp-endpoint.test.ts
    • Added unit tests for the MCP endpoint controller to verify request handling and authentication.
  • packages/server/test/services/mcp-server.test.ts
    • Added unit tests for the MCP server service, covering configuration CRUD and token management.
  • packages/server/test/utils/mockRequest.test.ts
    • Added unit tests for the createMockRequest utility function.
  • packages/ui/src/api/mcpServer.js
    • Created new API client functions for interacting with the MCP server configuration endpoints.
  • packages/ui/src/ui-component/dialog/ChatflowConfigurationDialog.jsx
    • Integrated the new McpServer component into the chatflow configuration dialog.
  • packages/ui/src/ui-component/extended/McpServer.jsx
    • Developed a new UI component for configuring MCP server settings, including enabling/disabling, tool details, and token management.
Activity
  • The author has implemented first-class MCP server support, including both Streamable HTTP and deprecated SSE transport endpoints.
  • Database migrations have been added to persist MCP server configurations.
  • A new UI configuration tab has been developed to manage MCP server settings.
  • Unit tests for MCP endpoints and services have been created and passed.
  • Integration tests were conducted with various platforms (n8n, Dify, Activepieces, Make), showing successful interactions, though Langsmith failed due to authorization issues.
  • A demo recording is available on YouTube to showcase the new functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces first-class Model Context Protocol (MCP) support, allowing a chatflow to be exposed as an MCP server. The changes are extensive and well-structured, including new dependencies, database migrations, API endpoints, services, UI components, and comprehensive unit tests. My review focuses on improving code maintainability by reducing duplication in controllers by applying recommended middleware patterns for authorization and validation, and ensuring consistency in dependency management and code comments. Overall, this is a solid feature addition.

- Added '@modelcontextprotocol/sdk' version 1.12.0
- Added 'zod' version 3.25.32
- Added migrations for MCP server config
- Added MCP endpoints (Streamable HTTP and SSE)
- Added MCP server configuration tab
- Added unit tests for MCP endpoints and services
@prd-hoang-doan prd-hoang-doan force-pushed the feat/chatflow-mcp-server branch from a41f96f to 2c31965 Compare March 8, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant