Why connect LangChain to Odoo?
LangChain is where you build AI agents; Odoo is where your business data lives. If you want an agent that can answer questions about real sales orders, open invoices, stock levels, or CRM pipeline — instead of hallucinating — it needs live access to the ERP. This guide shows how to connect LangChain to Odoo through the Model Context Protocol (MCP), so a LangChain Odoo agent can read and query your data directly.
The question "how to connect Odoo to LangChain" usually ends in a pile of custom XML-RPC glue. MCP removes that. LangChain supports MCP tools natively via the langchain-mcp-adapters package, so once Odoo exposes an MCP endpoint, your agent discovers the available tools automatically — the same open standard Claude, Cursor, and other clients already speak.
The result is a clean Odoo LangChain integration: your agent gets structured, governed access to live Odoo records, and you skip building and maintaining a bespoke API layer.
The approach: LangChain consumes Odoo MCP tools
MCP is a standard way to expose tools to AI agents. An Odoo MCP endpoint publishes tools such as search_records, get_record, and describe_model. On the LangChain side, langchain-mcp-adapters' MultiServerMCPClient connects to that endpoint and turns those into native LangChain tools your agent can call.
You just need an Odoo MCP endpoint to point at. KSROlabs provides two, depending on how your Odoo is hosted — a self-hosted native module and a purpose-built gateway for Odoo Online. Both expose the same LangChain Odoo MCP tools, so your agent code is identical either way.
Step-by-step: build a LangChain Odoo agent
Follow these 5 steps to connect LangChain to your live Odoo instance via MCP.
Install LangChain and the MCP adapters
In your Python environment, install the LangChain packages plus langchain-mcp-adapters, which lets LangChain consume any MCP server as a set of tools: pip install langchain langgraph langchain-mcp-adapters. You will also want an LLM provider package (for example langchain-openai or langchain-anthropic) for the agent model.
Get an Odoo MCP endpoint and a scoped API key
Expose an MCP endpoint over your Odoo data. Self-hosted, Odoo.sh, and on-prem instances use the KSROlabs MCP Server module, which adds an endpoint under Settings → MCP Server. Odoo Online (*.odoo.com) instances use the KSROlabs Odoo Online MCP Gateway. Either way you create a scoped, read-only-by-default API key and copy the bearer token — it is shown once.
Point MultiServerMCPClient at your Odoo MCP server
Configure langchain-mcp-adapters MultiServerMCPClient with your Odoo MCP endpoint URL and the Authorization: Bearer <token> header. Use the streamable_http transport for a remote endpoint. The client handles the MCP handshake and discovers the Odoo tools automatically.
Load the Odoo tools into your agent
Call await client.get_tools() to fetch the Odoo MCP tools (search_records, get_record, describe_model, and any write tools your key allows) as native LangChain tools. Pass that list straight into a LangGraph or LangChain agent — no custom wrappers or hand-written API clients required.
Build and run the LangChain Odoo agent
Create a ReAct-style agent with create_react_agent(model, tools) and invoke it with a natural-language question such as "What were our top five customers by revenue last quarter?" The agent decides which Odoo MCP tools to call, runs them against live data, and returns a grounded answer.
Putting it together, a minimal LangChain Odoo agent looks like this:
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
# 1. Point LangChain at your Odoo MCP endpoint
client = MultiServerMCPClient({
"odoo": {
"transport": "streamable_http",
"url": "https://your-odoo.com/mcp/v1",
"headers": {"Authorization": "Bearer <your-scoped-token>"},
}
})
# 2. Discover Odoo tools exposed over MCP
tools = await client.get_tools()
# 3. Build a LangChain agent that can use them
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools)
# 4. Ask a question over live Odoo data
result = await agent.ainvoke({
"messages": "List our five most recent confirmed sale orders."
})
print(result["messages"][-1].content)Swap the model for any LangChain-supported LLM, and swap the endpoint URL for your MCP Server or Odoo Online MCP Gateway address. The agent handles tool selection on its own.
Two hosting paths for your Odoo MCP endpoint
How you expose Odoo over MCP depends on how Odoo is hosted. LangChain connects to either the same way:
Self-hosted, Odoo.sh & on-prem → MCP Server module
If you can install custom modules, the native KSROlabs MCP Server for Odoo runs the MCP endpoint inside your instance. It adds a Settings → MCP Server panel for endpoints, scoped API keys, and model permissions — ideal for on-prem and Odoo.sh deployments.
Odoo Online (*.odoo.com) → Odoo Online MCP Gateway
Odoo Online (SaaS) blocks custom modules, so the purpose-built KSROlabs Odoo Online MCP Gateway sits outside Odoo and exposes a compliant MCP endpoint for your tenant — a commercial, managed service with no module install required.
Read more on each path: the native Odoo MCP Server module for self-hosted and on-prem Odoo, or the Odoo Online MCP Gateway for *.odoo.com SaaS tenants.
What you can build with a LangChain Odoo agent
Once your agent has live Odoo tools, you can build agentic workflows over ERP data:
Conversational ERP analytics
Let staff ask "What did revenue look like by region last quarter?" and have the agent query live sale.order and account.move records instead of exporting spreadsheets.
Invoice & AR triage
Have the agent surface overdue invoices, summarise the largest open balances, and draft follow-up notes — grounded in real account.move data.
Inventory & fulfilment checks
Ask the agent about stock levels, backorders, or slow-moving SKUs and let it read stock.quant and related models before it answers.
CRM co-pilot workflows
Feed a LangGraph agent your CRM pipeline so it can prioritise leads, summarise account history, and suggest next actions from live crm.lead data.
Keeping the agent's access governed
An autonomous agent with ERP access needs guardrails. The Odoo MCP endpoint is designed for this: every connection uses a scoped API key, keys are read-only by default, and write access is granted per model only when you explicitly enable it. For a LangChain agent, give it a dedicated least-privilege key limited to the models it actually needs.
Bearer tokens can be rotated or revoked at any time, and requests are logged so you keep an audit trail of what the agent read or changed. That means you can adopt an Odoo LangChain integration without handing an LLM unrestricted access to your database.
Frequently asked questions
Can I connect LangChain to Odoo?
Yes. LangChain can connect to Odoo through the Model Context Protocol (MCP). Using the langchain-mcp-adapters package, you point LangChain at an Odoo MCP endpoint and it loads Odoo tools your agent can call. The KSROlabs MCP Server (for self-hosted, Odoo.sh, and on-prem Odoo) or the Odoo Online MCP Gateway (for *.odoo.com) provides that endpoint, so no custom XML-RPC client is needed.
How does LangChain use Odoo via MCP?
MCP is an open standard for exposing tools to AI agents. The Odoo MCP endpoint publishes tools such as search_records, get_record, and describe_model. langchain-mcp-adapters turns those into native LangChain tools, and your LangChain or LangGraph agent decides when to call them. When a user asks a question, the agent invokes the right Odoo MCP tool, reads the live result, and reasons over it — the same protocol Claude, Cursor, and other MCP clients use.
Does it work with Odoo Online (SaaS)?
Yes. Odoo Online (*.odoo.com) instances cannot install custom modules, so they use the KSROlabs Odoo Online MCP Gateway — a purpose-built external gateway that exposes a compliant MCP endpoint for your SaaS tenant without touching the Odoo codebase. Self-hosted, Odoo.sh, and on-prem instances use the native MCP Server module instead. LangChain connects to either the same way.
Is it secure?
Security is scoped per API key. Each key is limited to the specific Odoo models it may read, keys are read-only by default, and write access is opt-in per model. Tokens are bearer credentials you can rotate or revoke at any time, and requests are logged for audit. For a LangChain agent, the recommended pattern is a dedicated, least-privilege key scoped to only the models the agent needs.
How do I get it, and what does it cost?
For self-hosted, Odoo.sh, and on-prem Odoo, purchase the KSROlabs MCP Server module from the Odoo App Store; it is a paid product and free setup support is included. For Odoo Online (SaaS), the Odoo Online MCP Gateway is a paid, commercial subscription — contact KSROlabs to get set up and to discuss pricing for your tenant. Both give LangChain the same MCP endpoint to build agents against.
Do I need to write a custom Odoo API client for LangChain?
No. That is the point of the MCP approach. Without MCP you would hand-write XML-RPC or REST wrappers and register each as a LangChain tool. With the Odoo MCP endpoint, langchain-mcp-adapters discovers the available tools automatically and hands them to your agent, so you focus on the agent logic rather than plumbing.