[GH-ISSUE #13125] issue:MCP tool call error #16817

Closed
opened 2026-04-19 22:38:38 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @chelseaztq on GitHub (Apr 22, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/13125

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Git Clone

Open WebUI Version

0.6.5

Ollama Version (if applicable)

No response

Operating System

Ubuntu 22.04

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

I am using the MCP server service of openwebui,the tool call cannot be performed normally without using the native mode,But when I use the native mode, I found that the arguments parameter is not parsed correctly during the streaming output parsing.
[](852d9dcbe9/backend/open_webui/utils/middleware.py (L1689))
The specific reason is that the "current_response_tool_call" does not have the "arguments" key value, I'm not sure if it's a problem with the vllm inference framework I'm using, in any case, there are no "arguments" here, and the version of the vllm inference framework I'm using is 0.8.4.
So, this led to the situation where delta_arguments was not correctly added to the arguments when assigning here.
This also indirectly leads to errors when calling specific tools later.
852d9dcbe9/backend/open_webui/utils/tools.py (L563)
Because here parms is actually an empty {}, it evaluates to false, and the code will directly jump to raise Exception

Actual Behavior

Refer to the above

Steps to Reproduce

So I made some repairs, but I feel it's not a fundamental solution to the problem.
Firstly, check if there are arguments in the dict. If not, create this key and assign the default value ""

if delta_arguments:
      # current_response_tool_call[
      #     "function"
      # ][
      #     "arguments"
      # ] += delta_arguments
     current_response_tool_call["function"]["arguments"] = current_response_tool_call["function"].get("arguments", "") + delta_arguments

Secondly, because my mcp tool may not pass any parameters to the arguments here, the parsing may result in an empty {}, but when the if parms is performing a boolean value judgment, it is false.
So I also made the following corrections

if operation.get("requestBody", {}).get("content"):
            # if params:
     body_params = params
            # else:
            #     raise Exception(
            #         f"Request body expected for operation '{name}' but none found."
            #     )

Finally, my MCP tool was successfully called

Image

But regarding the modification of the second step, this is just a temporary solution. If you think my fix is okay, I will submit a PR later

I am not sure whether it is because my system prompt caused the current_response_tool_call not to include the arguments key-value pair, or it is caused by the vllm framework, but this is indeed a relatively serious problem, which directly led to the mcp not being usable.

And I also referred to the template of cherry studio's tool call, and I found that they wrote it very detailed, as follows

prompt: '<|im_start|>system\nIn this environment you have access to a set of tools you can use to answer the user\'s question. You can use one tool per message, and will receive the result of that tool use in the user\'s response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.\n\n## Tool Use Formatting\n\nTool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here\'s the structure:\n\n<tool_use>\n  <name>{tool_name}</name>\n  <arguments>{json_arguments}</arguments>\n</tool_use>\n\nThe tool name should be the exact name of the tool you are using, and the arguments should be a JSON object containing the parameters required by that tool. For example:\n<tool_use>\n  <name>python_interpreter</name>\n  <arguments>{"code": "5 + 3 + 1294.678"}</arguments>\n</tool_use>\n\nThe user will respond with the result of the tool use, which should be formatted as follows:\n\n<tool_use_result>\n  <name>{tool_name}</name>\n  <result>{result}</result>\n</tool_use_result>\n\nThe result should be a string, which can represent a file or any other output type. You can use this result as input for the next action.\nFor example, if the result of the tool use is an image file, you can use it in the next action like this:\n\n<tool_use>\n  <name>image_transformer</name>\n  <arguments>{"image": "image_1.jpg"}</arguments>\n</tool_use>\n\nAlways adhere to this format for the tool use to ensure proper parsing and execution.\n\n## Tool Use Examples\n\nHere are a few examples using notional tools:\n---\nUser: Generate an image of the oldest person in this document.\n\nAssistant: I can use the document_qa tool to find out who the oldest person is in the document.\n<tool_use>\n  <name>document_qa</name>\n  <arguments>{"document": "document.pdf", "question": "Who is the oldest person mentioned?"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n  <name>document_qa</name>\n  <result>John Doe, a 55 year old lumberjack living in Newfoundland.</result>\n</tool_use_result>\n\nAssistant: I can use the image_generator tool to create a portrait of John Doe.\n<tool_use>\n  <name>image_generator</name>\n  <arguments>{"prompt": "A portrait of John Doe, a 55-year-old man living in Canada."}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n  <name>image_generator</name>\n  <result>image.png</result>\n</tool_use_result>\n\nAssistant: the image is generated as image.png\n\n---\nUser: "What is the result of the following operation: 5 + 3 + 1294.678?"\n\nAssistant: I can use the python_interpreter tool to calculate the result of the operation.\n<tool_use>\n  <name>python_interpreter</name>\n  <arguments>{"code": "5 + 3 + 1294.678"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n  <name>python_interpreter</name>\n  <result>1302.678</result>\n</tool_use_result>\n\nAssistant: The result of the operation is 1302.678.\n\n---\nUser: "Which city has the highest population , Guangzhou or Shanghai?"\n\nAssistant: I can use the search tool to find the population of Guangzhou.\n<tool_use>\n  <name>search</name>\n  <arguments>{"query": "Population Guangzhou"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n  <name>search</name>\n  <result>Guangzhou has a population of 15 million inhabitants as of 2021.</result>\n</tool_use_result>\n\nAssistant: I can use the search tool to find the population of Shanghai.\n<tool_use>\n  <name>search</name>\n  <arguments>{"query": "Population Shanghai"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n  <name>search</name>\n  <result>26 million (2019)</result>\n</tool_use_result>\nAssistant: The population of Shanghai is 26 million, while Guangzhou has a population of 15 million. Therefore, Shanghai has the highest population.\n\n\n## Tool Use Available Tools\nAbove example were using notional tools that might not exist for you. You only have access to these tools:\n<tools>\n\n<tool>\n       </arguments>\n</tool>\n\n</tools>\n\n## Tool Use Rules\nHere are the rules you should always follow to solve your task:\n1. Always use the right arguments for the tools. Never use variable names as the action arguments, use the value instead.\n2. Call a tool only when needed: do not call the search agent if you do not need information, try to solve the task yourself.\n3. If no tool call is needed, just answer the question directly.\n4. Never re-do a tool call that you previously did with the exact same parameters.\n5. For tool use, MARK SURE use XML tag format as shown in the examples above. Do not use any other format.\n\n# User Instructions\n    \n\nNow Begin! If you solve the task correctly, you will receive a reward of $1,000,000.\n<|im_end|>\n<|im_start|>user\n<|im_end|>\n<|im_start|>assistant\n

Cherry Studio's MCP service is very stable, I'm not sure if they have adopted the native mode, you can refer to it

Logs & Screenshots

Image

Additional Information

No response

Originally created by @chelseaztq on GitHub (Apr 22, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/13125 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Git Clone ### Open WebUI Version 0.6.5 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 22.04 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior I am using the MCP server service of openwebui,the tool call cannot be performed normally without using the native mode,But when I use the native mode, I found that the arguments parameter is not parsed correctly during the streaming output parsing. [[](url)](https://github.com/open-webui/open-webui/blob/852d9dcbe9b4406e1da230a14642f35ac7bb0d2b/backend/open_webui/utils/middleware.py#L1689) The specific reason is that the "current_response_tool_call" does not have the "arguments" key value, I'm not sure if it's a problem with the vllm inference framework I'm using, in any case, there are no "arguments" here, and the version of the vllm inference framework I'm using is 0.8.4. So, this led to the situation where delta_arguments was not correctly added to the arguments when assigning here. This also indirectly leads to errors when calling specific tools later. https://github.com/open-webui/open-webui/blob/852d9dcbe9b4406e1da230a14642f35ac7bb0d2b/backend/open_webui/utils/tools.py#L563 Because here parms is actually an empty {}, it evaluates to false, and the code will directly jump to raise Exception ### Actual Behavior Refer to the above ### Steps to Reproduce So I made some repairs, but I feel it's not a fundamental solution to the problem. Firstly, check if there are arguments in the dict. If not, create this key and assign the default value "" ```python if delta_arguments: # current_response_tool_call[ # "function" # ][ # "arguments" # ] += delta_arguments current_response_tool_call["function"]["arguments"] = current_response_tool_call["function"].get("arguments", "") + delta_arguments ``` Secondly, because my mcp tool may not pass any parameters to the arguments here, the parsing may result in an empty {}, but when the if parms is performing a boolean value judgment, it is false. So I also made the following corrections ```python if operation.get("requestBody", {}).get("content"): # if params: body_params = params # else: # raise Exception( # f"Request body expected for operation '{name}' but none found." # ) ``` Finally, my MCP tool was successfully called ![Image](https://github.com/user-attachments/assets/76e3001a-f3e1-48b2-bd0d-6c0157d409d5) But regarding the modification of the second step, this is just a temporary solution. If you think my fix is okay, I will submit a PR later I am not sure whether it is because my system prompt caused the current_response_tool_call not to include the arguments key-value pair, or it is caused by the vllm framework, but this is indeed a relatively serious problem, which directly led to the mcp not being usable. And I also referred to the template of cherry studio's tool call, and I found that they wrote it very detailed, as follows ```python prompt: '<|im_start|>system\nIn this environment you have access to a set of tools you can use to answer the user\'s question. You can use one tool per message, and will receive the result of that tool use in the user\'s response. You use tools step-by-step to accomplish a given task, with each tool use informed by the result of the previous tool use.\n\n## Tool Use Formatting\n\nTool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here\'s the structure:\n\n<tool_use>\n <name>{tool_name}</name>\n <arguments>{json_arguments}</arguments>\n</tool_use>\n\nThe tool name should be the exact name of the tool you are using, and the arguments should be a JSON object containing the parameters required by that tool. For example:\n<tool_use>\n <name>python_interpreter</name>\n <arguments>{"code": "5 + 3 + 1294.678"}</arguments>\n</tool_use>\n\nThe user will respond with the result of the tool use, which should be formatted as follows:\n\n<tool_use_result>\n <name>{tool_name}</name>\n <result>{result}</result>\n</tool_use_result>\n\nThe result should be a string, which can represent a file or any other output type. You can use this result as input for the next action.\nFor example, if the result of the tool use is an image file, you can use it in the next action like this:\n\n<tool_use>\n <name>image_transformer</name>\n <arguments>{"image": "image_1.jpg"}</arguments>\n</tool_use>\n\nAlways adhere to this format for the tool use to ensure proper parsing and execution.\n\n## Tool Use Examples\n\nHere are a few examples using notional tools:\n---\nUser: Generate an image of the oldest person in this document.\n\nAssistant: I can use the document_qa tool to find out who the oldest person is in the document.\n<tool_use>\n <name>document_qa</name>\n <arguments>{"document": "document.pdf", "question": "Who is the oldest person mentioned?"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>document_qa</name>\n <result>John Doe, a 55 year old lumberjack living in Newfoundland.</result>\n</tool_use_result>\n\nAssistant: I can use the image_generator tool to create a portrait of John Doe.\n<tool_use>\n <name>image_generator</name>\n <arguments>{"prompt": "A portrait of John Doe, a 55-year-old man living in Canada."}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>image_generator</name>\n <result>image.png</result>\n</tool_use_result>\n\nAssistant: the image is generated as image.png\n\n---\nUser: "What is the result of the following operation: 5 + 3 + 1294.678?"\n\nAssistant: I can use the python_interpreter tool to calculate the result of the operation.\n<tool_use>\n <name>python_interpreter</name>\n <arguments>{"code": "5 + 3 + 1294.678"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>python_interpreter</name>\n <result>1302.678</result>\n</tool_use_result>\n\nAssistant: The result of the operation is 1302.678.\n\n---\nUser: "Which city has the highest population , Guangzhou or Shanghai?"\n\nAssistant: I can use the search tool to find the population of Guangzhou.\n<tool_use>\n <name>search</name>\n <arguments>{"query": "Population Guangzhou"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>search</name>\n <result>Guangzhou has a population of 15 million inhabitants as of 2021.</result>\n</tool_use_result>\n\nAssistant: I can use the search tool to find the population of Shanghai.\n<tool_use>\n <name>search</name>\n <arguments>{"query": "Population Shanghai"}</arguments>\n</tool_use>\n\nUser: <tool_use_result>\n <name>search</name>\n <result>26 million (2019)</result>\n</tool_use_result>\nAssistant: The population of Shanghai is 26 million, while Guangzhou has a population of 15 million. Therefore, Shanghai has the highest population.\n\n\n## Tool Use Available Tools\nAbove example were using notional tools that might not exist for you. You only have access to these tools:\n<tools>\n\n<tool>\n </arguments>\n</tool>\n\n</tools>\n\n## Tool Use Rules\nHere are the rules you should always follow to solve your task:\n1. Always use the right arguments for the tools. Never use variable names as the action arguments, use the value instead.\n2. Call a tool only when needed: do not call the search agent if you do not need information, try to solve the task yourself.\n3. If no tool call is needed, just answer the question directly.\n4. Never re-do a tool call that you previously did with the exact same parameters.\n5. For tool use, MARK SURE use XML tag format as shown in the examples above. Do not use any other format.\n\n# User Instructions\n \n\nNow Begin! If you solve the task correctly, you will receive a reward of $1,000,000.\n<|im_end|>\n<|im_start|>user\n<|im_end|>\n<|im_start|>assistant\n ``` Cherry Studio's MCP service is very stable, I'm not sure if they have adopted the native mode, you can refer to it ### Logs & Screenshots ![Image](https://github.com/user-attachments/assets/cc97ef49-ec75-4686-8ee9-bf239adcb538) ### Additional Information _No response_
GiteaMirror added the bug label 2026-04-19 22:38:38 -05:00
Author
Owner

@rgaricano commented on GitHub (Apr 22, 2025):

are you using dev branch of mcpo?
(on dev branch there are some commits that fix schema errors, https://github.com/open-webui/mcpo/tree/dev )

<!-- gh-comment-id:2821757440 --> @rgaricano commented on GitHub (Apr 22, 2025): are you using dev branch of mcpo? (on dev branch there are some commits that fix schema errors, https://github.com/open-webui/mcpo/tree/dev )
Author
Owner

@Kun-Zhang-x commented on GitHub (May 9, 2025):

这个问题我也遇到了,奇怪的是我如果使用阿里百炼上的Qwen3模型就是正常的,但是使用本地vllm0.8.5部署的Qwen3模型就会出现这个问题

<!-- gh-comment-id:2866191394 --> @Kun-Zhang-x commented on GitHub (May 9, 2025): 这个问题我也遇到了,奇怪的是我如果使用阿里百炼上的Qwen3模型就是正常的,但是使用本地vllm0.8.5部署的Qwen3模型就会出现这个问题
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#16817