Skip to main content

LangChain Integration

Use all DialogBrain tools in a LangChain agent with langchain-mcp-adapters.

Install

pip install "dialogbrain[langchain]"

Usage

import asyncio
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from dialogbrain import get_langchain_tools

async def main():
llm = ChatOpenAI(model="gpt-4o")

async with get_langchain_tools(api_key="db_live_YOUR_KEY") as tools:
agent = create_react_agent(llm, tools)
result = await agent.ainvoke({
"messages": [{"role": "user", "content": "List my recent conversations"}]
})
print(result["messages"][-1].content)

asyncio.run(main())

How It Works

get_langchain_tools() connects to https://api.dialogbrain.com/mcp using langchain-mcp-adapters and fetches the live tool list. When new tools are added to DialogBrain, they appear automatically — no SDK update needed.