T

langchain-mcp-tools-ts-usage

...
Created 1/6/2025byhideya

Categories

langchainlangchain-typescriptmcpmcp-clientmodelcontextprotocolnodejstool-callingtypescript

Language:

TypeScript

Stars:

8

Forks:

1

Simple MCP Client Using LangChain / 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[]).

Anthropic's claude-3-5-sonnet-latest is used as the LLM. For convenience, code for OpenAI's gpt-4o is 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 16+
  • npm 7+ (npx) to run Node.js-based MCP servers
  • [optional] uv (uvx) installed to run Python-based MCP servers
  • API key from Anthropic (or OpenAI)

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
    
Last updated: 2/21/2025

Publisher info

hideya's avatar

hideya

self-employed
tokyo
23
followers
8
following
92
repos

More MCP servers built with TypeScript

docbase-mcp-server

MCP Server Implementation for DocBase

By f4401
aapi-mcp-server

Advanced API MCP Server

By Asphere-xyz1
DBX-MCP-Server

MCP Server for Dropbox

By amgadabdelhafez1