fix: handle Message objects in build_output by extracting text attribute (#8729)

Update mcp_component.py
This commit is contained in:
Edwin Jose 2025-06-25 12:26:10 -05:00 committed by GitHub
commit d892058759
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,7 @@ from langflow.io import DropdownInput, McpInput, MessageTextInput, Output # Imp
from langflow.io.schema import flatten_schema, schema_to_langflow_inputs
from langflow.logging import logger
from langflow.schema.dataframe import DataFrame
from langflow.schema.message import Message
from langflow.services.auth.utils import create_user_longterm_token
from langflow.services.cache.utils import CacheMiss
@ -405,7 +406,10 @@ class MCPToolsComponent(ComponentWithCache):
for arg in tool_args:
value = getattr(self, arg.name, None)
if value:
kwargs[arg.name] = value
if isinstance(value, Message):
kwargs[arg.name] = value.text
else:
kwargs[arg.name] = value
unflattened_kwargs = maybe_unflatten_dict(kwargs)