-
Notifications
You must be signed in to change notification settings - Fork 33
[BUG] Tools parameters/arguements are not working #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Code: import { MultiServerMCPClient } from "@langchain/mcp-adapters";
import { ChatOpenAI } from "@langchain/openai";
import dotenv from "dotenv";
import util from "util";
dotenv.config();
(async () => {
// Initialize the MCP client with server configuration for firecrawl.
const client = new MultiServerMCPClient({
// Global tool configuration options.
throwOnLoadError: true,
prefixToolNameWithServerName: true,
additionalToolNamePrefix: "mcp",
// MCP server configuration.
mcpServers: {
// Use a STDIO connection for the firecrawl server.
firecrawl: {
transport: "stdio",
command: "npx",
args: ["-y", "firecrawl-mcp"],
env: {
FIRECRAWL_API_KEY: process.env.FIRECRAWL_API_KEY!,
},
// You can add additional options like timeout or restart configurations if needed.
},
},
});
try {
// Load the tools from the Firecrawl MCP server.
const tools = await client.getTools();
// console.log("Loaded tools:", tools);
console.log(util.inspect(tools[0], { showHidden: true, depth: null, colors: true }));
// const result = await tools[0].invoke({ url: "https://github.com/mendableai/firecrawl-mcp-server", formats: ["markdown"], onlyMainContent: true });
// console.log("Result:", result);
const llm = new ChatOpenAI({
modelName: "gpt-4o-mini",
});
const bindLLM = llm.bind({
tools: tools,
tool_choice: "auto",
});
const result = await bindLLM.invoke([
// { role: "system", content: `Tool Prompt: ${JSON.stringify(tooldata)}` },
{
role: "system",
content: `Use properties to get information about tool required arguments!`
},
{
role: "user",
content: "What is that page about: url: https://github.com/mendableai/firecrawl-mcp-server"
}]);
console.log("Result:", JSON.stringify(result.tool_calls, null, 2));
} catch (error: any) {
console.error("Error during agent invocation:", error);
// For tool-specific errors, you might check error.name === "ToolException"
if (error.name === "ToolException") {
console.error("Tool execution failed:", error.message);
}
} finally {
// Close the MCP client to clean up resources.
await client.close();
}
})(); results: In loog I can see properties are there, but bind can not pick them up. |
Just to mention, the same behaviour is with CreateReactAgent. |
Same issue, I think the issue is caued by And I tried directly use And I pass this tool to ReAct agent like below: And I found that the LLM can not process the tool params, when I debug with the langsmith, I find that actually the params of the function calling are invalid. |
So I fixed my issues by down grading version a bit. Also am binding the whole getAllTools (maybe with some prefilteting step) and it works nicely. |
Actually, I found another way to solve this problem by forked this adapter project. The only modification is that I added a new dependency It worked well for me. And I also found that event we do not use And also, I found We can find that the params of the function calling are correct now. |
Hi, @benjamincburns, thank you for providing the this adopter for developers to integrate the mcp servers easier. I'm wondering if there are any issues of |
This has been fixed as of v0.4.1. Please update to the latest versions of If you're still experiencing issues after updating to latest versions of ALL of the above libraries, please open a new issue. |
Bug Description
When
I use const tools = await client.getTools();
and
const bindLLM = llm.bind({
tools,
tool_choice: "auto",
});
it does not see tool arguments and always provide with empty arguments:
"tool_calls": [
{
"id": "call_Njw1orEyCrlaWWSjg3KTvdOE",
"type": "function",
"function": {
"name": "mcp__firecrawl__firecrawl_scrape",
"arguments": "{}"
}
}
]
Environment
The text was updated successfully, but these errors were encountered: