LangChain (Python)
Connect a LangChain agent to Leadovaro using leadovaro-mcp-client. The langchain() adapter returns tool schemas ready to bind to any ChatModel, with a helper for executing tool calls.
Prerequisites
- Python 3.11+
- A Leadovaro account at app.leadovaro.com with a configured toolkit
- A Leadovaro token and an LLM API key (e.g. Anthropic)
Installation
pip install "leadovaro-mcp-client[langchain]" langchain-anthropic python-dotenv
Environment Variables
LEADOVARO_TOKEN=your-leadovaro-token
ANTHROPIC_API_KEY=your-anthropic-key
How to generate a Leadovaro token and configure toolkit URL parameters
Connecting to Leadovaro
Use LeadovaroMCPClient with the langchain() adapter to get tool schemas, bind them to a model, then use execute_langchain_tool_call to execute tool calls from the model's response:
import asyncio
import os
from dotenv import load_dotenv
from leadovaro_mcp_client import LeadovaroMCPClient
from leadovaro_mcp_client.adapters.langchain import execute_langchain_tool_call, langchain
from langchain_anthropic import ChatAnthropic
from langchain_core.messages import HumanMessage, ToolMessage
load_dotenv()
async def main():
client = LeadovaroMCPClient(auth={"token": os.environ["LEADOVARO_TOKEN"]})
tool_schemas = await client.adapt_for(langchain())
model = ChatAnthropic(model="claude-sonnet-4-6").bind_tools(tool_schemas)
messages = [HumanMessage(content="What events do I have today?")]
while True:
response = await model.ainvoke(messages)
messages.append(response)
if not response.tool_calls:
break
for tool_call in response.tool_calls:
result = await execute_langchain_tool_call(client, tool_call)
messages.append(ToolMessage(
content=str(result),
tool_call_id=tool_call["id"],
))
print(messages[-1].content)
await client.close()
asyncio.run(main())
Production Configuration
Lock to a Toolkit
For production agents, scope to a specific toolkit:
client = LeadovaroMCPClient(
auth={"token": os.environ["LEADOVARO_TOKEN"]},
leadovaro_profile=os.environ.get("LEADOVARO_PROFILE_ID"),
)
When a profile is specified, the session is locked by default — the agent cannot switch toolkits or modify its own guardrails. This prevents prompt injection attacks from escaping the defined tool scope.
Reference Implementation
Complete implementation with FastAPI chat UI, streaming responses, and production patterns
Next Steps
JavaScript LangGraph integration using @civic/mcp-client
Production deployment guide: profile locking, URL params, authentication
Constrain what tools your LangGraph agent can use
Query what your agent did via Leadovaro Chat
Token generation and URL parameter reference