MCPInstall
langchain-mcp-tools-ts-usage logo

langchain-mcp-tools-ts-usage

by hideya 12 stars hideya/langchain-mcp-tools-ts-usage

A Simple MCP Client Implementation Using LangChain / TypeScript

READMEmain

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

OpenAI's gpt-5.4-mini 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] npm 7+ (npx) to run Node.js package-based local MCP servers
  • [optional] uv (uvx) installed to run Python-based MCP servers
  • LLM API keys from OpenAI, Anthropic, Google GenAI, and/or xAI 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
    

License

MIT

More Developer Tools MCP servers

Similar servers from the same category.

Sourcebot

sourcebot-dev

Enables code search across multiple repository hosts including GitHub, GitLab, Gitea, Gerrit, and Bitbucket with advanced filtering options for exploring large codebases through natural language queries.

searchgit

CodeAlive

codealive-ai

Provides a bridge to CodeAlive's platform for semantic code search, repository exploration, and context-aware chat completions that leverage deep understanding of entire codebases including documentation and dependencies.

search

Provides a secure, sandboxed environment for executing Python, Node.js, and shell commands in ephemeral containers with file management capabilities for code testing, visualization, and data analysis.

filesystemdatabase

NovaCV

lightbaby

Integrates with NovaCV API to generate, analyze, and convert resumes in various formats without dealing with complex document formatting

PDFSupport+5