This repository showcases a simple Model Context Protocol (MCP) client using LangChain and TypeScript, demonstrating how to convert MCP server tools into LangChain-compatible tools for use with LLMs like Anthropic's Claude.
This project demonstrates a simple Model Context Protocol (MCP) client using LangChain and TypeScript. It showcases how to integrate MCP server tools with a LangChain ReAct Agent.
The core functionality relies on the convertMcpToLangchainTools()
utility from the @h1deya/langchain-mcp-tools
package. This function initializes multiple MCP servers in parallel and converts their tools into an array of LangChain-compatible StructuredTool[]
.
The client uses Anthropic's claude-3-5-sonnet-latest
as the default LLM, with commented-out code provided for OpenAI's gpt-4o
. The repository also points to a more conversational MCP client and a Python equivalent for broader use cases.
To use this project, you'll need Node.js 16+, npm 7+, and optionally uv
for Python-based MCP servers. An API key from Anthropic (or OpenAI) is also required. After installing dependencies and setting up the API key in the .env
file, you can run the app using npm start
.
hideya/langchain-mcp-tools-ts-usage
January 6, 2025
March 28, 2025
TypeScript