Skip to content

[JS] Tool calls to tools registered by the MCP plugin don't always work. #2628

Open
@gspencergoog

Description

@gspencergoog

Describe the bug
Tool calls to tools registered by the MCP plugin don't always work.

Sometimes when calling a tool using Gemini 2.0-Flash, I get output similar to:

{
  "response": "```tool_code\nprint(default_api.search_nodes(query='Greg'))\n```"
}

Rather than an actual tool call. Sometimes it does actually call the tool correctly, though.

I think this is because Gemini is sometimes wrapping the tool call with the code markdown markers and/or just forgetting that the tool is registered.

I'm referring to the tool by its registered name in both the prompt header and the body of the prompt.

To Reproduce

Use this query:

{
  "prompt": "Hi, my name is Greg. Am I in your memory?"
}

on the mcpFlow for the genkit project in this .tar.gz file: genkit_issue.tar.gz

Expected behavior
I would expect the tool to be called and the result to be structured output from the tool.

The correct response would be something like "Yes, you are in my memory: you like Genkit".

Runtime (please complete the following information):

  • OS: Linux
  • Version 6.12.12-1rodete2-amd64

** Node version

  • v20.18.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjs

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions