This repository was archived by the owner on May 16, 2025. It is now read-only.
This repository was archived by the owner on May 16, 2025. It is now read-only.
[BUG] Cannot bind MCP tools to ChatXAI models #66
Closed
Description
Bug Description
When using tools loaded via loadMcpTools()
with createReactAgent
from @langchain/langgraph
using ChatXAI or ChatDeepSeek, the system throws a TypeError: parameters.describe is not a function
.
Reproduction Steps
Steps to reproduce the behavior:
- Create a client using
new Client()
from@modelcontextprotocol/sdk/client
. - Connect to a tool server via
StdioClientTransport
, e.g.,tavily-mcp
. - Load tools using
loadMcpTools('tavily-mcp', client)
. - Pass these tools directly to
createReactAgent()
as-is, choose ChatDeepSeek or ChatXAI as the LLM. - Invoke the compiled agent workflow and observe the crash.
Expected Behavior
The tools should be accepted by createReactAgent()
without requiring manual conversion of the parameters
field to Zod schema.
Actual Behavior
Runtime error is thrown:
[Nest] 19888 - 29/04/2025, 6:06:13 pm ERROR TypeError: Cannot read properties of undefined (reading 'typeName')
at parseDef (C:\Users\Admin\Documents\red\p1\demo\node_modules\openai\src\_vendor\zod-to-json-schema\parseDef.ts:102:53)
at zodToJsonSchema (C:\Users\Admin\Documents\red\p1\demo\node_modules\openai\src\_vendor\zod-to-json-schema\zodToJsonSchema.ts:26:13)
at zodToJsonSchema (C:\Users\Admin\Documents\red\p1\demo\node_modules\openai\src\helpers\zod.ts:16:26)
at zodFunction (C:\Users\Admin\Documents\red\p1\demo\node_modules\openai\src\helpers\zod.ts:119:21)
at _convertToOpenAITool (C:\Users\Admin\Documents\red\p1\demo\node_modules\@langchain\xai\node_modules\@langchain\openai\dist\utils\tools.cjs:22:50)
at _convertChatOpenAIToolTypeToOpenAITool (C:\Users\Admin\Documents\red\p1\demo\node_modules\@langchain\xai\node_modules\@langchain\openai\dist\chat_models.cjs:461:48)
at C:\Users\Admin\Documents\red\p1\demo\node_modules\@langchain\xai\node_modules\@langchain\openai\dist\chat_models.cjs:1330:19
at Array.map (<anonymous>)
at ChatXAI.bindTools (C:\Users\Admin\Documents\red\p1\demo\node_modules\@langchain\xai\node_modules\@langchain\openai\dist\chat_models.cjs:1328:26)
at createReactAgent (C:\Users\Admin\Documents\red\p1\demo\node_modules\@langchain\langgraph\src\prebuilt\react_agent_executor.ts:469:3)
Stack trace points to internal LangGraph validation when handling tools.
Environment
- OS: Windows 11
- Node.js version: 22.14.0
- Package version:
@langchain/langgraph
: 0.2.65@langchain/mcp-adapters
: 0.4.2
- MCP Tool:
tavily-mcp
(https://docs.tavily.com/documentation/mcp#cursor) - Transport type:
stdio
- MCP Server:
Additional Context
None
Possible Solution
none