Repository navigation
Replies: 2 comments
|
You are not missing something obvious. The behaviour follows from how Langflow converts an MCP tool result, and the function is worth reading because it explains every one of your parse → structured-output hops.
def _convert_mcp_result(result: Any) -> Any:
...
content = getattr(result, "content", None)
if not content:
return ""
needs_list = any(getattr(block, "type", None) != "text" for block in content)
if not needs_list:
# Text-only: join all text blocks into a single string (backward compat)
return "\n".join(getattr(block, "text", "") for block in content
if getattr(block, "type", None) == "text")Two consequences:
So your chain is the "expected" path: text in, parse out. The design keeps the plain-string return for backward compatibility — the docstring says so — which is why it has not changed. The shortcut you are looking forYou do not need Parse → Structured Output → extract per field. One Structured Output component on the tool's text output does the whole job, if the tool text is valid JSON: Point the schema at the object the tool actually emits: from pydantic import BaseModel
class User(BaseModel):
id: int
name: str
email: strand every field becomes a separate output handle you can wire directly into the next node. The intermediate "Parse" step only earns its place when the text has prose around the JSON (e.g. If you want the JSON without touching a schemaTwo components in
Either one replaces your parse → structured-output chain when you only need a field or two out of the payload. Why this is not going to get better soon
Worth flagging one thing from the same file while you are in there: errors are raised, not returned as data — """A CallToolResult with isError=True is a FAILED call; returning it as data hides the failure."""If a call previously "worked" and now silently yields an empty string, the tool is likely returning |
|
@geiseri — circling back on this since it's the highest-traffic kind of question in the repo. The behaviour you hit isn't a missing feature: If that explains the chain you were fighting, please mark the comment above as the answer — the "am I missing something obvious" framing is exactly what the next reader will search for. If you're still stuck on a specific hop, paste the boundary JSON and I'll say which conversion is dropping it. |
Uh oh!
There was an error while loading. Please reload this page.
I have been pulling my hair out with this. The games I have to play to get the structured output from a MCP tool call are infuriating. Short of writing a custom component I end up with these strange chains of "Parse to get the
textcolumn of the tool response" -> "Structured Output to convert that text back into the original json payload from the mcp" -> ... chain of parse->structured output ... -> "The field I wanted in the first place". My smooth brain must be missing something obvious, since being able to handle json should not be so convoluted. Or is it expected that one should be using custom components for manipulating json?I did see #4326 but the parser kept complaining about "Error running method "filter_data": not all arguments converted during string formatting", #3590 seemed to imply the need of a custom component. Since these are over a year old I am not sure they still count.
All reactions