Pragmatic – Leading provider of open source business applications OpenERP, Ruby on Rails, Node.js, Talend, jaspersoft  – Pragmatic
Beyonce Adams

Implementing MCP for Odoo: How to Plug Your Odoo Data into ChatGPT, Claude, and Gemini

TL;DR

Model Context Protocol (MCP) is like a USB-C port for AI—a standard that lets ChatGPT/Claude/Gemini discover and use tools and data sources at runtime. With Odoo, that means AI can:

  • Read records (e.g., leads, stock, invoices),
  • Reason with context (RAG on Odoo data, attachments), and
  • Act (create quotations, post journal entries) under policies, approvals, and audit logs.

This guide shows you how to wire up Odoo + MCP using the LLM Integration Base, AI Chatbot with MCP Tools, and optional LLM RAG modules—plus reference code for an MCP server that exposes safe Odoo actions.

Who is this for?

  • Odoo partners and in-house teams shipping AI features fast
  • IT leaders who need AI inside business workflows without brittle, one-off APIs
  • Security/compliance teams who want guardrails, audit, and least-privilege access

What is MCP (and why Odoo teams care)?

Model Context Protocol (MCP) is an open standard that lets AI apps dynamically discover and invoke tools, stream context, and keep two-way, policy-enforced conversations with your systems.
Compared with one-off API integrations, MCP reduces dev time (fewer bespoke wrappers), improves runtime flexibility (AI can find new tools without new code), and centralizes policy (who can call what, when, and how).

Core advantages for Odoo:

  • Dynamic discovery: New tools (e.g., “create_quotation”) appear instantly to the AI.
  • Two-way comms: AI can pull Odoo data and push actions (with approvals).
  • Unified control: Access, rate limits, logging, and safety policies in one place.

Architecture Overview

Prerequisites

Platform & modules

  • Odoo (v17–19) with:
    • LLM Integration Base (multi-provider LLM support, chat completions, embeddings, tool exec)
    • AI Chatbot with MCP Tools (chat UI, MCP client support, per-user memory, streaming, file Q&A)
    • LLM RAG (collections, embeddings, semantic search across Odoo data)

Runtime

  • Node.js (required for MCP clients in some setups)
  • Python environment with libraries mentioned in your stack, e.g.:
    • fastembed (embeddings)
    • langchain_openai, langchain_anthropic, langchain_google_genai
    • (If you’re building servers) an MCP server SDK such as fastmcp or an equivalent
  • LLM access: OpenAI (GPT), Anthropic (Claude), Google Gemini and/or Ollama for local/open-source models

Security & secrets

  • API keys stored securely (Odoo system parameters / vault)
  • SSO/RBAC in Odoo; service accounts for server-to-server calls
  • Network allowlists if self-hosting

Step-by-Step Implementation

1) Install & enable Odoo AI modules

  1. Install LLM Integration Base → gives you:
    • Multiple provider support (OpenAI/Claude/Gemini/Ollama/Replicate) through one interface
    • Model discovery (fetch available models)
    • Tool execution framework (the “hooks” AI uses to act in Odoo)
  2. Install AI Chatbot with MCP Tools → adds:
    • In-Odoo chat, MCP client support, streaming output
    • Per-user conversation memory
    • File Q&A on PDF, CSV, XLSX, JSON, TXT attachments
  3. (Optional) Install LLM RAG → create collections, embed Odoo records, enable semantic search.

Tip: Keep modules version-aligned with your Odoo and pin Python packages for reproducibility.

2) Configure LLM providers & guardrails

  • In Settings → AI/LLM choose providers (OpenAI, Anthropic, Google) and models.
  • Set max tokens, temperature, and rate limits per role.
  • Turn on action approvals for sensitive tools (e.g., posting journal entries).

Enable audit logs for prompts, tool calls, and responses (compliance ready).

