How to obtain the tool_call_input of the Agent node #16583

Closed
opened 2026-02-21 19:26:45 -05:00 by yindo · 1 comment
Owner

Originally created by @yangyf520 on GitHub (Aug 31, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Parameters of mcp need to be used

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @yangyf520 on GitHub (Aug 31, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. Parameters of mcp need to be used ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [ ] I am interested in contributing to this feature.
yindo added the 🤖 feat:agent label 2026-02-21 19:26:45 -05:00
yindo closed this issue 2026-02-21 19:26:45 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 31, 2025):

To obtain the tool_call_input of the Agent node in Dify, you need to look at how the agent processes tool calls internally. When the LLM returns a tool call, the FunctionCallAgentRunner extracts the tool call arguments from the LLM response, parses them as a dictionary, and serializes them as a JSON string. This JSON object is the tool_call_input and contains the parameters that will be sent to the tool—including any MCP parameters if you're using an MCP tool. The relevant code for this extraction and serialization is in the extract_tool_calls and save_agent_thought methods of the agent runner, and the parameters are passed directly to the tool engine for execution as tool_parameters see code reference.

For MCP tools, parameters must be formatted as a JSON string that matches the tool's schema. If you need to pass arrays or complex objects, convert them to JSON strings before including them in the tool call input see discussion. When the agent invokes the tool, these parameters are validated and used as-is by the tool engine see code reference.

If you're troubleshooting or want to inspect the actual input, you can log or access the tool_call_input field from the agent's thought or from the tool invocation logs. For MCP tools in workflow mode, arguments may be wrapped in an inputs dictionary before being sent see PR.

In summary: extract the tool call arguments from the LLM response, ensure they're properly formatted as JSON (especially for MCP), and these become the tool_call_input used by the Agent node.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 31, 2025): <!-- Answer --> To obtain the `tool_call_input` of the Agent node in Dify, you need to look at how the agent processes tool calls internally. When the LLM returns a tool call, the `FunctionCallAgentRunner` extracts the tool call arguments from the LLM response, parses them as a dictionary, and serializes them as a JSON string. This JSON object is the `tool_call_input` and contains the parameters that will be sent to the tool—including any MCP parameters if you're using an MCP tool. The relevant code for this extraction and serialization is in the `extract_tool_calls` and `save_agent_thought` methods of the agent runner, and the parameters are passed directly to the tool engine for execution as `tool_parameters` [see code reference](https://github.com/langgenius/dify/blob/9f528d23d442c04805d4fef3e2a2326f6b109a5b/api/core/agent/fc_agent_runner.py). For MCP tools, parameters must be formatted as a JSON string that matches the tool's schema. If you need to pass arrays or complex objects, convert them to JSON strings before including them in the tool call input [see discussion](https://github.com/langgenius/dify/issues/20116#issuecomment-2903174341). When the agent invokes the tool, these parameters are validated and used as-is by the tool engine [see code reference](https://github.com/langgenius/dify/blob/9f528d23d442c04805d4fef3e2a2326f6b109a5b/api/core/tools/tool_engine.py). If you're troubleshooting or want to inspect the actual input, you can log or access the `tool_call_input` field from the agent's thought or from the tool invocation logs. For MCP tools in workflow mode, arguments may be wrapped in an `inputs` dictionary before being sent [see PR](https://github.com/langgenius/dify/pull/22505). In summary: extract the tool call arguments from the LLM response, ensure they're properly formatted as JSON (especially for MCP), and these become the `tool_call_input` used by the Agent node. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0d83b32c-c1a7-47a0-a7a5-238060bd6f0f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0d83b32c-c1a7-47a0-a7a5-238060bd6f0f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0d83b32c-c1a7-47a0-a7a5-238060bd6f0f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0d83b32c-c1a7-47a0-a7a5-238060bd6f0f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0d83b32c-c1a7-47a0-a7a5-238060bd6f0f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0d83b32c-c1a7-47a0-a7a5-238060bd6f0f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0d83b32c-c1a7-47a0-a7a5-238060bd6f0f?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/24847)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16583