Skip to content
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
@Ries0703

Description

@Ries0703

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:

  1. Create a client using new Client() from @modelcontextprotocol/sdk/client.
  2. Connect to a tool server via StdioClientTransport, e.g., tavily-mcp.
  3. Load tools using loadMcpTools('tavily-mcp', client).
  4. Pass these tools directly to createReactAgent() as-is, choose ChatDeepSeek or ChatXAI as the LLM.
  5. 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

Additional Context

None

Possible Solution

none

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions