Error invoking prebuilt reAct Agent with Tools loaded from MCP #260

Closed
opened 2026-02-15 18:15:10 -05:00 by yindo · 1 comment
Owner

Originally created by @avneeshkumar on GitHub (May 19, 2025).

I have raise the same issue here as well.. Close this if not relevant here

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

The code is as follows:-


import ChatAPIRequestDto from '../../dtos/chatAPI.request';
import { Service } from 'typedi';
import { MultiServerMCPClient } from '@langchain/mcp-adapters';
import { LangchainLlm } from '@/utils/langchainLLM';
import { MM_CONFIG } from '@/config';
import { createReactAgent } from '@langchain/langgraph/prebuilt';

@Service()
export class SimpleApiService {
  private client: MultiServerMCPClient;
  private model: LangchainLlm;
  constructor() {
    // Create client and connect to server
    this.client = new MultiServerMCPClient({
      // Global tool configuration options
      // Whether to throw on errors if a tool fails to load (optional, default: true)
      throwOnLoadError: true,
      // Whether to prefix tool names with the server name (optional, default: true)
      prefixToolNameWithServerName: true,
      // Optional additional prefix for tool names (optional, default: "mcp")
      additionalToolNamePrefix: 'mcp',

      // Server configuration
      mcpServers: {
        // Sreamable HTTP transport example, with auth headers and automatic SSE fallback disabled (defaults to enabled)
        mailmodo: {
          transport: 'sse',
          url: 'https://mcp.app.mailmodo.com/mcp',
          headers: {
            Authorization: 'Anything-goes-here',
          },
          reconnect: {
            enabled: true,
            maxAttempts: 5,
            delayMs: 10000,
          },
          useNodeEventSource: true,
        },
      },
    });
    this.model = new LangchainLlm(MM_CONFIG.azureOpenAI.azureOpenAIApiDeploymentName);
  }
  public async processRequest(dto: ChatAPIRequestDto): Promise<any> {
    // Create the React agent
    const tools = await this.client.getTools();
    const agent = createReactAgent({
      llm: this.model.getLLM(),
      tools: [tools[0]],
    });
    const response = await agent.invoke({
      messages: [{ role: 'user', content: dto.query }],
    });
    await this.client.close();
    return response;
  }
}


Error Message and Stack Trace (if applicable)

/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts:102
  const jsonSchema = selectParser(def, (def as any).typeName, refs, forceResolution);
                                                    ^
TypeError: Cannot read properties of undefined (reading 'typeName')
    at parseDef (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts:102:53)
    at zodToJsonSchema (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts:26:13)
    at zodToJsonSchema (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/helpers/zod.ts:12:26)
    at zodFunction (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/helpers/zod.ts:98:21)
    at _convertToOpenAITool (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/utils/tools.cjs:22:50)
    at _convertChatOpenAIToolTypeToOpenAITool (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/chat_models.cjs:229:48)
    at /Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/chat_models.cjs:1134:40
    at Array.map (<anonymous>)
    at ChatOpenAI.bindTools (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/chat_models.cjs:1134:26)
    at getModelRunnable (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/langgraph/src/prebuilt/react_agent_executor.ts:524:7) {
  pregelTaskId: '9c4a050e-046e-5db4-9ae5-8ed15cd1cf23'
}

Description

Tools are loading correctly.

[
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__userDetails",
      description: "Tool to get all details of a contact ",
      schema: {
        type: "object",
        properties: {
          email: {
            type: "string",
          },
        },
        required: [
          "email",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__userDetails",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Tool to get all details of a contact ",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        email: {
          type: "string",
        },
      },
      required: [
        "email",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__MailmodoCampainReportTool",
      description: "Tool to get the campaign reports for a particular campaign like open, click submission count etc",
      schema: {
        type: "object",
        properties: {
          campaignId: {
            type: "string",
            format: "uuid",
          },
          fromDate: {
            type: "string",
            pattern: "^\\d{4}-\\d{2}-\\d{2}$",
          },
          toDate: {
            type: "string",
            pattern: "^\\d{4}-\\d{2}-\\d{2}$",
          },
        },
        required: [
          "campaignId",
          "fromDate",
          "toDate",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__MailmodoCampainReportTool",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Tool to get the campaign reports for a particular campaign like open, click submission count etc",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        campaignId: {
          type: "string",
          format: "uuid",
        },
        fromDate: {
          type: "string",
          pattern: "^\\d{4}-\\d{2}-\\d{2}$",
        },
        toDate: {
          type: "string",
          pattern: "^\\d{4}-\\d{2}-\\d{2}$",
        },
      },
      required: [
        "campaignId",
        "fromDate",
        "toDate",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__currentDateTime",
      description: "Get Current Date and time",
      schema: {
        type: "object",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__currentDateTime",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Get Current Date and time",
    func: function () { [native code] },
    schema: {
      type: "object",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__sendEvent",
      description: "Send custom events with email, event name and event properties",
      schema: {
        type: "object",
        properties: {
          email: {
            type: "string",
          },
          event_name: {
            type: "string",
          },
          ts: {
            type: "number",
          },
          event_properties: {
            type: "object",
            additionalProperties: {
              anyOf: [
                {
                  type: "string",
                },
                {
                  type: "number",
                },
                {
                  type: "boolean",
                },
                {
                  not: {
                  },
                },
              ],
            },
          },
        },
        required: [
          "email",
          "event_name",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__sendEvent",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Send custom events with email, event name and event properties",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        email: {
          type: "string",
        },
        event_name: {
          type: "string",
        },
        ts: {
          type: "number",
        },
        event_properties: {
          type: "object",
          additionalProperties: {
            anyOf: [
              {
                type: "string",
              },
              {
                type: "number",
              },
              {
                type: "boolean",
              },
              {
                not: {
                },
              },
            ],
          },
        },
      },
      required: [
        "email",
        "event_name",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__addContactToList",
      description: "Add Contact to list ",
      schema: {
        type: "object",
        properties: {
          email: {
            type: "string",
          },
          listName: {
            type: "string",
          },
          data: {
            type: "object",
            properties: {
              first_name: {
                type: "string",
                description: "First name of the user",
              },
              last_name: {
                type: "string",
                description: "Last name of the user",
              },
              name: {
                type: "string",
                description: "Full name of the user",
              },
              gender: {
                type: "string",
                description: "Gender of the user",
              },
              age: {
                type: "integer",
                description: "Age of the user in numbers",
              },
              birthday: {
                anyOf: [
                  {
                    type: "string",
                  },
                  {
                    type: "integer",
                  },
                ],
                description: "Birthdate of the user (ISO format or UNIX timestamp)",
              },
              phone: {
                type: "string",
                description: "Primary phone number of the user",
              },
              address1: {
                type: "string",
                description: "Line 1 of the address of the user",
              },
              address2: {
                type: "string",
                description: "Line 2 of the address of the user",
              },
              city: {
                type: "string",
                description: "City/district/village of the user",
              },
              state: {
                type: "string",
                description: "State, region or province of the user",
              },
              country: {
                type: "string",
                description: "Country of the user",
              },
              postal_code: {
                type: "string",
                description: "PIN/ZIP Code of the user",
              },
              designation: {
                type: "string",
                description: "Designation of the user",
              },
              company: {
                type: "string",
                description: "Company of the user",
              },
              industry: {
                type: "string",
                description: "Industry of the user",
              },
              description: {
                type: "string",
                description: "Description of the user",
              },
              anniversary_date: {
                anyOf: [
                  {
                    $ref: "#/properties/data/properties/birthday/anyOf/0",
                  },
                  {
                    $ref: "#/properties/data/properties/birthday/anyOf/1",
                  },
                ],
                description: "Anniversary date (ISO format or UNIX timestamp)",
              },
            },
            additionalProperties: {
              anyOf: [
                {
                  type: "string",
                },
                {
                  type: "number",
                },
                {
                  type: "boolean",
                },
                {
                  not: {
                  },
                },
              ],
            },
          },
          created_at: {
            type: "string",
          },
          last_click: {
            $ref: "#/properties/created_at",
          },
          last_open: {
            $ref: "#/properties/created_at",
          },
          timezone: {
            type: "string",
            pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$",
          },
        },
        required: [
          "email",
          "listName",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__addContactToList",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Add Contact to list ",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        email: {
          type: "string",
        },
        listName: {
          type: "string",
        },
        data: {
          type: "object",
          properties: {
            first_name: {
              type: "string",
              description: "First name of the user",
            },
            last_name: {
              type: "string",
              description: "Last name of the user",
            },
            name: {
              type: "string",
              description: "Full name of the user",
            },
            gender: {
              type: "string",
              description: "Gender of the user",
            },
            age: {
              type: "integer",
              description: "Age of the user in numbers",
            },
            birthday: {
              anyOf: [
                {
                  type: "string",
                },
                {
                  type: "integer",
                },
              ],
              description: "Birthdate of the user (ISO format or UNIX timestamp)",
            },
            phone: {
              type: "string",
              description: "Primary phone number of the user",
            },
            address1: {
              type: "string",
              description: "Line 1 of the address of the user",
            },
            address2: {
              type: "string",
              description: "Line 2 of the address of the user",
            },
            city: {
              type: "string",
              description: "City/district/village of the user",
            },
            state: {
              type: "string",
              description: "State, region or province of the user",
            },
            country: {
              type: "string",
              description: "Country of the user",
            },
            postal_code: {
              type: "string",
              description: "PIN/ZIP Code of the user",
            },
            designation: {
              type: "string",
              description: "Designation of the user",
            },
            company: {
              type: "string",
              description: "Company of the user",
            },
            industry: {
              type: "string",
              description: "Industry of the user",
            },
            description: {
              type: "string",
              description: "Description of the user",
            },
            anniversary_date: {
              anyOf: [
                {
                  $ref: "#/properties/data/properties/birthday/anyOf/0",
                },
                {
                  $ref: "#/properties/data/properties/birthday/anyOf/1",
                },
              ],
              description: "Anniversary date (ISO format or UNIX timestamp)",
            },
          },
          additionalProperties: {
            anyOf: [
              {
                type: "string",
              },
              {
                type: "number",
              },
              {
                type: "boolean",
              },
              {
                not: {
                },
              },
            ],
          },
        },
        created_at: {
          type: "string",
        },
        last_click: {
          $ref: "#/properties/created_at",
        },
        last_open: {
          $ref: "#/properties/created_at",
        },
        timezone: {
          type: "string",
          pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$",
        },
      },
      required: [
        "email",
        "listName",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__addBulkContactToList",
      description: "Add Many Contact to a list in single API",
      schema: {
        type: "object",
        properties: {
          listName: {
            type: "string",
          },
          values: {
            type: "array",
            items: {
              type: "object",
              properties: {
                email: {
                  type: "string",
                },
                data: {
                  type: "object",
                  properties: {
                    first_name: {
                      type: "string",
                      description: "First name of the user",
                    },
                    last_name: {
                      type: "string",
                      description: "Last name of the user",
                    },
                    name: {
                      type: "string",
                      description: "Full name of the user",
                    },
                    gender: {
                      type: "string",
                      description: "Gender of the user",
                    },
                    age: {
                      type: "integer",
                      description: "Age of the user in numbers",
                    },
                    birthday: {
                      anyOf: [
                        {
                          type: "string",
                        },
                        {
                          type: "integer",
                        },
                      ],
                      description: "Birthdate of the user (ISO format or UNIX timestamp)",
                    },
                    phone: {
                      type: "string",
                      description: "Primary phone number of the user",
                    },
                    address1: {
                      type: "string",
                      description: "Line 1 of the address of the user",
                    },
                    address2: {
                      type: "string",
                      description: "Line 2 of the address of the user",
                    },
                    city: {
                      type: "string",
                      description: "City/district/village of the user",
                    },
                    state: {
                      type: "string",
                      description: "State, region or province of the user",
                    },
                    country: {
                      type: "string",
                      description: "Country of the user",
                    },
                    postal_code: {
                      type: "string",
                      description: "PIN/ZIP Code of the user",
                    },
                    designation: {
                      type: "string",
                      description: "Designation of the user",
                    },
                    company: {
                      type: "string",
                      description: "Company of the user",
                    },
                    industry: {
                      type: "string",
                      description: "Industry of the user",
                    },
                    description: {
                      type: "string",
                      description: "Description of the user",
                    },
                    anniversary_date: {
                      anyOf: [
                        {
                          $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/0",
                        },
                        {
                          $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/1",
                        },
                      ],
                      description: "Anniversary date (ISO format or UNIX timestamp)",
                    },
                  },
                  additionalProperties: {
                    anyOf: [
                      {
                        type: "string",
                      },
                      {
                        type: "number",
                      },
                      {
                        type: "boolean",
                      },
                      {
                        not: {
                        },
                      },
                    ],
                  },
                },
                created_at: {
                  type: "string",
                },
                last_click: {
                  $ref: "#/properties/values/items/properties/created_at",
                },
                last_open: {
                  $ref: "#/properties/values/items/properties/created_at",
                },
                timezone: {
                  type: "string",
                  pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$",
                },
              },
              required: [
                "email",
              ],
              additionalProperties: false,
            },
          },
        },
        required: [
          "listName",
          "values",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__addBulkContactToList",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Add Many Contact to a list in single API",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        listName: {
          type: "string",
        },
        values: {
          type: "array",
          items: {
            type: "object",
            properties: {
              email: {
                type: "string",
              },
              data: {
                type: "object",
                properties: {
                  first_name: {
                    type: "string",
                    description: "First name of the user",
                  },
                  last_name: {
                    type: "string",
                    description: "Last name of the user",
                  },
                  name: {
                    type: "string",
                    description: "Full name of the user",
                  },
                  gender: {
                    type: "string",
                    description: "Gender of the user",
                  },
                  age: {
                    type: "integer",
                    description: "Age of the user in numbers",
                  },
                  birthday: {
                    anyOf: [
                      {
                        type: "string",
                      },
                      {
                        type: "integer",
                      },
                    ],
                    description: "Birthdate of the user (ISO format or UNIX timestamp)",
                  },
                  phone: {
                    type: "string",
                    description: "Primary phone number of the user",
                  },
                  address1: {
                    type: "string",
                    description: "Line 1 of the address of the user",
                  },
                  address2: {
                    type: "string",
                    description: "Line 2 of the address of the user",
                  },
                  city: {
                    type: "string",
                    description: "City/district/village of the user",
                  },
                  state: {
                    type: "string",
                    description: "State, region or province of the user",
                  },
                  country: {
                    type: "string",
                    description: "Country of the user",
                  },
                  postal_code: {
                    type: "string",
                    description: "PIN/ZIP Code of the user",
                  },
                  designation: {
                    type: "string",
                    description: "Designation of the user",
                  },
                  company: {
                    type: "string",
                    description: "Company of the user",
                  },
                  industry: {
                    type: "string",
                    description: "Industry of the user",
                  },
                  description: {
                    type: "string",
                    description: "Description of the user",
                  },
                  anniversary_date: {
                    anyOf: [
                      {
                        $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/0",
                      },
                      {
                        $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/1",
                      },
                    ],
                    description: "Anniversary date (ISO format or UNIX timestamp)",
                  },
                },
                additionalProperties: {
                  anyOf: [
                    {
                      type: "string",
                    },
                    {
                      type: "number",
                    },
                    {
                      type: "boolean",
                    },
                    {
                      not: {
                      },
                    },
                  ],
                },
              },
              created_at: {
                type: "string",
              },
              last_click: {
                $ref: "#/properties/values/items/properties/created_at",
              },
              last_open: {
                $ref: "#/properties/values/items/properties/created_at",
              },
              timezone: {
                type: "string",
                pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$",
              },
            },
            required: [
              "email",
            ],
            additionalProperties: false,
          },
        },
      },
      required: [
        "listName",
        "values",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__unsubscribeContact",
      description: "Unsubscribe or supress contact in mailmodo",
      schema: {
        type: "object",
        properties: {
          email: {
            type: "string",
          },
        },
        required: [
          "email",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__unsubscribeContact",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Unsubscribe or supress contact in mailmodo",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        email: {
          type: "string",
        },
      },
      required: [
        "email",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__resubscribeContact",
      description: "Resubscribe contact in mailmodo",
      schema: {
        type: "object",
        properties: {
          email: {
            type: "string",
          },
        },
        required: [
          "email",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__resubscribeContact",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Resubscribe contact in mailmodo",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        email: {
          type: "string",
        },
      },
      required: [
        "email",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__archiveContact",
      description: "permanently archive contact in mailmodo",
      schema: {
        type: "object",
        properties: {
          email: {
            type: "string",
          },
        },
        required: [
          "email",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__archiveContact",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "permanently archive contact in mailmodo",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        email: {
          type: "string",
        },
      },
      required: [
        "email",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__removeContactFromList",
      description: "Remove a particular contact from the contact list",
      schema: {
        type: "object",
        properties: {
          email: {
            type: "string",
          },
          listName: {
            type: "string",
          },
        },
        required: [
          "email",
          "listName",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__removeContactFromList",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Remove a particular contact from the contact list",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        email: {
          type: "string",
        },
        listName: {
          type: "string",
        },
      },
      required: [
        "email",
        "listName",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__sendEmailToCampaign",
      description: "Trigger and email for email campaign trigger with personalization parameter added to the email template. ",
      schema: {
        type: "object",
        properties: {
          campaignId: {
            type: "string",
            description: "Camapign id of the campaign to be triggered",
          },
          email: {
            type: "string",
            format: "email",
            description: "Email address of the contact to whom you want to send the email. This is required.",
          },
          subject: {
            type: "string",
            description: "Optional: Overrides the default subject line provided when creating the campaign.",
          },
          replyTo: {
            type: "string",
            description: "Optional: Overrides the default reply-to email address for the campaign.",
          },
          fromName: {
            type: "string",
            description: "Optional: Overrides the sender name for the campaign.",
          },
          campaign_data: {
            type: "object",
            additionalProperties: {
              type: "string",
            },
            description: "Optional: Transient personalization parameters, not stored in the contact profile.",
          },
          data: {
            type: "object",
            additionalProperties: {
              type: "string",
            },
            description: "Optional: Personalization parameters saved to the contact's profile.",
          },
          addToList: {
            type: "string",
            description: "Optional: List ID to which the contact should be added as part of triggering the campaign.",
          },
        },
        required: [
          "campaignId",
          "email",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__sendEmailToCampaign",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "Trigger and email for email campaign trigger with personalization parameter added to the email template. ",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        campaignId: {
          type: "string",
          description: "Camapign id of the campaign to be triggered",
        },
        email: {
          type: "string",
          format: "email",
          description: "Email address of the contact to whom you want to send the email. This is required.",
        },
        subject: {
          type: "string",
          description: "Optional: Overrides the default subject line provided when creating the campaign.",
        },
        replyTo: {
          type: "string",
          description: "Optional: Overrides the default reply-to email address for the campaign.",
        },
        fromName: {
          type: "string",
          description: "Optional: Overrides the sender name for the campaign.",
        },
        campaign_data: {
          type: "object",
          additionalProperties: {
            type: "string",
          },
          description: "Optional: Transient personalization parameters, not stored in the contact profile.",
        },
        data: {
          type: "object",
          additionalProperties: {
            type: "string",
          },
          description: "Optional: Personalization parameters saved to the contact's profile.",
        },
        addToList: {
          type: "string",
          description: "Optional: List ID to which the contact should be added as part of triggering the campaign.",
        },
      },
      required: [
        "campaignId",
        "email",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
  {
    lc_serializable: false,
    lc_kwargs: {
      name: "mcp__mailmodo__broadcastCampaignToList",
      description: "The broadcast campaign API allows the user to trigger campaigns to the entire contact list using a single API request.",
      schema: {
        type: "object",
        properties: {
          campaignId: {
            type: "string",
            description: "Campaign id of the campaign to be triggered",
          },
          listId: {
            type: "string",
            description: "Id of the contact list or segment for which the campaign should be triggered.",
          },
          subject: {
            type: "string",
            description: "Optional subject line of the campaign. This will appear as the subject of the email sent to recipients.",
          },
          idempotencyKey: {
            type: "string",
            description: "Optional unique key to allow retries of the same campaign within 24 hours. Allows safe resending. For example: \"2024-09-05T17:00:00Z\".",
          },
          campaign_data: {
            type: "object",
            additionalProperties: {
              type: "string",
            },
            description: "Optional set of personalization parameters for the campaign. Each key represents a variable (e.g., \"first_name\") to be used in the email template. If a key is missing, the backend will fetch values from contact properties or default to an empty string.",
          },
        },
        required: [
          "campaignId",
          "listId",
        ],
        additionalProperties: false,
        $schema: "http://json-schema.org/draft-07/schema#",
      },
      responseFormat: "content_and_artifact",
      func: function () { [native code] },
    },
    lc_runnable: true,
    name: "mcp__mailmodo__broadcastCampaignToList",
    verbose: false,
    callbacks: undefined,
    tags: [
    ],
    metadata: {
    },
    returnDirect: false,
    verboseParsingErrors: false,
    responseFormat: "content_and_artifact",
    description: "The broadcast campaign API allows the user to trigger campaigns to the entire contact list using a single API request.",
    func: function () { [native code] },
    schema: {
      type: "object",
      properties: {
        campaignId: {
          type: "string",
          description: "Campaign id of the campaign to be triggered",
        },
        listId: {
          type: "string",
          description: "Id of the contact list or segment for which the campaign should be triggered.",
        },
        subject: {
          type: "string",
          description: "Optional subject line of the campaign. This will appear as the subject of the email sent to recipients.",
        },
        idempotencyKey: {
          type: "string",
          description: "Optional unique key to allow retries of the same campaign within 24 hours. Allows safe resending. For example: \"2024-09-05T17:00:00Z\".",
        },
        campaign_data: {
          type: "object",
          additionalProperties: {
            type: "string",
          },
          description: "Optional set of personalization parameters for the campaign. Each key represents a variable (e.g., \"first_name\") to be used in the email template. If a key is missing, the backend will fetch values from contact properties or default to an empty string.",
        },
      },
      required: [
        "campaignId",
        "listId",
      ],
      additionalProperties: false,
      $schema: "http://json-schema.org/draft-07/schema#",
    },
  },
]

But when using these tools with prebuilt createReactAgent

 const response = await agent.invoke({
      messages: [{ role: 'user', content: dto.query }],
    });

I am getting the error. Looks like the error is because the tools have schema as JSONSchema format but the Langchain is expecting it to be of Zod Schema format.

System Info

langchain@0.3.26 | MIT | deps: 12 | versions: 321
Typescript bindings for langchain
https://github.com/langchain-ai/langchainjs/tree/main/langchain/

keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores

dist
.tarball: https://registry.npmjs.org/langchain/-/langchain-0.3.26.tgz
.shasum: 5e1dec39172d1589bfee369a710b2e2459c3df8e
.integrity: sha512-W/9phB4wiAnj+PnpMWmv/ptIp7i5ygY2aK8yjKlxccHPbaNeMoy7njzFz8d0/xfcPyA3MvG4AuZnJ1j3/E2/Ig==
.unpackedSize: 2.9 MB

dependencies:
@langchain/openai: >=0.1.0 <0.6.0        jsonpointer: ^5.0.1                      uuid: ^10.0.0                            
@langchain/textsplitters: >=0.0.0 <0.2.0 langsmith: ^0.3.29                       yaml: ^2.2.1                             
js-tiktoken: ^1.0.12                     openapi-types: ^12.1.3                   zod-to-json-schema: ^3.22.3              
js-yaml: ^4.1.0                          p-retry: 4                               zod: ^3.22.4                             

maintainers:
- nfcampos <nuno@boringbits.io>
- jacoblee93 <jacoblee93@gmail.com>
- andrewnguonly <andrewnguonly@gmail.com>
- benjamincburns <benjamin.c.burns@gmail.com>
- davidduong <david@duong.cz>
- hwchase17 <hw.chase.17@gmail.com>
- basproul <braceasproul@gmail.com>

dist-tags:
latest: 0.3.26                             next: 0.3.2-rc.0                           tag-for-publishing-older-releases: 0.2.20  

published 4 days ago by benjamincburns <benjamin.c.burns@gmail.com>

Node version: v20.18.1

OS: Mac 15.4.1 M2

Originally created by @avneeshkumar on GitHub (May 19, 2025). **I have raise the same issue [here](https://github.com/langchain-ai/langchainjs/issues/8203) as well.. Close this if not relevant here** ### Checked other resources - [x] I added a very descriptive title to this issue. - [x] I searched the LangChain.js documentation with the integrated search. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in LangChain.js rather than my code. - [x] The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package). ### Example Code The code is as follows:- ```typescript import ChatAPIRequestDto from '../../dtos/chatAPI.request'; import { Service } from 'typedi'; import { MultiServerMCPClient } from '@langchain/mcp-adapters'; import { LangchainLlm } from '@/utils/langchainLLM'; import { MM_CONFIG } from '@/config'; import { createReactAgent } from '@langchain/langgraph/prebuilt'; @Service() export class SimpleApiService { private client: MultiServerMCPClient; private model: LangchainLlm; constructor() { // Create client and connect to server this.client = new MultiServerMCPClient({ // Global tool configuration options // Whether to throw on errors if a tool fails to load (optional, default: true) throwOnLoadError: true, // Whether to prefix tool names with the server name (optional, default: true) prefixToolNameWithServerName: true, // Optional additional prefix for tool names (optional, default: "mcp") additionalToolNamePrefix: 'mcp', // Server configuration mcpServers: { // Sreamable HTTP transport example, with auth headers and automatic SSE fallback disabled (defaults to enabled) mailmodo: { transport: 'sse', url: 'https://mcp.app.mailmodo.com/mcp', headers: { Authorization: 'Anything-goes-here', }, reconnect: { enabled: true, maxAttempts: 5, delayMs: 10000, }, useNodeEventSource: true, }, }, }); this.model = new LangchainLlm(MM_CONFIG.azureOpenAI.azureOpenAIApiDeploymentName); } public async processRequest(dto: ChatAPIRequestDto): Promise<any> { // Create the React agent const tools = await this.client.getTools(); const agent = createReactAgent({ llm: this.model.getLLM(), tools: [tools[0]], }); const response = await agent.invoke({ messages: [{ role: 'user', content: dto.query }], }); await this.client.close(); return response; } } ``` ### Error Message and Stack Trace (if applicable) ```txt /Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts:102 const jsonSchema = selectParser(def, (def as any).typeName, refs, forceResolution); ^ TypeError: Cannot read properties of undefined (reading 'typeName') at parseDef (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/_vendor/zod-to-json-schema/parseDef.ts:102:53) at zodToJsonSchema (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/_vendor/zod-to-json-schema/zodToJsonSchema.ts:26:13) at zodToJsonSchema (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/helpers/zod.ts:12:26) at zodFunction (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/openai/src/helpers/zod.ts:98:21) at _convertToOpenAITool (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/utils/tools.cjs:22:50) at _convertChatOpenAIToolTypeToOpenAITool (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/chat_models.cjs:229:48) at /Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/chat_models.cjs:1134:40 at Array.map (<anonymous>) at ChatOpenAI.bindTools (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/openai/dist/chat_models.cjs:1134:26) at getModelRunnable (/Users/avneeshkumar/Documents/mailmodo/backend/galactiq/node_modules/@langchain/langgraph/src/prebuilt/react_agent_executor.ts:524:7) { pregelTaskId: '9c4a050e-046e-5db4-9ae5-8ed15cd1cf23' } ``` ### Description Tools are loading correctly. ```js [ { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__userDetails", description: "Tool to get all details of a contact ", schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__userDetails", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Tool to get all details of a contact ", func: function () { [native code] }, schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__MailmodoCampainReportTool", description: "Tool to get the campaign reports for a particular campaign like open, click submission count etc", schema: { type: "object", properties: { campaignId: { type: "string", format: "uuid", }, fromDate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", }, toDate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", }, }, required: [ "campaignId", "fromDate", "toDate", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__MailmodoCampainReportTool", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Tool to get the campaign reports for a particular campaign like open, click submission count etc", func: function () { [native code] }, schema: { type: "object", properties: { campaignId: { type: "string", format: "uuid", }, fromDate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", }, toDate: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$", }, }, required: [ "campaignId", "fromDate", "toDate", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__currentDateTime", description: "Get Current Date and time", schema: { type: "object", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__currentDateTime", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Get Current Date and time", func: function () { [native code] }, schema: { type: "object", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__sendEvent", description: "Send custom events with email, event name and event properties", schema: { type: "object", properties: { email: { type: "string", }, event_name: { type: "string", }, ts: { type: "number", }, event_properties: { type: "object", additionalProperties: { anyOf: [ { type: "string", }, { type: "number", }, { type: "boolean", }, { not: { }, }, ], }, }, }, required: [ "email", "event_name", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__sendEvent", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Send custom events with email, event name and event properties", func: function () { [native code] }, schema: { type: "object", properties: { email: { type: "string", }, event_name: { type: "string", }, ts: { type: "number", }, event_properties: { type: "object", additionalProperties: { anyOf: [ { type: "string", }, { type: "number", }, { type: "boolean", }, { not: { }, }, ], }, }, }, required: [ "email", "event_name", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__addContactToList", description: "Add Contact to list ", schema: { type: "object", properties: { email: { type: "string", }, listName: { type: "string", }, data: { type: "object", properties: { first_name: { type: "string", description: "First name of the user", }, last_name: { type: "string", description: "Last name of the user", }, name: { type: "string", description: "Full name of the user", }, gender: { type: "string", description: "Gender of the user", }, age: { type: "integer", description: "Age of the user in numbers", }, birthday: { anyOf: [ { type: "string", }, { type: "integer", }, ], description: "Birthdate of the user (ISO format or UNIX timestamp)", }, phone: { type: "string", description: "Primary phone number of the user", }, address1: { type: "string", description: "Line 1 of the address of the user", }, address2: { type: "string", description: "Line 2 of the address of the user", }, city: { type: "string", description: "City/district/village of the user", }, state: { type: "string", description: "State, region or province of the user", }, country: { type: "string", description: "Country of the user", }, postal_code: { type: "string", description: "PIN/ZIP Code of the user", }, designation: { type: "string", description: "Designation of the user", }, company: { type: "string", description: "Company of the user", }, industry: { type: "string", description: "Industry of the user", }, description: { type: "string", description: "Description of the user", }, anniversary_date: { anyOf: [ { $ref: "#/properties/data/properties/birthday/anyOf/0", }, { $ref: "#/properties/data/properties/birthday/anyOf/1", }, ], description: "Anniversary date (ISO format or UNIX timestamp)", }, }, additionalProperties: { anyOf: [ { type: "string", }, { type: "number", }, { type: "boolean", }, { not: { }, }, ], }, }, created_at: { type: "string", }, last_click: { $ref: "#/properties/created_at", }, last_open: { $ref: "#/properties/created_at", }, timezone: { type: "string", pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$", }, }, required: [ "email", "listName", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__addContactToList", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Add Contact to list ", func: function () { [native code] }, schema: { type: "object", properties: { email: { type: "string", }, listName: { type: "string", }, data: { type: "object", properties: { first_name: { type: "string", description: "First name of the user", }, last_name: { type: "string", description: "Last name of the user", }, name: { type: "string", description: "Full name of the user", }, gender: { type: "string", description: "Gender of the user", }, age: { type: "integer", description: "Age of the user in numbers", }, birthday: { anyOf: [ { type: "string", }, { type: "integer", }, ], description: "Birthdate of the user (ISO format or UNIX timestamp)", }, phone: { type: "string", description: "Primary phone number of the user", }, address1: { type: "string", description: "Line 1 of the address of the user", }, address2: { type: "string", description: "Line 2 of the address of the user", }, city: { type: "string", description: "City/district/village of the user", }, state: { type: "string", description: "State, region or province of the user", }, country: { type: "string", description: "Country of the user", }, postal_code: { type: "string", description: "PIN/ZIP Code of the user", }, designation: { type: "string", description: "Designation of the user", }, company: { type: "string", description: "Company of the user", }, industry: { type: "string", description: "Industry of the user", }, description: { type: "string", description: "Description of the user", }, anniversary_date: { anyOf: [ { $ref: "#/properties/data/properties/birthday/anyOf/0", }, { $ref: "#/properties/data/properties/birthday/anyOf/1", }, ], description: "Anniversary date (ISO format or UNIX timestamp)", }, }, additionalProperties: { anyOf: [ { type: "string", }, { type: "number", }, { type: "boolean", }, { not: { }, }, ], }, }, created_at: { type: "string", }, last_click: { $ref: "#/properties/created_at", }, last_open: { $ref: "#/properties/created_at", }, timezone: { type: "string", pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$", }, }, required: [ "email", "listName", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__addBulkContactToList", description: "Add Many Contact to a list in single API", schema: { type: "object", properties: { listName: { type: "string", }, values: { type: "array", items: { type: "object", properties: { email: { type: "string", }, data: { type: "object", properties: { first_name: { type: "string", description: "First name of the user", }, last_name: { type: "string", description: "Last name of the user", }, name: { type: "string", description: "Full name of the user", }, gender: { type: "string", description: "Gender of the user", }, age: { type: "integer", description: "Age of the user in numbers", }, birthday: { anyOf: [ { type: "string", }, { type: "integer", }, ], description: "Birthdate of the user (ISO format or UNIX timestamp)", }, phone: { type: "string", description: "Primary phone number of the user", }, address1: { type: "string", description: "Line 1 of the address of the user", }, address2: { type: "string", description: "Line 2 of the address of the user", }, city: { type: "string", description: "City/district/village of the user", }, state: { type: "string", description: "State, region or province of the user", }, country: { type: "string", description: "Country of the user", }, postal_code: { type: "string", description: "PIN/ZIP Code of the user", }, designation: { type: "string", description: "Designation of the user", }, company: { type: "string", description: "Company of the user", }, industry: { type: "string", description: "Industry of the user", }, description: { type: "string", description: "Description of the user", }, anniversary_date: { anyOf: [ { $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/0", }, { $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/1", }, ], description: "Anniversary date (ISO format or UNIX timestamp)", }, }, additionalProperties: { anyOf: [ { type: "string", }, { type: "number", }, { type: "boolean", }, { not: { }, }, ], }, }, created_at: { type: "string", }, last_click: { $ref: "#/properties/values/items/properties/created_at", }, last_open: { $ref: "#/properties/values/items/properties/created_at", }, timezone: { type: "string", pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$", }, }, required: [ "email", ], additionalProperties: false, }, }, }, required: [ "listName", "values", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__addBulkContactToList", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Add Many Contact to a list in single API", func: function () { [native code] }, schema: { type: "object", properties: { listName: { type: "string", }, values: { type: "array", items: { type: "object", properties: { email: { type: "string", }, data: { type: "object", properties: { first_name: { type: "string", description: "First name of the user", }, last_name: { type: "string", description: "Last name of the user", }, name: { type: "string", description: "Full name of the user", }, gender: { type: "string", description: "Gender of the user", }, age: { type: "integer", description: "Age of the user in numbers", }, birthday: { anyOf: [ { type: "string", }, { type: "integer", }, ], description: "Birthdate of the user (ISO format or UNIX timestamp)", }, phone: { type: "string", description: "Primary phone number of the user", }, address1: { type: "string", description: "Line 1 of the address of the user", }, address2: { type: "string", description: "Line 2 of the address of the user", }, city: { type: "string", description: "City/district/village of the user", }, state: { type: "string", description: "State, region or province of the user", }, country: { type: "string", description: "Country of the user", }, postal_code: { type: "string", description: "PIN/ZIP Code of the user", }, designation: { type: "string", description: "Designation of the user", }, company: { type: "string", description: "Company of the user", }, industry: { type: "string", description: "Industry of the user", }, description: { type: "string", description: "Description of the user", }, anniversary_date: { anyOf: [ { $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/0", }, { $ref: "#/properties/values/items/properties/data/properties/birthday/anyOf/1", }, ], description: "Anniversary date (ISO format or UNIX timestamp)", }, }, additionalProperties: { anyOf: [ { type: "string", }, { type: "number", }, { type: "boolean", }, { not: { }, }, ], }, }, created_at: { type: "string", }, last_click: { $ref: "#/properties/values/items/properties/created_at", }, last_open: { $ref: "#/properties/values/items/properties/created_at", }, timezone: { type: "string", pattern: "^[A-Za-z_]+(?:\\/[A-Za-z_]+(?:\\/[A-Za-z_]+)?)?$", }, }, required: [ "email", ], additionalProperties: false, }, }, }, required: [ "listName", "values", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__unsubscribeContact", description: "Unsubscribe or supress contact in mailmodo", schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__unsubscribeContact", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Unsubscribe or supress contact in mailmodo", func: function () { [native code] }, schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__resubscribeContact", description: "Resubscribe contact in mailmodo", schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__resubscribeContact", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Resubscribe contact in mailmodo", func: function () { [native code] }, schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__archiveContact", description: "permanently archive contact in mailmodo", schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__archiveContact", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "permanently archive contact in mailmodo", func: function () { [native code] }, schema: { type: "object", properties: { email: { type: "string", }, }, required: [ "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__removeContactFromList", description: "Remove a particular contact from the contact list", schema: { type: "object", properties: { email: { type: "string", }, listName: { type: "string", }, }, required: [ "email", "listName", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__removeContactFromList", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Remove a particular contact from the contact list", func: function () { [native code] }, schema: { type: "object", properties: { email: { type: "string", }, listName: { type: "string", }, }, required: [ "email", "listName", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__sendEmailToCampaign", description: "Trigger and email for email campaign trigger with personalization parameter added to the email template. ", schema: { type: "object", properties: { campaignId: { type: "string", description: "Camapign id of the campaign to be triggered", }, email: { type: "string", format: "email", description: "Email address of the contact to whom you want to send the email. This is required.", }, subject: { type: "string", description: "Optional: Overrides the default subject line provided when creating the campaign.", }, replyTo: { type: "string", description: "Optional: Overrides the default reply-to email address for the campaign.", }, fromName: { type: "string", description: "Optional: Overrides the sender name for the campaign.", }, campaign_data: { type: "object", additionalProperties: { type: "string", }, description: "Optional: Transient personalization parameters, not stored in the contact profile.", }, data: { type: "object", additionalProperties: { type: "string", }, description: "Optional: Personalization parameters saved to the contact's profile.", }, addToList: { type: "string", description: "Optional: List ID to which the contact should be added as part of triggering the campaign.", }, }, required: [ "campaignId", "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__sendEmailToCampaign", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "Trigger and email for email campaign trigger with personalization parameter added to the email template. ", func: function () { [native code] }, schema: { type: "object", properties: { campaignId: { type: "string", description: "Camapign id of the campaign to be triggered", }, email: { type: "string", format: "email", description: "Email address of the contact to whom you want to send the email. This is required.", }, subject: { type: "string", description: "Optional: Overrides the default subject line provided when creating the campaign.", }, replyTo: { type: "string", description: "Optional: Overrides the default reply-to email address for the campaign.", }, fromName: { type: "string", description: "Optional: Overrides the sender name for the campaign.", }, campaign_data: { type: "object", additionalProperties: { type: "string", }, description: "Optional: Transient personalization parameters, not stored in the contact profile.", }, data: { type: "object", additionalProperties: { type: "string", }, description: "Optional: Personalization parameters saved to the contact's profile.", }, addToList: { type: "string", description: "Optional: List ID to which the contact should be added as part of triggering the campaign.", }, }, required: [ "campaignId", "email", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, { lc_serializable: false, lc_kwargs: { name: "mcp__mailmodo__broadcastCampaignToList", description: "The broadcast campaign API allows the user to trigger campaigns to the entire contact list using a single API request.", schema: { type: "object", properties: { campaignId: { type: "string", description: "Campaign id of the campaign to be triggered", }, listId: { type: "string", description: "Id of the contact list or segment for which the campaign should be triggered.", }, subject: { type: "string", description: "Optional subject line of the campaign. This will appear as the subject of the email sent to recipients.", }, idempotencyKey: { type: "string", description: "Optional unique key to allow retries of the same campaign within 24 hours. Allows safe resending. For example: \"2024-09-05T17:00:00Z\".", }, campaign_data: { type: "object", additionalProperties: { type: "string", }, description: "Optional set of personalization parameters for the campaign. Each key represents a variable (e.g., \"first_name\") to be used in the email template. If a key is missing, the backend will fetch values from contact properties or default to an empty string.", }, }, required: [ "campaignId", "listId", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, responseFormat: "content_and_artifact", func: function () { [native code] }, }, lc_runnable: true, name: "mcp__mailmodo__broadcastCampaignToList", verbose: false, callbacks: undefined, tags: [ ], metadata: { }, returnDirect: false, verboseParsingErrors: false, responseFormat: "content_and_artifact", description: "The broadcast campaign API allows the user to trigger campaigns to the entire contact list using a single API request.", func: function () { [native code] }, schema: { type: "object", properties: { campaignId: { type: "string", description: "Campaign id of the campaign to be triggered", }, listId: { type: "string", description: "Id of the contact list or segment for which the campaign should be triggered.", }, subject: { type: "string", description: "Optional subject line of the campaign. This will appear as the subject of the email sent to recipients.", }, idempotencyKey: { type: "string", description: "Optional unique key to allow retries of the same campaign within 24 hours. Allows safe resending. For example: \"2024-09-05T17:00:00Z\".", }, campaign_data: { type: "object", additionalProperties: { type: "string", }, description: "Optional set of personalization parameters for the campaign. Each key represents a variable (e.g., \"first_name\") to be used in the email template. If a key is missing, the backend will fetch values from contact properties or default to an empty string.", }, }, required: [ "campaignId", "listId", ], additionalProperties: false, $schema: "http://json-schema.org/draft-07/schema#", }, }, ] ``` But when using these tools with prebuilt createReactAgent ```typescript const response = await agent.invoke({ messages: [{ role: 'user', content: dto.query }], }); ``` I am getting the error. Looks like the error is because the tools have schema as JSONSchema format but the Langchain is expecting it to be of Zod Schema format. ### System Info ```txt langchain@0.3.26 | MIT | deps: 12 | versions: 321 Typescript bindings for langchain https://github.com/langchain-ai/langchainjs/tree/main/langchain/ keywords: llm, ai, gpt3, chain, prompt, prompt engineering, chatgpt, machine learning, ml, openai, embeddings, vectorstores dist .tarball: https://registry.npmjs.org/langchain/-/langchain-0.3.26.tgz .shasum: 5e1dec39172d1589bfee369a710b2e2459c3df8e .integrity: sha512-W/9phB4wiAnj+PnpMWmv/ptIp7i5ygY2aK8yjKlxccHPbaNeMoy7njzFz8d0/xfcPyA3MvG4AuZnJ1j3/E2/Ig== .unpackedSize: 2.9 MB dependencies: @langchain/openai: >=0.1.0 <0.6.0 jsonpointer: ^5.0.1 uuid: ^10.0.0 @langchain/textsplitters: >=0.0.0 <0.2.0 langsmith: ^0.3.29 yaml: ^2.2.1 js-tiktoken: ^1.0.12 openapi-types: ^12.1.3 zod-to-json-schema: ^3.22.3 js-yaml: ^4.1.0 p-retry: 4 zod: ^3.22.4 maintainers: - nfcampos <nuno@boringbits.io> - jacoblee93 <jacoblee93@gmail.com> - andrewnguonly <andrewnguonly@gmail.com> - benjamincburns <benjamin.c.burns@gmail.com> - davidduong <david@duong.cz> - hwchase17 <hw.chase.17@gmail.com> - basproul <braceasproul@gmail.com> dist-tags: latest: 0.3.26 next: 0.3.2-rc.0 tag-for-publishing-older-releases: 0.2.20 published 4 days ago by benjamincburns <benjamin.c.burns@gmail.com> ``` Node version: v20.18.1 OS: Mac 15.4.1 M2
yindo closed this issue 2026-02-15 18:15:10 -05:00
Author
Owner

@avneeshkumar commented on GitHub (May 20, 2025):

Issue is resolved. It was happening because of outdated version of ChatOpenAI (import { ChatOpenAI } from '@langchain/openai';) which was not detecting the Faulty constructor when using the Azure OpenAI Deployments.

this.chatOpenAI = new ChatOpenAI({
      model: this.modelName,
      azureOpenAIApiVersion: this.azureOpenAIVersion,
      azureOpenAIApiKey: this.azureOpenAIKey,
      azureOpenAIEndpoint: this.azureOpenAIEndpoint,
      azureOpenAIApiDeploymentName: this.deploymentName,
});

Correct Code

this.chatOpenAI = new AzureChatOpenAI({
      model: this.modelName,
      azureOpenAIApiVersion: this.azureOpenAIVersion,
      azureOpenAIApiKey: this.azureOpenAIKey,
      azureOpenAIEndpoint: this.azureOpenAIEndpoint,
      azureOpenAIApiDeploymentName: this.deploymentName,
    });
}

We detected after I manually added the "@langchain/openai": "0.5.10", to package.json which gave build error on the constructor which we fixed by using the AzureChatOpenAI.

@avneeshkumar commented on GitHub (May 20, 2025): Issue is resolved. It was happening because of outdated version of ChatOpenAI (`import { ChatOpenAI } from '@langchain/openai';`) which was not detecting the Faulty constructor when using the Azure OpenAI Deployments. ```typescript this.chatOpenAI = new ChatOpenAI({ model: this.modelName, azureOpenAIApiVersion: this.azureOpenAIVersion, azureOpenAIApiKey: this.azureOpenAIKey, azureOpenAIEndpoint: this.azureOpenAIEndpoint, azureOpenAIApiDeploymentName: this.deploymentName, }); ``` Correct Code ```Typescript this.chatOpenAI = new AzureChatOpenAI({ model: this.modelName, azureOpenAIApiVersion: this.azureOpenAIVersion, azureOpenAIApiKey: this.azureOpenAIKey, azureOpenAIEndpoint: this.azureOpenAIEndpoint, azureOpenAIApiDeploymentName: this.deploymentName, }); } ``` We detected after I manually added the `"@langchain/openai": "0.5.10",` to package.json which gave build error on the constructor which we fixed by using the `AzureChatOpenAI`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#260