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

Closed
opened 2026-02-22 18:31:13 -05:00 by yindo · 2 comments
Owner

Originally created by @lucasandre22 on GitHub (Sep 3, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4360

Originally assigned to: @shatfield4 on GitHub.

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

Originally created by @lucasandre22 on GitHub (Sep 3, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4360 Originally assigned to: @shatfield4 on GitHub. ### 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): <img width="882" height="747" alt="Image" src="https://github.com/user-attachments/assets/06413190-30a5-497a-97e6-db289fbb1910" /> ### 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
yindo added the possible buginvestigating labels 2026-02-22 18:31:13 -05:00
yindo closed this issue 2026-02-22 18:31:13 -05:00
Author
Owner

@timothycarambat commented on GitHub (Sep 8, 2025):

@shatfield4 is this related to #4214 possibly?

@timothycarambat commented on GitHub (Sep 8, 2025): @shatfield4 is this related to #4214 possibly?
Author
Owner

@lucasandre22 commented on GitHub (Sep 8, 2025):

@timothycarambat Not the one you mentioned but yes, it was fixed by #4214.

@lucasandre22 commented on GitHub (Sep 8, 2025): @timothycarambat Not the one you mentioned but yes, it was fixed by #4214.
yindo changed title from [BUG]: MCP Call validation fails if it does not contain optional arguments to [GH-ISSUE #4360] [BUG]: MCP Call validation fails if it does not contain optional arguments 2026-06-05 14:48:30 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#2779