Building Advanced Agents: Integrating MCP Servers
93%
LangChain and MCP
LangChain has support for MCP clients, but we need to add the langchain-mcp-adapters package. This library provides a lightweight wrapper that makes MCP tools compatible with LangChain.
[project]
name = "repl"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"chromadb==1.5.9",
"langchain==1.2.18",
"langchain-core==1.4.0",
"langchain-mcp-adapters==0.2.2",
"langchain-ollama==1.1.0",
"langchain-redis==0.2.5",
"mem0ai[nlp]==2.0.0",
"ollama==0.6.2",
"python-dotenv==1.2.2",
]
# [.. truncated ..]
This is a simple generic example showing how LangChain connects and uses MCP tools.
async def main():
client = MultiServerMCPClient(
{
"math": {
"transport":Local AI Engineering with Ollama
Run, understand, customize, fine-tune, and build agentic apps on your own hardwareEnroll now to unlock all content and receive all future updates for free.
