Skip to content

[BUG] Cannot bind MCP tools to ChatXAI models #66

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

Closed
Ries0703 opened this issue Apr 29, 2025 · 2 comments
Closed

[BUG] Cannot bind MCP tools to ChatXAI models #66

Ries0703 opened this issue Apr 29, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@Ries0703
Copy link

Ries0703 commented Apr 29, 2025

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

@Ries0703 Ries0703 added the bug Something isn't working label Apr 29, 2025
@benjamincburns
Copy link
Collaborator

benjamincburns commented May 13, 2025

This is actually a bug in langchain - we need to implement JSONSchema support on the XAI provider. Created langchain-ai/langchainjs#8166 to track this

@benjamincburns
Copy link
Collaborator

@Ries0703 Thanks for flagging this. Let's track this on the new ticket (see link in previous comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants