[RFC] Feat: Add MCP server tool calling support. #7781
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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
andStreamable HTTP
.It can also define custom HTTP headers which will be sent to MCP servers, the headers can use variables.
it includes a new table
mcp_server
, and a new settings page above.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.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 computesa + 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
, theGenerate
component can use it:Type of change