Skip to content

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

Fix: align MCP tool call timeout and handle empty content (#13899)

eviaaaaa1e83c8c05172
diff --git a/common/mcp_tool_call_conn.py b/common/mcp_tool_call_conn.py
index 9033c79c4a..95e3581bb0 100644
--- a/common/mcp_tool_call_conn.py
+++ b/common/mcp_tool_call_conn.py
@@ -182,6 +182,8 @@ class MCPToolCallSession(ToolCallSession):
return f"MCP server error: {result.content}"
# For now, we only support text content
+ if not result.content:
+ return "MCP server returned empty content."
if isinstance(result.content[0], TextContent):
return result.content[0].text
else:
@@ -214,7 +216,10 @@ class MCPToolCallSession(ToolCallSession):
if self._close:
return "Error: Session is closed"
- future = asyncio.run_coroutine_threadsafe(self._call_mcp_tool(name, arguments), self._event_loop)
+ future = asyncio.run_coroutine_threadsafe(
+ self._call_mcp_tool(name, arguments, request_timeout=timeout),
+ self._event_loop,
+ )
try:
return future.result(timeout=timeout)
except FuturesTimeoutError: