Skip to main content
Glama
odoo-preview-mcp

odoo-preview-mcp

by Sahajta-AI
README.md
# odoo-preview-mcp

[![tests](https://github.com/Sahajta-AI/odoo-preview-mcp/actions/workflows/tests.yml/badge.svg)](https://github.com/Sahajta-AI/odoo-preview-mcp/actions/workflows/tests.yml)
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/LICENSE)

An MCP server that lets Claude read and change your Odoo data as the signed-in person, with a preview and an approval before every change.

You ask Claude things like *"show me open opportunities over 50,000 by stage"*, *"create a quotation for Acme with
3 licences"* or *"match this bank line with the Northwind bill"*. Claude does the work in your real Odoo, inside
that person's own Odoo permissions.

## Safety guarantees

All company data lives in Odoo, so the server is built safety-first:

| Guarantee | How |
|---|---|
| **Claude acts as the person, never through a shared admin key** | Each person signs in with their *own* Odoo API key. Odoo's normal access rights and record rules apply to every call, and Odoo records every change under that person's name. Claude can do only what that person can do in Odoo, so give people normal user accounts, not admin accounts. |
| **A human approves every change** | Each change is previewed first: current value → new value, with the names behind ids. To apply it, Claude must send back a token signed for that exact preview. The token works once, expires after an hour, and stops working if the records changed after the preview. Change tools are marked *destructive*, so Claude asks before it runs them. |
| **Almost nothing can be deleted** | One delete tool, for three kinds of records only: draft invoices and bills that never had a number, cancelled quotations, and archived leads. The server checks each record with Odoo before the approval and again just before it deletes. Every other delete path is refused. |
| **Field names are checked against live Odoo** | Every field name, choice value and record id is checked against the live Odoo database before anything is sent. Unknown names are refused with a "did you mean…?" hint, so a made-up field never reaches Odoo. |
| **Read-only unless you switch it on** | The default mode shows only search, read and report tools. Change tools do not appear until you set `MCP_ACCESS_MODE=read_write`. |
| **Workflows stay intact** | Status fields (`state`) cannot be written directly. Claude can press only real Odoo buttons (Confirm, Validate, …). Cancel, reset, archive and e-mail buttons are off by default. |
| **Secrets stay secret** | Passwords, API keys, tokens and system settings are never readable. Stored Odoo keys are encrypted. |
| **Audit trail** | The server logs every call with ids and field names, never values. |

The full list of protections and the threat model are in [docs/SECURITY.md](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/docs/SECURITY.md).

## How it compares

Two other open-source Odoo MCP servers are well known, and both have been public much longer than this one:
[erpipe-org/mcp-odoo](https://github.com/erpipe-org/mcp-odoo) and
[ivnvxd/mcp-server-odoo](https://github.com/ivnvxd/mcp-server-odoo). Both are good choices. They make different
trade-offs.

| | odoo-preview-mcp | erpipe-org/mcp-odoo | ivnvxd/mcp-server-odoo |
|---|---|---|---|
| Whose Odoo account Claude uses | Company mode: each person signs in with their own key on one shared server. Local mode: your own key. | The one login in the server's settings (per Odoo instance). Sign-in per person is part of their hosted product, ERPipe. | The one login in the server's settings. |
| Setup inside Odoo | None, only an API key | None | For production, the `mcp_server` module from the Odoo Apps store. Without it, a "YOLO mode" for testing. |
| Before a change | Preview, then a token signed for that exact change | Preview and validation, then an approval token, and writes must be switched on | Odoo's permissions, plus the per-model permissions set in the Odoo module |
| Deleting | Only never-numbered drafts, cancelled quotations and archived leads | Deletes go through the same approval flow as other writes | A delete tool, limited by the module's per-model delete permission |
| Odoo versions | 18 and later (JSON-2 on 19+, legacy JSON-RPC before). Most testing on 19. | 16 to 19, tested against real Odoo 16–19 in Docker | 16 and later with the module, any version in YOLO mode |

**What they do well.** erpipe-org/mcp-odoo covers more Odoo versions, connects to several Odoo databases from one
server, and has diagnostics, upgrade helpers and field-level allow and deny lists. ivnvxd/mcp-server-odoo lets the
Odoo administrator choose, inside Odoo, which models the AI may read, change or delete, and it can limit a
session to some companies in a multi-company database.

**Where this project is different.**

* **One server for the whole company, with each person's own sign-in.** You deploy once. Each person connects
  from Claude and enters their own Odoo login and API key. Nobody shares a key, and an admin key is never needed.
* **Every change is previewed and approved.** Claude cannot change data without a preview that the person saw,
  and the approval token works only for that exact change.
* **Deleting is almost impossible by design**, not only switched off by a setting.
* **Accounting work that goes past create and update:** matching bank lines with bills and invoices (also in
  another currency and in part), Odoo's official reports (P&L, balance sheet, ledgers, ageing, tax report),
  moving the tax lock date, and correcting a posted vendor bill step by step.
* **Files and fields:** a private upload page for files from the person's computer, and custom fields placed on
  a form with a "show only when" rule, all with the same preview and approval.

If you need many Odoo versions or databases from one server, or control from inside Odoo, look at the other two.

## Quick start (local, about 5 minutes)

This runs the server on your own computer for one person, with your own Odoo key.

**You need:** Python 3.11 or later, [uv](https://docs.astral.sh/uv/getting-started/installation/), and an Odoo
database where the external API is allowed. On Odoo Online, the external API needs the **Custom** plan.

1. **Create an Odoo API key.** In Odoo: your profile picture → *My Preferences* → *Security* tab →
   *Create API Key*. If Odoo asks for a scope, choose **RPC**. Copy the key. (Details: [docs/ODOO_SETUP.md](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/docs/ODOO_SETUP.md#create-an-api-key).)

2. **Test the connection.**

   ```bash
   ODOO_URL=https://mycompany.odoo.com ODOO_LOGIN=you@mycompany.com ODOO_API_KEY=your-key uvx odoo-preview-mcp check
   ```

   It prints your Odoo user, the Odoo version and the active safety settings.

3. **Add it to Claude.** For Claude Code:

   ```bash
   claude mcp add odoo -e ODOO_URL=https://mycompany.odoo.com -e ODOO_LOGIN=you@mycompany.com -e ODOO_API_KEY=your-key -- uvx odoo-preview-mcp
   ```

   For Claude Desktop, open *Settings → Developer → Edit Config* and add:

   ```json
   {
     "mcpServers": {
       "odoo": {
         "command": "uvx",
         "args": ["odoo-preview-mcp"],
         "env": {
           "ODOO_URL": "https://mycompany.odoo.com",
           "ODOO_LOGIN": "you@mycompany.com",
           "ODOO_API_KEY": "your-key"
         }
       }
     }
   }
   ```

   Restart Claude Desktop. Then ask: *"Who am I in Odoo?"*

The server starts read-only. To let Claude make changes (always with a preview and an approval), add
`MCP_ACCESS_MODE=read_write`. If you use `pipx` instead of `uv`, run `pipx install odoo-preview-mcp` and use the
command `odoo-preview-mcp` in place of `uvx odoo-preview-mcp`.

## For a whole company

Run the server once with HTTPS, and each person connects from Claude with their own Odoo login and API key:

1. Prepare Odoo: [docs/ODOO_SETUP.md](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/docs/ODOO_SETUP.md).
2. Deploy with Docker on any small server ([docs/DEPLOY.md](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/docs/DEPLOY.md)),
   or on Vercel with a Redis database ([docs/DEPLOY_VERCEL.md](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/docs/DEPLOY_VERCEL.md)).
3. In Claude: *Settings → Connectors → Add custom connector*, with your server's URL followed by `/mcp`. Each
   person clicks **Connect** and signs in on the server's page.

## What Claude can do

| Tool | What it does | Mode |
|---|---|---|
| `odoo_whoami`, `odoo_help` | Who am I, what is allowed, and per area of Odoo what Claude can and cannot do | always |
| `odoo_list_models`, `odoo_describe_model` | Find the model for a concept ("invoice" → `account.move`) and its fields | always |
| `odoo_search`, `odoo_read`, `odoo_count`, `odoo_find` | Find and read records, and turn a name into the right record | always |
| `odoo_aggregate` | Totals and breakdowns computed by Odoo (revenue by month, pipeline by stage) | always |
| `odoo_report` | Odoo's official accounting reports for a period, with a link to open them | always |
| `odoo_list_actions` | The buttons on a model's screens and whether Claude may press them | always |
| `odoo_read_file` | Read a file that is already in Odoo (a bill's PDF, a contract) | always |
| `odoo_bank_match_candidates` | The items Odoo's bank screen would offer for one bank line | always |
| `odoo_preview_create` → `odoo_create` | Create records (with order lines and so on) | read_write |
| `odoo_preview_update` → `odoo_update` | Change field values | read_write |
| `odoo_preview_action` → `odoo_run_action` | Press a workflow button (confirm an order, validate) | read_write |
| `odoo_preview_delete` → `odoo_delete` | Delete a never-numbered draft invoice or bill, a cancelled quotation or an archived lead | read_write |
| `odoo_add_note` | Log an internal note in the chatter (nobody is e-mailed) | read_write |
| `odoo_preview_followers` → `odoo_change_followers` | Add or remove followers | read_write |
| `odoo_preview_bank_match` → `odoo_bank_match`, `odoo_preview_bank_unmatch` → `odoo_bank_unmatch` | Match a bank line with bills or invoices, in any currency, and undo a match | read_write |
| `odoo_preview_lock_date` → `odoo_lock_date` | Move the tax return lock date forward | read_write |
| `odoo_preview_fix_posted_bill` → `odoo_fix_posted_bill` | Correct a posted vendor bill step by step | read_write |
| `odoo_upload_link` → `odoo_uploaded_files` | A private one-hour page where the person uploads files (up to 4 MB each) into Odoo | read_write, company mode |
| `odoo_preview_custom_field` → `odoo_add_custom_field`, `odoo_preview_place_field` → `odoo_place_field`, `odoo_preview_remove_custom_field` → `odoo_remove_custom_field` | Add a custom field (named `x_mcp_…`), place it on a form, and remove both again | read_write + `MCP_ALLOW_CUSTOM_FIELDS` |
| `odoo_preview_message` → `odoo_send_message` | Message a record's followers (this e-mails customers) | read_write + `MCP_ALLOW_OUTBOUND_MESSAGES` |

The server uses Odoo's generic model API, so it covers every installed app (CRM, Sales, Invoicing, Inventory,
Purchase, Project, HR, Helpdesk, Studio models), always inside the person's permissions.

## Configuration

All settings are environment variables. [.env.example](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/.env.example)
explains each one. The main ones:

| Variable | Default | Meaning |
|---|---|---|
| `ODOO_URL` | *(required)* | Your Odoo address, e.g. `https://mycompany.odoo.com` |
| `ODOO_LOGIN`, `ODOO_API_KEY` | *(empty)* | Your Odoo login and API key. Local mode only; in company mode each person signs in. |
| `ODOO_DB` | *(empty)* | Database name. Needed only with several databases or the legacy API. |
| `ODOO_PROTOCOL` | `auto` | `json2` (Odoo 19+), `jsonrpc` (older Odoo), or `auto` to detect |
| `MCP_ACCESS_MODE` | `read_only` | `read_write` shows the change tools |
| `MCP_ALLOW_ARCHIVE` | `false` | Allow archiving and unarchiving |
| `MCP_ALLOW_CANCEL_ACTIONS` | `false` | Allow cancel, reset to draft and mark lost buttons |
| `MCP_ALLOW_OUTBOUND_MESSAGES` | `false` | Allow anything that e-mails or messages people |
| `MCP_ALLOW_CUSTOM_FIELDS` | `false` | Allow adding custom fields and placing them on forms (needs Odoo admin rights) |
| `MCP_WRITABLE_MODELS` | *(all business models)* | Allow changes only on these models, e.g. `crm.lead,res.partner,project.task` |
| `MCP_BLOCKED_MODELS`, `MCP_READONLY_MODELS` | *(none)* | Extra limits; patterns such as `hr.*` work |
| `MCP_MAX_WRITE_RECORDS` | `100` | Most records one create or edit may touch (hard limit 100) |
| `MCP_MAX_ACTION_RECORDS` | `20` | Most records one button, message or delete may touch (hard limit 100) |
| `MCP_CONFIRM_TTL_SECONDS` | `3600` | How long an approved preview stays usable (hard limit 24 hours) |
| `MCP_DISPLAY_NAME` | `Odoo` | Name shown on the sign-in and upload pages and in Claude, e.g. `Acme Odoo` |
| `MCP_ADMIN_CONTACT` | `your administrator` | Who people should ask when something is switched off |
| `MCP_DEFAULT_TIMEZONE` | `UTC` | Time zone used when a person's Odoo profile has none |
| `MCP_PUBLIC_URL` | *(empty)* | Company mode: the public HTTPS address of this server |
| `MCP_SECRET` | *(empty)* | Company mode: 32+ random characters; encrypts stored keys and signs tokens |
| `MCP_ALLOWED_LOGINS`, `MCP_ALLOWED_LOGIN_DOMAINS` | *(empty)* | Company mode: only these logins, or logins on these e-mail domains, may connect |
| `MCP_REDIS_URL` | *(empty)* | Company mode on serverless hosting: a Redis database for shared state |

## Contributing

Bug reports, ideas and pull requests are welcome. Please read
[CONTRIBUTING.md](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/CONTRIBUTING.md) first. In short:

* Open an issue before a large change, so we can agree on the approach.
* Keep the safety guarantees above. A change that weakens one will not be merged.
* Add tests. `pytest` runs the offline suite in under a minute, with no Odoo needed.
* Never put real customer data, API keys or company names in code, tests or issues.

Please report security problems privately, as [SECURITY.md](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/SECURITY.md) explains, not in a public issue.

## Development

```bash
git clone https://github.com/Sahajta-AI/odoo-preview-mcp && cd odoo-preview-mcp
uv venv && uv pip install -e ".[dev]"
.venv/bin/pytest                     # offline tests, no Odoo needed
.venv/bin/pytest -m integration      # against a throwaway Odoo, see tests/test_live_odoo.py
```

The first version was tested end to end against Odoo 18.0, 19.0 and 20.0 (Community, with demo data). Later
features (bank matching, custom fields, upload links) were tested against Odoo 19 only. Built on the official MCP
Python SDK.

## License

Apache License 2.0. Copyright 2026 Sahajta AI Solution Private Limited. See [LICENSE](https://github.com/Sahajta-AI/odoo-preview-mcp/blob/main/LICENSE).