这是indexloc提供的服务,不要输入任何密码
Skip to content

[BUG]: MCP Call validation fails if it does not contain optional arguments #4360

@lucasandre22

Description

@lucasandre22

How are you running AnythingLLM?

Local development

What happened?

When configuring a MCP Server in AnythingLLM, we may have multiple parameters, which many of them can be optional.
However, the current MCP call validation inside the code at untooled.js expects the call to MCP to have all the MCP parameters the tool provides, which is not correct since a part of them can be optional.
Here is the piece of code:

validFuncCall(functionCall` = {}, functions = []) {
    if (
      !functionCall ||
      !functionCall?.hasOwnProperty("name") ||
      !functionCall?.hasOwnProperty("arguments")
    ) {
      return {
        valid: false,
        reason: "Missing name or arguments in function call.",
      };
    }

    const foundFunc = functions.find((def) => def.name === functionCall.name);
    if (!foundFunc) {
      return { valid: false, reason: "Function name does not exist." };
    }

    //This validation does not make sense since some parameters are optional!!
    // const props = Object.keys(foundFunc.parameters.properties);
    // const fProps = Object.keys(functionCall.arguments);
    // if (!this.compareArrays(props, fProps)) {
    //   return { valid: false, reason: "Invalid argument schema match." };
    // }

    return { valid: true, reason: null };
  }

My suggestion is to take in consideration the required fields and only check if the required parameters are there.
We already have this information in UI (the required parameters are marked with red asterisc):

Image

Are there known steps to reproduce?

Configure kiwi.com MCP server:

{
  "mcpServers": {
    "kiwi": {
        "url": "https://mcp.kiwi.com",
        "type": "streamable",
        "anythingllm": {
            "autoStart": true,
            "setupOnStart": true
        }
    }
  }
}

and try to call it in chat with:
@agent I want to search for flights from sao paulo to tokyo for 15/09/2025 to 20/09/2025

Metadata

Metadata

Assignees

Labels

investigatingCore team or maintainer will or is currently looking into this issuepossible bugBug was reported but is not confirmed or is unable to be replicated.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions