Skip to content

Conversation

ZhongpinWang
Copy link
Contributor

Context

Relates to #1145.

Relates to SAP/ai-sdk-js-backlog#374

What this PR does and why it is needed

The first part is about switching from using zod/v4 to zod/v3 with [email protected] package in sample-code/src/tutorials/mcp/weather-mcp-server.ts since @modelcontextprotocol/sdk does not even support zod/v4 from [email protected] due to the outdated zod dependency.

modelcontextprotocol typescript sdk is working on supporting [email protected] package directly. See modelcontextprotocol/typescript-sdk#869.

The second part is to add a new sample-code show-casing how to use LangChain's MCP adapter with pure LangChain bindTools() without LangGraph. (as requested in #1145).

@ZhongpinWang ZhongpinWang changed the title fix: Use zod/v3 in Agent tutorial and add plain LangChain MCP sample code chore: Use zod/v3 in Agent tutorial and add plain LangChain MCP sample code Oct 7, 2025
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import * as z from 'zod/v4';
import * as z from 'zod/v3';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/modelcontextprotocol/typescript-sdk/blob/e0de0829019a4eab7af29c05f9a7ec13364f121e/package.json#L75 This zod version is outdated and does not support zod/v4 feature and is not compatible with our latest [email protected] package.

new HumanMessage('What is the weather like in Berlin?')
];

const response = await client.bindTools(tools).invoke(messages);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pp] We could just use getMcpTools here since it returns an array anyway, no point creating a copy of the same array

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, initially I was doing this, but I need to access tools[0] later again to invoke the actual function, thus, I extracted this out, otherwise we call getMcpTools() twice.

Copy link
Contributor

@deekshas8 deekshas8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor comment, else LGTM 🚀

@ZhongpinWang ZhongpinWang merged commit b5e7aee into main Oct 8, 2025
13 checks passed
@ZhongpinWang ZhongpinWang deleted the chore-add-mcp-with-plain-langchain branch October 8, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants