How to set return_direct=True for tools in MCP Tool component so the agent returns the tool output directly? #9351
Unanswered
FullClipJumpJet
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,I'm using the MCP Tool component in Langflow to expose several tools to an agent. My goal is for the final response to the user to be exactly the tool's output, without any additional processing, wrapping, or rewriting by the agent.I understand that in LangChain tools, setting return_direct=True achieves this behavior: the output of the tool is returned directly to the user, and the agent does not modify or format it in any way.However, I cannot find a way to set return_direct=True for the tools created by the MCP Tool component in Langflow. When I inspect the component output, return_direct is always false, and the agent always writes its own message based on the tool's result (instead of passing it through directly).How can I make sure that the tool's output is returned directly to the user, with no agent post-processing or rewriting, when using the MCP Tool component? Is there a way to set return_direct=True for these tools, either in the UI or in code?Thank you for your help!
Additional Context: Custom MCP Tool Registration
For reference, here is a simplified version of the code used to register tools for the MCP Tools component on the server side:
python
@server.list_tools()
async def handle_list_tools() -> list[types.Tool]:
return [
types.Tool(
name="fetchHTML",
description="returns HTML.",
inputSchema={
"type": "object",
"properties": {
"url": {"description": "URL base da API"},
"authorization": {"description": "Cabeçalho Authorization"},
"content_type": {"description": "Content-Type (ex: application/json)"},
"additional_headers": {"description": "Cabeçalhos HTTP adicionais"},
"filters": {"description": "Filtro estilo ODATA ex: CAMPO eq 'valor'"},
"orderby": {"description": "Campo para ordenação, ex: YEQPEVID desc"},
"count": {"description": "Limite de resultados a retornar, ex: 5", "type": "integer"}
},
"required": ["url"]
},
return_direct=True,
),
]
As you can see, the tool FetchHTML has return_direct=True set in it's definition. However, even with this setting, the Langflow UI still shows return_direct: false for it , and the agent continues to post-process the tool output instead of returning it directly to the user.
Beta Was this translation helpful? Give feedback.
All reactions