# mcp-client-langchain-ts

> MCP Client

This repository provides a TypeScript-based Model Context Protocol (MCP) client that integrates with LangChain ReAct Agent, enabling interaction with LLMs like Anthropic, OpenAI, and Groq through MCP servers.

## Overview

- **Category:** AI
- **Language:** TypeScript
- **Stars:** 13
- **Forks:** 0
- **Owner:** hideya
- **GitHub:** https://github.com/hideya/mcp-client-langchain-ts
- **Created:** 2024-12-31T13:54:03+00:00
- **Updated:** 2025-03-28T02:38:52+00:00
- **Source:** https://model-context-protocol.com/clients/typescript-langchain-mcp-client-react-agent

## Setup

## Setup
1. Install dependencies:
    ```bash
    npm install
    ```

2. Setup API keys:
    ```bash
    cp .env.template .env
    ```
    - Update `.env` as needed.
    - `.gitignore` is configured to ignore `.env`
      to prevent accidental commits of the credentials.

3. Configure LLM and MCP Servers settings `llm_mcp_config.json5` as needed.

    - [The configuration file format](https://github.com/hideya/mcp-client-langchain-ts/blob/main/llm_mcp_config.json5)
      for MCP servers follows the same structure as
      [Claude for Desktop](https://modelcontextprotocol.io/quickstart/user),
      with one difference: the key name `mcpServers` has been changed
      to `mcp_servers` to follow the snake_case convention
      commonly used in JSON configuration files.
    - The file format is [JSON5](https://json5.org/), where comments and trailing commas are allowed.
    - The format is further extended to replace `${...}` notations with the values of corresponding environment variables.
    - Keep all the credentials and private info in the `.env` file and refer to them with `${...}` notation as needed.

## Tools

## Available Tools

1.  `convertMcpToLangchainTools()` (Handles parallel initialization of specified multiple MCP servers and converts their available tools into an array of LangChain-compatible tools).
2.  LangChain ReAct Agent (Demonstrates the use of MCP server tools).
3.  LLMs from Anthropic, OpenAI and Groq (Currently supported).
