1. Conduid
  2. AI
  3. Langchain MCP Connect
MCP server · AI

Langchain MCP Connect

Tools to easily integrate Anthropic Model Context Protocol(MCP) with Langchain

Unclaimed MIT last commit a year ago ai
54Fair

Scored 3 days ago · breakdown

About Langchain MCP Connect

Langchain MCP Connect is an MCP server published by lloydhamilton in the AI category: tools to easily integrate Anthropic Model Context Protocol(MCP) with Langchain.

The repository has 17 stars and 3 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.

Install

From source
git clone https://github.com/lloydhamilton/langchain_mcp_connect

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Ask AI

✦

Ask AI about Langchain MCP Connect

Powered by Claude · Grounded in docs

I know everything about Langchain MCP Connect. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

Static checks derived from the repository 5 days ago. Heuristics on the source, not an audit.

  • ✓README presentThe repository ships documentation.
  • ✓License declaredUsable under a stated license.
  • ✓Tests presentA test suite exists in the repository.
  • ✓Dependencies pinnedA lockfile pins dependency versions.
  • ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
  • !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.

Releases

v2.2.0Release v2.2.0 · 17 Feb 2025What's Changed Add support for SSE server parameters in MCP clients by @ahlner in https://github.com/lloydhamilton/langchain_mcp_connect/pull/2 New Contributors @ahlner made their first contribution in…
v2.1.1Release v2.1.1 · 8 Feb 2025Full Changelog: https://github.com/lloydhamilton/langchain_mcp_connect/compare/v2.1.0...v2.1.1
v2.1.0Release v2.1.0 · 8 Feb 2025What's Changed Add synchronous tool execution by @lloydhamilton in https://github.com/lloydhamilton/langchain_mcp_connect/pull/1 New Contributors @lloydhamilton made their first contribution in…
v2.0.5Release v2.0.5 · 27 Jan 2025Full Changelog: https://github.com/lloydhamilton/langchain_mcp_connect/compare/v2.0.4...v2.0.5
v2.0.4Release v2.0.4 · 27 Jan 2025Full Changelog: https://github.com/lloydhamilton/langchain_mcp_connect/compare/v2.0.3...v2.0.4

README

build status GitHub Release

Introduction

This project introduces tools to easily integrate Anthropic Model Context Protocol(MCP) with langchain. It provides a simple way to connect to MCP servers and access tools that can be made available to LangChain. Most importantly, langchain-mcp-connect allows developers to easily integrate their LLMs with a rich ecosystem of pre-built MCP servers.

MCP integrations with langchain expands the capabilities of LLM by providing access to community servers and additional resources. This means that we do not need to create custom tools for each LLM, but rather use the same tools across different LLMs.

Installation

pip install langchain-mcp-connect

What is the Model Context Protocol (MCP)?

The Model Context Protocol (MCP) is an open-source standard released by Anthropic. The Model Context Protocol highlights the importance of tooling standardisation through open protocols. Specifically, it standardises how applications interact and provide context to LLMs. Just like how HTTP standardises how we communicate across the internet, MCP provides a standard protocol for LLM to interact with external tools. You can find out more about the MCP at https://github.com/modelcontextprotocol and https://modelcontextprotocol.io/introduction.

Example usage

The langchain_mcp_connect contain key methods to connect MCP server tools to LangChain. Before starting, please ensure you meet the pre-requisites. For a detailed example on how langchain_mcp_connect can be used, see this demo project.

Defining a tool

Define your tool within claude_mcp_config.json file in the root directory. For a list of available tools and how to configure tools see here.

langchain_mcp_connect supports both stdio and HTTP with Server-Sent Events (SSE) protocols.

{
  "mcpServers": {
    "git": {
      "command": "uvx",
      "args": ["mcp-server-git", "--repository", "./"]
    },
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "./"
      ]
    },
    "github": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ENV_GITHUB_PERSONAL_ACCESS_TOKEN"
      }
    },
    "sseService": {
      "url": "http://localhost:8000/sse"
    }
  }
}

Environment Variables

Managing secrets is a key aspect of any project. The langchain_mcp_connect tool is able to inject secrets from the current environment. To do so, prefix the name of your environment variable with ENV_ in claude_mcp_config.json to inject environment variables into the current context. In the example above, ensure you have defined GITHUB_PERSONAL_ACCESS_TOKEN in your current environment with:

export GITHUB_PERSONAL_ACCESS_TOKEN="<YOUR_TOKEN_HERE>"
export OPENAI_API_KEY="<YOUR_KEY_HERE>"

Running the example

You can find an example usage in the src/example/agent.py file. You will need to install uv.

uv run src/example/agent.py

Example code

import asyncio
import logging
import os

from dotenv import load_dotenv
from langchain_core.messages import HumanMessage
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

from langchain_mcp_connect import LangChainMcp

load_dotenv()

logging.basicConfig(level=logging.INFO)
log = logging.getLogger("LangChainMcp")

if "GITHUB_PERSONAL_ACCESS_TOKEN" not in os.environ:
    raise ValueError(
        "Please set the GITHUB_PERSONAL_ACCESS_TOKEN environment variable."
    )
if "OPENAI_API_KEY" not in os.environ:
    raise ValueError("Please set the OPENAI_API_KEY environment variable.")


if __name__ == "__main__":

    QUERY = "What tools do you have access to?"

    # Define the llm
    llm = ChatOpenAI(
        model="gpt-4o",
        model_kwargs={
            "max_tokens": 4096,
            "temperature": 0.0,
        },
    )

    # Fetch tools
    mcp = LangChainMcp()
    tools = mcp.list_mcp_tools()

    # Bind tools to the agent
    agent_executor = create_react_agent(llm, tools)
    human_message = dict(messages=[HumanMessage(content=QUERY)])
    
    # Run the agent asynchronously
    response = asyncio.run(
        agent_executor.ainvoke(input=human_message)
    )

    log.info(response)

README fetched from the repository 5 days ago. The original is authoritative.

Questions

About Langchain MCP Connect

How do I install Langchain MCP Connect?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Langchain MCP Connect safe to use with an AI agent?

Its trust score is 54 out of 100 (fair). It passes 5 of the 6 static security checks run so far; the failures are listed above. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Langchain MCP Connect still maintained?

The last commit was a year ago. That's long enough that you should check whether the maintainer is responding to issues before depending on it.