lfx-nightly 0.1.12.dev19__py3-none-any.whl → 0.1.12.dev21__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lfx-nightly might be problematic. Click here for more details.
- lfx/components/agents/mcp_component.py +67 -30
- {lfx_nightly-0.1.12.dev19.dist-info → lfx_nightly-0.1.12.dev21.dist-info}/METADATA +1 -1
- {lfx_nightly-0.1.12.dev19.dist-info → lfx_nightly-0.1.12.dev21.dist-info}/RECORD +5 -5
- {lfx_nightly-0.1.12.dev19.dist-info → lfx_nightly-0.1.12.dev21.dist-info}/WHEEL +0 -0
- {lfx_nightly-0.1.12.dev19.dist-info → lfx_nightly-0.1.12.dev21.dist-info}/entry_points.txt +0 -0
|
@@ -10,7 +10,7 @@ from lfx.base.agents.utils import maybe_unflatten_dict, safe_cache_get, safe_cac
|
|
|
10
10
|
from lfx.base.mcp.util import MCPSseClient, MCPStdioClient, create_input_schema_from_json_schema, update_tools
|
|
11
11
|
from lfx.custom.custom_component.component_with_cache import ComponentWithCache
|
|
12
12
|
from lfx.inputs.inputs import InputTypes # noqa: TC001
|
|
13
|
-
from lfx.io import DropdownInput, McpInput, MessageTextInput, Output
|
|
13
|
+
from lfx.io import BoolInput, DropdownInput, McpInput, MessageTextInput, Output
|
|
14
14
|
from lfx.io.schema import flatten_schema, schema_to_langflow_inputs
|
|
15
15
|
from lfx.log.logger import logger
|
|
16
16
|
from lfx.schema.dataframe import DataFrame
|
|
@@ -53,6 +53,7 @@ class MCPToolsComponent(ComponentWithCache):
|
|
|
53
53
|
"tool_placeholder",
|
|
54
54
|
"mcp_server",
|
|
55
55
|
"tool",
|
|
56
|
+
"use_cache",
|
|
56
57
|
]
|
|
57
58
|
|
|
58
59
|
display_name = "MCP Tools"
|
|
@@ -68,6 +69,16 @@ class MCPToolsComponent(ComponentWithCache):
|
|
|
68
69
|
info="Select the MCP Server that will be used by this component",
|
|
69
70
|
real_time_refresh=True,
|
|
70
71
|
),
|
|
72
|
+
BoolInput(
|
|
73
|
+
name="use_cache",
|
|
74
|
+
display_name="Use Cached Server",
|
|
75
|
+
info=(
|
|
76
|
+
"Enable caching of MCP Server and tools to improve performance. "
|
|
77
|
+
"Disable to always fetch fresh tools and server updates."
|
|
78
|
+
),
|
|
79
|
+
value=False,
|
|
80
|
+
advanced=True,
|
|
81
|
+
),
|
|
71
82
|
DropdownInput(
|
|
72
83
|
name="tool",
|
|
73
84
|
display_name="Tool",
|
|
@@ -132,16 +143,32 @@ class MCPToolsComponent(ComponentWithCache):
|
|
|
132
143
|
self.tools = []
|
|
133
144
|
return [], {"name": server_name, "config": server_config_from_value}
|
|
134
145
|
|
|
135
|
-
#
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
# Check if caching is enabled, default to False
|
|
147
|
+
use_cache = getattr(self, "use_cache", False)
|
|
148
|
+
|
|
149
|
+
# Use shared cache if available and caching is enabled
|
|
150
|
+
cached = None
|
|
151
|
+
if use_cache:
|
|
152
|
+
servers_cache = safe_cache_get(self._shared_component_cache, "servers", {})
|
|
153
|
+
cached = servers_cache.get(server_name) if isinstance(servers_cache, dict) else None
|
|
138
154
|
|
|
139
155
|
if cached is not None:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
156
|
+
try:
|
|
157
|
+
self.tools = cached["tools"]
|
|
158
|
+
self.tool_names = cached["tool_names"]
|
|
159
|
+
self._tool_cache = cached["tool_cache"]
|
|
160
|
+
server_config_from_value = cached["config"]
|
|
161
|
+
except (TypeError, KeyError, AttributeError) as e:
|
|
162
|
+
# Handle corrupted cache data by clearing it and continuing to fetch fresh tools
|
|
163
|
+
msg = f"Unable to use cached data for MCP Server{server_name}: {e}"
|
|
164
|
+
await logger.awarning(msg)
|
|
165
|
+
# Clear the corrupted cache entry
|
|
166
|
+
current_servers_cache = safe_cache_get(self._shared_component_cache, "servers", {})
|
|
167
|
+
if isinstance(current_servers_cache, dict) and server_name in current_servers_cache:
|
|
168
|
+
current_servers_cache.pop(server_name)
|
|
169
|
+
safe_cache_set(self._shared_component_cache, "servers", current_servers_cache)
|
|
170
|
+
else:
|
|
171
|
+
return self.tools, {"name": server_name, "config": server_config_from_value}
|
|
145
172
|
|
|
146
173
|
try:
|
|
147
174
|
try:
|
|
@@ -186,19 +213,21 @@ class MCPToolsComponent(ComponentWithCache):
|
|
|
186
213
|
self.tool_names = [tool.name for tool in tool_list if hasattr(tool, "name")]
|
|
187
214
|
self._tool_cache = tool_cache
|
|
188
215
|
self.tools = tool_list
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
current_servers_cache
|
|
201
|
-
|
|
216
|
+
|
|
217
|
+
# Cache the result only if caching is enabled
|
|
218
|
+
if use_cache:
|
|
219
|
+
cache_data = {
|
|
220
|
+
"tools": tool_list,
|
|
221
|
+
"tool_names": self.tool_names,
|
|
222
|
+
"tool_cache": tool_cache,
|
|
223
|
+
"config": server_config,
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
# Safely update the servers cache
|
|
227
|
+
current_servers_cache = safe_cache_get(self._shared_component_cache, "servers", {})
|
|
228
|
+
if isinstance(current_servers_cache, dict):
|
|
229
|
+
current_servers_cache[server_name] = cache_data
|
|
230
|
+
safe_cache_set(self._shared_component_cache, "servers", current_servers_cache)
|
|
202
231
|
|
|
203
232
|
except (TimeoutError, asyncio.TimeoutError) as e:
|
|
204
233
|
msg = f"Timeout updating tool list: {e!s}"
|
|
@@ -294,14 +323,22 @@ class MCPToolsComponent(ComponentWithCache):
|
|
|
294
323
|
# Check if tools are already cached for this server before clearing
|
|
295
324
|
cached_tools = None
|
|
296
325
|
if current_server_name:
|
|
297
|
-
|
|
298
|
-
if
|
|
299
|
-
|
|
300
|
-
if
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
326
|
+
use_cache = getattr(self, "use_cache", True)
|
|
327
|
+
if use_cache:
|
|
328
|
+
servers_cache = safe_cache_get(self._shared_component_cache, "servers", {})
|
|
329
|
+
if isinstance(servers_cache, dict):
|
|
330
|
+
cached = servers_cache.get(current_server_name)
|
|
331
|
+
if cached is not None:
|
|
332
|
+
try:
|
|
333
|
+
cached_tools = cached["tools"]
|
|
334
|
+
self.tools = cached_tools
|
|
335
|
+
self.tool_names = cached["tool_names"]
|
|
336
|
+
self._tool_cache = cached["tool_cache"]
|
|
337
|
+
except (TypeError, KeyError, AttributeError) as e:
|
|
338
|
+
# Handle corrupted cache data by ignoring it
|
|
339
|
+
msg = f"Unable to use cached data for MCP Server,{current_server_name}: {e}"
|
|
340
|
+
await logger.awarning(msg)
|
|
341
|
+
cached_tools = None
|
|
305
342
|
|
|
306
343
|
# Only clear tools if we don't have cached tools for the current server
|
|
307
344
|
if not cached_tools:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lfx-nightly
|
|
3
|
-
Version: 0.1.12.
|
|
3
|
+
Version: 0.1.12.dev21
|
|
4
4
|
Summary: Langflow Executor - A lightweight CLI tool for executing and serving Langflow AI flows
|
|
5
5
|
Author-email: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
|
|
6
6
|
Requires-Python: <3.14,>=3.10
|
|
@@ -111,7 +111,7 @@ lfx/components/agentql/__init__.py,sha256=Erl669Dzsk-SegsDPWTtkKbprMXVuv8UTCo5RE
|
|
|
111
111
|
lfx/components/agentql/agentql_api.py,sha256=N94yEK7ZuQCIsFBlr_8dqrJY-K1-KNb6QEEYfDIsDME,5569
|
|
112
112
|
lfx/components/agents/__init__.py,sha256=u1PH9Ui0dUgTdTZVP7cdVysCv4extdusKS_brcbE7Eg,1049
|
|
113
113
|
lfx/components/agents/agent.py,sha256=1hsfPWkqCzRF4SKT7l9R1yaMor1J2MarXG1ISwDNVL0,26678
|
|
114
|
-
lfx/components/agents/mcp_component.py,sha256=
|
|
114
|
+
lfx/components/agents/mcp_component.py,sha256=dW0eENDKz8esIShOooDEL48r3J3GoI1h0tuqIPLSnR4,25462
|
|
115
115
|
lfx/components/aiml/__init__.py,sha256=DNKB-HMFGFYmsdkON-s8557ttgBXVXADmS-BcuSQiIQ,1087
|
|
116
116
|
lfx/components/aiml/aiml.py,sha256=23Ineg1ajlCoqXgWgp50I20OnQbaleRNsw1c6IzPu3A,3877
|
|
117
117
|
lfx/components/aiml/aiml_embeddings.py,sha256=2uNwORuj55mxn2SfLbh7oAIfjuXwHbsnOqRjfMtQRqc,1095
|
|
@@ -718,7 +718,7 @@ lfx/utils/schemas.py,sha256=NbOtVQBrn4d0BAu-0H_eCTZI2CXkKZlRY37XCSmuJwc,3865
|
|
|
718
718
|
lfx/utils/util.py,sha256=xGR32XDRr_TtruhjnXfI7lEWmk-vgywHAy3kz5SBowc,15725
|
|
719
719
|
lfx/utils/util_strings.py,sha256=nU_IcdphNaj6bAPbjeL-c1cInQPfTBit8mp5Y57lwQk,1686
|
|
720
720
|
lfx/utils/version.py,sha256=cHpbO0OJD2JQAvVaTH_6ibYeFbHJV0QDHs_YXXZ-bT8,671
|
|
721
|
-
lfx_nightly-0.1.12.
|
|
722
|
-
lfx_nightly-0.1.12.
|
|
723
|
-
lfx_nightly-0.1.12.
|
|
724
|
-
lfx_nightly-0.1.12.
|
|
721
|
+
lfx_nightly-0.1.12.dev21.dist-info/METADATA,sha256=FFH6xxBJeaIDtfggQ37m3IODz1Z15oVzPy5JHMrBjyA,8068
|
|
722
|
+
lfx_nightly-0.1.12.dev21.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
723
|
+
lfx_nightly-0.1.12.dev21.dist-info/entry_points.txt,sha256=1724p3RHDQRT2CKx_QRzEIa7sFuSVO0Ux70YfXfoMT4,42
|
|
724
|
+
lfx_nightly-0.1.12.dev21.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|