hideya
MCP Serverhideyapublic

langchain mcp tools ts usage

MCP Tools Usage From LangChain ReAct Agent / Example in TypeScript

Repository Info

11
Stars
2
Forks
11
Watchers
0
Issues
TypeScript
Language
MIT License
License

About This Server

MCP Tools Usage From LangChain ReAct Agent / Example in TypeScript

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

MCP Tools Usage From LangChain / Example in TypeScript License: MIT

This simple Model Context Protocol (MCP) client demonstrates the use of MCP server tools by LangChain ReAct Agent.

It leverages a utility function convertMcpToLangchainTools() from @h1deya/langchain-mcp-tools.
This function handles parallel initialization of specified multiple MCP servers and converts their available tools into an array of LangChain-compatible tools (StructuredTool[]). It also performs LLM provider-specific schema transformations to prevent schema compatibility issues

Google GenAI's gemini-2.5-flash is used as the LLM. For convenience, code for OpenAI's and Anthropic's LLMs are also included and commented out.

A bit more realistic (conversational) MCP Client is available here

A python equivalent of this app is available here

Prerequisites

  • Node.js 18+
  • npm 8+ (npx) to run Node.js-based MCP servers
  • [optional] uv (uvx) installed to run Python-based MCP servers
  • LLM API keys from OpenAI, Anthropic, and/or Google GenAI as needed

Usage

  1. Install dependencies:

    npm install
    
  2. Setup API key:

    cp .env.template .env
    
    • Update .env as needed.
    • .gitignore is configured to ignore .env to prevent accidental commits of the credentials.
  3. Run the app:

    npm start
    

Simple Exapmle Code for Streamable HTTP Authentiocation

A simple example of showing how to implement an OAuth client provider and use it with the langchain-mcp-tools library can be found in src/streamable-http-auth-test-client.ts.

For testing purposes, a sample MCP server with OAuth authentication support that works with the above client is provided in src/streamable-http-auth-test-server.ts.

You can run the server with npm run test:streamable:server and the client with npm run test:streamable:client.

Quick Start

1

Clone the repository

git clone https://github.com/hideya/langchain-mcp-tools-ts-usage
2

Install dependencies

cd langchain-mcp-tools-ts-usage
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerhideya
Repolangchain-mcp-tools-ts-usage
LanguageTypeScript
LicenseMIT License
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation