Skip to content

[RFC] Feat: Add MCP server tool calling support. #7781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

notsyncing
Copy link
Contributor

@notsyncing notsyncing commented May 21, 2025

What problem does this PR solve?

Hello, we are exposing some MCP endpoints on our backend service, and we want to use it in the Generate component for tool calling, so I created this PR.

This PR does two things:

  1. Added a MCP server management mechanism:

Added a MCP Server page in the settings. It can add, modify, or delete available MCP servers. MCP servers are bound to per tenant.
An MCPServerService was added for CRUD of these servers (api/db/services/mcp_server_service.py).

Supported MCP server types are: SSE and Streamable HTTP.

It can also define custom HTTP headers which will be sent to MCP servers, the headers can use variables.

image

image

it includes a new table mcp_server, and a new settings page above.

  1. Added MCP server tool calling mechanism to the Generate component:

You can select one or more MCP servers configured in the settings page for the LLM to use. This dropdown is also controlled by the is_tools property of the selected LLM.

image

You can also bind variables to MCP servers.

An example MCP tool server is also added in mcp/server/simple_tools_server.py. It contains a bad calculator tool, which computes a + b + 200. You can start it with command: python mcp/server/simple_tools_server.py in the ragflow venv.

With that server started at localhost:8080, the Generate component can use it:

image

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

@yingfeng yingfeng requested a review from yongtenglei May 22, 2025 01:54
@lizheng419
Copy link
Contributor

Very good features

@notsyncing notsyncing marked this pull request as ready for review May 26, 2025 13:31
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels May 26, 2025
@ZhenhangTung
Copy link

@notsyncing Hi. I'm the product manager of RAGFlow. Soooooo thanks for opening this PR. Supporting MCP in Agent module is on our plan. Could you send me an email at zhenhangtung@gmail.com so we can better align our vision with your work?

@notsyncing
Copy link
Contributor Author

@notsyncing Hi. I'm the product manager of RAGFlow. Soooooo thanks for opening this PR. Supporting MCP in Agent module is on our plan. Could you send me an email at zhenhangtung@gmail.com so we can better align our vision with your work?

Sure! I have sent you a mail.

@yingfeng yingfeng added the ci Continue Integration label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants