Issue:MCP Tool Call Error

by ADMIN 26 views

Introduction

In this article, we will discuss an issue with the MCP (Machine-Generated Content) tool call error in Open WebUI. The issue is related to the native mode of the MCP server service, where the arguments parameter is not parsed correctly during the streaming output parsing. We will explore the problem, provide a temporary solution, and discuss the possible causes of the issue.

Check Existing Issues

Before we dive into the issue, let's check if there are any existing issues related to this problem.

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

Installation Method

The installation method used is Git Clone.

Open WebUI Version

The Open WebUI version used is 0.6.5.

Ollama Version (if applicable)

No response.

Operating System

The operating system used is 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 Open WebUI, and the tool call cannot be performed normally without using the native mode. However, when I use the native mode, I found that the arguments parameter is not parsed correctly during the streaming output parsing.

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, but this is indeed a relatively serious problem, which directly led to the MCP not being usable.

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

Possible Causes

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. However, this is indeed a relatively serious problem, which directly led to the MCP not being usable.

Temporary Solution

The temporary solution I made is to 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

And also, 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."
            #     )

Cherry Studio's MCP Service

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

Logs & Screenshots

Image

Additional Information

No response.

Conclusion

Q: What is the MCP tool call error?

A: The MCP tool call error is an issue with the Machine-Generated Content (MCP) tool call in Open WebUI. The issue is related to the native mode of the MCP server service, where the arguments parameter is not parsed correctly during the streaming output parsing.

Q: What are the possible causes of the MCP tool call error?

A: The possible causes of the MCP tool call error are:

  • The system prompt causing the current_response_tool_call not to include the arguments key-value pair.
  • The VLLM framework causing the issue.

Q: What is the temporary solution for the MCP tool call error?

A: The temporary solution for the MCP tool call error is to 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

And also, 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."
            #     )

Q: How can I prevent the MCP tool call error?

A: To prevent the MCP tool call error, you can:

  • Make sure that the current_response_tool_call includes the arguments key-value pair.
  • Use the VLLM framework correctly.

Q: What is the difference between the MCP tool call error and the VLLM framework?

A: The MCP tool call error is an issue with the Machine-Generated Content (MCP) tool call in Open WebUI, while the VLLM framework is a machine learning framework used in Open WebUI.

Q: Can I use the MCP tool call error solution in other projects?

A: Yes, you can use the MCP tool call error solution in other projects. However, you need to make sure that the solution is compatible with your project's requirements.

Q: How can I report the MCP tool call error?

A: You can report the MCP tool call error by creating an issue on the Open WebUI GitHub page.

Q: What is the current status of the MCP tool call error solution?

A: The current status of the MCP tool call error solution is that it is a temporary solution. A permanent solution is being worked on.

Q: Can I get help with the MCP tool call error solution?

A: Yes, you can get help with the MCP tool call error solution by asking on the Open WebUI GitHub page or by contacting the Open WebUI team.

Q: What are the future plans for the MCP tool call error solution?

A: The future plans for the MCP tool call error solution are to:

  • Make a permanent solution for the MCP tool call error.
  • Improve the VLLM framework to prevent the MCP tool call error.

Q: Can I contribute to the MCP tool call error solution?

A: Yes, you can contribute to the MCP tool call error solution by:

  • Reporting bugs and issues.
  • Providing solutions and fixes.
  • Helping with the development of the permanent solution.