3) Add Retrieval (RAG) for Odoo context

  • Define collections (e.g., CRM Notes, Product Specs, SOPs, Vendor SLAs).
  • Choose embedding model via fastembed (fast, local-friendly) or a provider.
  • Index Odoo records and attachments (PDF, DOCX exported to text).
  • Expose a search tool to the AI so it can cite sources and ground answers.

4) Publish Odoo capabilities as MCP tools

You can expose Odoo safely via an MCP server that defines tools (read & write) and applies policies. Below is a minimal Python sketch (conceptual) for an MCP server that talks to Odoo’s JSON-RPC:

# mcp_server_odoo.py (conceptual example)

import json, os, requests

from typing import Dict, Any

ODOO_URL = os.environ[“ODOO_URL”]      # e.g., https://erp.example.com

ODOO_DB  = os.environ[“ODOO_DB”]       # database name

ODOO_USER= os.environ[“ODOO_USER”]     # service user

ODOO_PWD = os.environ[“ODOO_PWD”]

def jsonrpc(path, method, params):

    url = f”{ODOO_URL}/jsonrpc”

    payload = {“jsonrpc”:”2.0″,”method”:”call”,”params”:params,”id”:1}

    r = requests.post(url, json=payload, timeout=30)

    r.raise_for_status()

    return r.json()[“result”]

def odoo_execute_kw(model, method, args=None, kwargs=None):

    # Authenticate once, then use uid + session; simplified for illustration

    uid = jsonrpc(“/jsonrpc”,”call”,{

        “service”:”common”,”method”:”login”,

        “args”:[ODOO_DB, ODOO_USER, ODOO_PWD]

    })

    return jsonrpc(“/jsonrpc”,”call”,{

      “service”:”object”,”method”:”execute_kw”,

      “args”:[ODOO_DB, uid, ODOO_PWD, model, method, args or [], kwargs or {}]

    })

# — MCP Tool Handlers (examples) ——————————————

def get_partner_by_email(email:str)->Dict[str,Any]:

    ids = odoo_execute_kw(“res.partner”,”search”,[ [(“email”,”=”,email)] ], {“limit”:1})

    if not ids: return {“found”:False}

    rec = odoo_execute_kw(“res.partner”,”read”,[ids], {“fields”:[“name”,”email”,”phone”,”company_type”]})[0]

    return {“found”:True, “partner”:rec}

def create_quotation(partner_id:int, lines:list)->Dict[str,Any]:

    # Guardrail: only allow for B2B partners; approval required elsewhere

    order_id = odoo_execute_kw(“sale.order”,”create”,[{

        “partner_id”: partner_id,

        “order_line”:[(0,0,{“product_id”:l[“product_id”],”product_uom_qty”:l[“qty”]}) for l in lines]

    }])

    return {“created”:True, “sale_order_id”: order_id}

def get_stock_qty(product_id:int, location_id:int)->Dict[str,Any]:

    qty = odoo_execute_kw(“stock.quant”,”read_group”,[

        [(“product_id”,”=”,product_id),(“location_id”,”=”,location_id)],

        [“quantity:sum”],[“product_id”,”location_id”]

    ])

    total = qty[0][“quantity_sum”] if qty else 0

    return {“product_id”:product_id, “location_id”:location_id, “qty”: total}

# Register these with your MCP server framework (e.g., FastMCP) and add policy.

Design tips

  • Keep read tools granular (e.g., get_partner_by_email, get_open_invoices)
  • Keep write tools narrow and idempotent (e.g., create draft quotation only)
  • Enforce policy: who/what can call tools, with reason strings logged
  • Add approval hooks for actions beyond thresholds (amount, GL account, etc.)

5) Connect the client (ChatGPT/Claude/Gemini) to MCP

  • ChatGPT (Developer Mode): add your MCP server endpoint; ChatGPT will discover tools and ask for permission to use them.
  • Odoo Chatbot with MCP Tools: runs inside Odoo; configure MCP endpoints + which tools are visible to which roles.

Now your AI can say:

“Find the latest RFQ from Acme, draft a quotation for 50 units of P-100, and route it for approval if over ₹2L.”

…and the MCP layer orchestrates the calls with logs and guardrails.

6) Add File Q&A and Attachments

In the AI Chatbot with MCP Tools module, users can upload PDF/CSV/XLSX/JSON/TXT; the bot can summarize, extract tables, or join that context with Odoo (e.g., “Compare this vendor’s price sheet (CSV) with our last 3 POs”).

7) Test, UAT, and roll-out

  • Golden prompts per team (CRM, Sales, Inventory, Finance, MRP, HR)
  • Edge cases (no stock, blocked partners, tax mismatches)
  • Load & rate limits (burst traffic from many users)
  • Security drills (tool misuse simulations, audit review)

Example Prompts (copy-paste)

CRM

  • “Score this week’s new leads and draft personalised follow-ups for the top 10.”
  • “Show open opportunities by stage for Acme Group, highlight blockers.”

Sales

  • “Create a draft quotation for Acme for 40× P-100; apply standard tiered pricing and route to RSM West if total > ₹200,000.”

Inventory

  • “What’s the on-hand vs. forecast for P-100 next 30 days across WH/1 and WH/2? Propose a replenishment plan.”

Accounting

  • “List invoices with anomaly risk >0.8 and explain the drivers (amount spikes, vendor mismatch, due date anomalies).”

MRP

  • “Suggest an alternative component for BOM-42 given supplier lead time jumps. Recompute the schedule impact.”

HR

  • “Summarise 30/60/90 feedback for New Hire A and recommend a skill plan.”

Security, Governance, and Observability

  • Least privilege: Per-tool, per-role scopes (read vs. draft-write vs. post).
  • Human-in-the-loop: Approvals for high-impact actions; “dry-run mode” in UAT.
  • Content safety: Prompt policies, PII redaction for outbound context.
  • Audit & trace: Log prompts, tool calls, inputs/outputs, approver identity.
  • SLAs: Timeouts, retries, graceful degradation to read-only mode.
  • Cost control: Token budgets per role; caching for repetitive context pulls.

Measuring Value (KPIs)

  • Cycle time: Lead→Quote, PO→Receipt, Invoice→Post
  • Touch reduction: clicks/tasks automated per user per week
  • Forecast accuracy: demand & cash flow deltas after RAG adoption
  • Exception rates: anomalies found vs. false positives
  • Adoption: weekly active AI users, prompts per role, approved actions

Common Pitfalls & How to Avoid Them

  • Tool sprawl: Start with 6–10 high-value tools; grow deliberately.
  • Unbounded actions: Require draft-only writes at first; add posting later with approvals.
  • Messy data: Prioritise data cleanup (products, partners, taxes) before automation.
  • No guardrails: Enforce role scopes, rate limits, amount caps.
  • Opaque AI: Return explanations and citations (via RAG) to build trust.

Feature Map: Odoo Modules × AI Outcomes

  • LLM Integration Base → multi-provider LLMs, embeddings, tool execution
  • AI Chatbot with MCP Tools → chat UX, MCP client, file Q&A, streaming, memory
  • LLM RAG → semantic search grounded in Odoo records & attachments

Supported LLMs: OpenAI (GPT), Google Gemini, Anthropic Claude, plus open-source via Ollama/Replicate.
Files: PDF, CSV, XLSX, JSON, TXT (analyze and reference in answers).
Prereq for MCP clients: Node.js present in the environment.

Conclusion

With MCP + Odoo, your AI isn’t a sidecar—it’s a first-class operator: reading context, explaining decisions, and taking policy-controlled actions. Start small (read-only + RAG), add draft writes with approvals, then scale to cross-functional automations. The result is an intelligent ERP that is faster, safer, and measurably more effective. Want a tailored plan? Comment “Odoo MCP” or DM “AI Roadmap” and we’ll map your highest-ROI tools and governance in a week.

SHARE | FOLLOW | SUBSCRIBE

Leave a Reply

Subscribe to Blog via Email.

Enter your email address to subscribe to this blog and receive notifications of new posts by email.
Loading

Recent Comments

Related Posts