Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(mcp): remove unused force_refresh parameter (#21349)

Sbaaoui Idriss76b068fba2b6
diff --git a/docs/develop/mcp/mcp_tools.md b/docs/develop/mcp/mcp_tools.md
index dc23ebcac0..126710de07 100644
--- a/docs/develop/mcp/mcp_tools.md
+++ b/docs/develop/mcp/mcp_tools.md
@@ -28,7 +28,6 @@ Retrieves relevant chunks from datasets available to the authenticated user. Whe
| `keyword` | boolean | No | `false` | Enables keyword-based search when true. |
| `top_k` | integer | No | `1024` | From `1` through `1024`; maximum candidate count considered before ranking. |
| `rerank_id` | string | No | Empty | Optional reranking model ID. |
-| `force_refresh` | boolean | No | `false` | Passes a metadata refresh request to the retrieval service. |
`page × page_size` must not exceed the fixed window of 512 rerank candidates. Requests beyond that window return an error.
diff --git a/internal/handler/dataset_search_test.go b/internal/handler/dataset_search_test.go
index ea64af1a6a..3ed9d958f0 100644
--- a/internal/handler/dataset_search_test.go
+++ b/internal/handler/dataset_search_test.go
@@ -198,6 +198,32 @@ func TestDatasetsHandlerSearchDatasetsSuccess(t *testing.T) {
}
}
+func TestDatasetsHandlerSearchDatasetsIgnoresUnknownFields(t *testing.T) {
+ gin.SetMode(gin.TestMode)
+ for _, extra := range []string{``, `,"force_refresh":true`, `,"force_refresh":false`, `,"force_refresh":"unused"`, `,"unknown":"unused"`} {
+ t.Run(extra, func(t *testing.T) {
+ fake := &fakeSearchDatasetsService{resp: &service.SearchDatasetsResponse{Total: 2}}
+ h := &DatasetsHandler{searchDatasetsService: fake}
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(http.MethodPost, "/api/v1/retrieval", strings.NewReader(`{"question":"hello","dataset_ids":["ds-1"]`+extra+`}`))
+ req.Header.Set("Content-Type", "application/json")
+ c, _ := gin.CreateTestContext(rec)
+ c.Request = req
+ c.Set("user", &entity.User{ID: "user-1"})
+
+ h.SearchDatasets(c)
+
+ body := decodeSearchResponse(t, rec)
+ if rec.Code != http.StatusOK || body["code"] != float64(common.CodeSuccess) {
+ t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String())
+ }
+ if fake.req == nil || fake.req.Question != "hello" || len(fake.req.DatasetIDs) != 1 || fake.req.DatasetIDs[0] != "ds-1" {
+ t.Fatalf("request = %#v", fake.req)
+ }
+ })
+ }
+}
+
func TestDatasetsHandlerSearchDatasetsValidationErrorsUseArgumentEnvelope(t *testing.T) {
tests := []struct {
name string
diff --git a/internal/handler/mcp_retrieval.go b/internal/handler/mcp_retrieval.go
index f584a4416f..d885f7d7d8 100644
--- a/internal/handler/mcp_retrieval.go
+++ b/internal/handler/mcp_retrieval.go
@@ -65,10 +65,9 @@ func mcpRetrieval(ctx context.Context, ds *dataset.DatasetService, userID string
}
searchReq := &service.SearchDatasetsRequest{
- DatasetIDs: datasetIDs,
- Question: req.Question,
- DocumentIDs: req.DocumentIDs,
- ForceRefresh: req.ForceRefresh,
+ DatasetIDs: datasetIDs,
+ Question: req.Question,
+ DocumentIDs: req.DocumentIDs,
}
if req.Page > 0 {
@@ -110,8 +109,6 @@ func mcpRetrieval(ctx context.Context, ds *dataset.DatasetService, userID string
}
// Metadata reads use the same authorized service paths as the REST API.
- // No shared cache: force_refresh always sees current metadata, without
- // cross-tenant cache state or a second metadata implementation.
documents := document.NewDocumentService()
datasetNames := make(map[string]string)
documentMetadata := make(map[string]map[string]any)
diff --git a/internal/mcp/http_test.go b/internal/mcp/http_test.go
index 8101447ed3..e1158d2ad6 100644
--- a/internal/mcp/http_test.go
+++ b/internal/mcp/http_test.go
@@ -92,6 +92,17 @@ func TestSDKTransportsAndTools(t *testing.T) {
if string(got) != string(want) {
t.Fatalf("schema mismatch: %s vs %s", got, want)
}
+ if tool.Name == "ragflow_retrieval" {
+ var schema struct {
+ Properties map[string]json.RawMessage `json:"properties"`
+ }
+ if err := json.Unmarshal(got, &schema); err != nil {
+ t.Fatal(err)
+ }
+ if _, ok := schema.Properties["force_refresh"]; ok {
+ t.Fatal("retrieval advertises force_refresh")
+ }
+ }
}
result, err := ss.CallTool(t.Context(), &sdk.CallToolParams{Name: "ragflow_retrieval", Arguments: map[string]any{"question": "hello"}})
if err != nil || result.IsError {
@@ -112,12 +123,15 @@ func TestSDKTransportsAndTools(t *testing.T) {
}
}
}
- for _, args := range []map[string]any{{}, {"question": 3}, {"question": "x", "page": 0}, {"question": "x", "page": 1.5}, {"question": "x", "page_size": 101}, {"question": "x", "top_k": 1025}, {"question": "x", "keyword": "true"}, {"question": "x", "dataset_ids": []any{3}}, {"question": "x", "similarity_threshold": -1}} {
+ for _, args := range []map[string]any{{}, {"question": 3}, {"question": "x", "page": 0}, {"question": "x", "page": 1.5}, {"question": "x", "page_size": 101}, {"question": "x", "top_k": 1025}, {"question": "x", "keyword": "true"}, {"question": "x", "dataset_ids": []any{3}}, {"question": "x", "similarity_threshold": -1}, {"question": "x", "force_refresh": true}, {"question": "x", "force_refresh": false}} {
result, err := ss.CallTool(t.Context(), &sdk.CallToolParams{Name: "ragflow_retrieval", Arguments: args})
if err != nil || !result.IsError {
t.Fatalf("invalid input accepted: %v result=%v err=%v", args, result, err)
}
}
+ if retrieval.Question != "hello" {
+ t.Fatalf("invalid input reached retrieval: %+v", retrieval)
+ }
empty := clientSession(t, hs.URL, mode, "empty")
result, err = empty.CallTool(t.Context(), &sdk.CallToolParams{Name: "ragflow_list_datasets"})
if err != nil || result.IsError || result.Content[0].(*sdk.TextContent).Text != "" {
diff --git a/internal/mcp/server.go b/internal/mcp/server.go
index 085166cff8..2f0fdce761 100644
--- a/internal/mcp/server.go
+++ b/internal/mcp/server.go
@@ -29,7 +29,6 @@ type RetrievalRequest struct {
TopK int `json:"top_k"`
RerankID string `json:"rerank_id,omitempty"`
Keyword bool `json:"keyword"`
- ForceRefresh bool `json:"force_refresh"`
}
// toolsJSON contains the schemas and base descriptions from mcp/server/server.py.
diff --git a/internal/mcp/tools.json b/internal/mcp/tools.json
index 4c8dc0cd1e..c0a3d521ee 100644
--- a/internal/mcp/tools.json
+++ b/internal/mcp/tools.json
@@ -4,6 +4,7 @@
"description": "Retrieve relevant chunks from the RAGFlow retrieve interface based on the question. You can optionally specify dataset_ids to search only specific datasets, or omit dataset_ids entirely to search across ALL available datasets. You can also optionally specify document_ids to search within specific documents. When dataset_ids is not provided or is empty, the system will automatically search across all available datasets. Below is the list of all available datasets, including their descriptions and IDs:",
"inputSchema": {
"type": "object",
+ "additionalProperties": false,
"properties": {
"dataset_ids": {
"type": "array",
@@ -65,11 +66,6 @@
"rerank_id": {
"type": "string",
"description": "Optional reranking model identifier"
- },
- "force_refresh": {
- "type": "boolean",
- "description": "Set to true only if fresh dataset and document metadata is explicitly required. Otherwise, cached metadata is used (default: false).",
- "default": false
}
},
"required": [
diff --git a/internal/service/dataset_types.go b/internal/service/dataset_types.go
index 4b79d7c648..3d5191f9e6 100644
--- a/internal/service/dataset_types.go
+++ b/internal/service/dataset_types.go
@@ -62,7 +62,6 @@ type SearchDatasetsRequest struct {
KeywordsSimilarityWeight *float64 `json:"keywords_similarity_weight,omitempty"`
VectorSimilarityWeight *float64 `json:"vector_similarity_weight,omitempty"`
IncludeCompiledChunks *bool `json:"include_knowledge_compilation,omitempty"`
- ForceRefresh bool `json:"force_refresh"`
KnowledgeCompilationScope string `json:"knowledge_compilation_scope,omitempty"`
}