# mcp-client-langchain-py

> MCP Client

This repository provides a Python-based Model Context Protocol (MCP) client using LangChain, enabling interaction with MCP servers through LangChain ReAct Agent and supporting LLMs from Anthropic, OpenAI, and Groq.

## Overview

- **Category:** AI
- **Language:** Python
- **Stars:** 13
- **Forks:** 2
- **Owner:** hideya
- **GitHub:** https://github.com/hideya/mcp-client-langchain-py
- **Created:** 2025-01-12T18:28:40+00:00
- **Updated:** 2025-03-27T06:12:28+00:00
- **Source:** https://model-context-protocol.com/clients/mcp-client-langchain-python-llm-interaction

## Setup

## Setup

1. Install dependencies:
    ```bash
    make 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.  `convert_mcp_to_langchain_tools()` (Utility function to handle parallel initialization of MCP servers and convert their tools into LangChain-compatible tools.)
2.  LangChain ReAct Agent (Demonstrates the use of MCP server tools.)
3.  Support for LLMs from Anthropic, OpenAI and Groq (Allows using different LLMs.)

