LangChain Tools

v1.0.0Developer Toolsstable

MCP to LangChain Tools Conversion Utility / Python

langchainlangchain-pythonmcpmcp-clientmodelcontextprotocol
Share:
28
Stars
0
Downloads
0
Weekly
0/5

What is LangChain Tools?

LangChain Tools is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcp to langchain tools conversion utility / python

MCP to LangChain Tools Conversion Utility / Python

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • MCP to LangChain Tools Conversion Utility / Python

Use Cases

Convert MCP tools to LangChain tools for Python applications.
Enable seamless integration between MCP and LangChain ecosystems.
hideya

Maintainer

LicenseMIT
Languagepython
Versionv1.0.0
UpdatedApr 13, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx langchain-mcp-tools-py

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use LangChain Tools

langchain-mcp-tools is a Python utility library that converts MCP (Model Context Protocol) server tools into native LangChain BaseTool objects, letting you plug any MCP-compatible tool server directly into LangChain agents and chains without writing adapter code. It supports local stdio servers, remote HTTP/SSE endpoints, and WebSocket transports, and handles connection lifecycle management through a returned async cleanup callback. Python developers building LangChain agents can use this library to tap into the growing ecosystem of MCP tool servers — file systems, web search, databases — with a single function call.

Prerequisites

  • Python 3.9 or later
  • pip or a compatible package manager
  • LangChain (langchain or langchain-core) installed in your environment
  • At least one MCP server to connect to (e.g. npx @modelcontextprotocol/server-filesystem)
  • An LLM API key (e.g. ANTHROPIC_API_KEY or OPENAI_API_KEY) for your LangChain agent
1

Install the library

Install langchain-mcp-tools from PyPI using pip. It will pull in the MCP client SDK as a dependency.

pip install langchain-mcp-tools
2

Define your MCP server configurations

Create a dictionary mapping server names to their connection parameters. Local servers use command and args; remote servers use url; add env for any API keys required by those servers.

mcp_servers = {
    "filesystem": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
    },
    "brave-search": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-brave-search"],
        "env": {"BRAVE_API_KEY": os.environ["BRAVE_API_KEY"]}
    }
}
3

Convert MCP tools to LangChain tools

Call convert_mcp_to_langchain_tools with your server config inside an async function. It returns a list of BaseTool objects and a cleanup coroutine you must call when finished.

from langchain_mcp_tools import convert_mcp_to_langchain_tools

async def main():
    tools, cleanup = await convert_mcp_to_langchain_tools(mcp_servers)
    try:
        # use tools here
        pass
    finally:
        await cleanup()
4

Build a LangChain agent with the tools

Pass the converted tools to any LangChain agent constructor. The tools behave like any other BaseTool and are callable by the agent's reasoning loop.

from langchain import hub
from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(model="claude-3-5-sonnet-20241022")
prompt = hub.pull("hwchase17/openai-tools-agent")
agent = create_tool_calling_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
result = await executor.ainvoke({"input": "List files in the current directory"})
5

Run cleanup after the agent finishes

Always call the cleanup function to gracefully shut down MCP server connections and free resources. Wrapping your code in try/finally ensures cleanup runs even if an exception occurs.

LangChain Tools Examples

Client configuration

Complete async script showing MCP tool conversion and agent execution with LangChain.

{
  "mcp_servers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
    },
    "brave-search": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-brave-search"],
      "env": {"BRAVE_API_KEY": "your_brave_api_key"}
    }
  }
}

Prompts to try

Example agent inputs once your LangChain agent is running with MCP tools loaded.

- "List all Python files in the current directory"
- "Read the contents of README.md and summarise it"
- "Search the web for the latest LangChain release notes"
- "Write a haiku to a new file called haiku.txt"
- "What MCP tools are currently available to you?"

Troubleshooting LangChain Tools

MCP server subprocess fails to start

Ensure npx and Node.js are installed and accessible. The library automatically injects PATH into the subprocess environment, but if a custom env dict is provided, PATH must be included explicitly.

Tool calls return errors about unsupported result types

The library only supports text results from MCP tool calls. MCP servers that return binary data, images, or resources will not work. MCP Resources, Prompts, and Sampling features are not implemented.

Connection timeout when using remote HTTP servers

Set the timeout key in the server config dictionary (e.g. {"url": "https://...", "timeout": 60}) to extend the connection timeout beyond the default.

Frequently Asked Questions about LangChain Tools

What is LangChain Tools?

LangChain Tools is a Model Context Protocol (MCP) server that mcp to langchain tools conversion utility / python It connects AI assistants to external tools and data sources through a standardized interface.

How do I install LangChain Tools?

Follow the installation instructions on the LangChain Tools GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with LangChain Tools?

LangChain Tools works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is LangChain Tools free to use?

Yes, LangChain Tools is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "langchain-mcp-tools-py": { "command": "npx", "args": ["-y", "langchain-mcp-tools-py"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use LangChain Tools?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides