MCP Server for Odoo

repository·main·Indexed 43 days ago

https://github.com/ivnvxd/mcp-server-odoo

A Model Context Protocol (MCP) server version 0.8.0 that enables AI assistants like Claude to interact with Odoo ERP systems. It allows for searching, creating, updating, and deleting Odoo records via natural language. The server supports a Standard mode requiring Odoo 16.0+ with the Odoo MCP module for enterprise security, and a YOLO mode for testing/demos using XML-RPC. It is compatible with Claude Desktop, Claude Code, Cursor, VS Code, Windsurf, and Zed.

Tokens
27.7K
Snippets
87
Records
123
Agent score
54%

What's inside mcp-server-odoo

  1. Overview of MCP Server for Odoo

    main

    The MCP Server for Odoo is a Model Context Protocol (MCP) server that allows AI assistants (like Claude) to interact with Odoo ERP systems. It enables natural language interaction for tasks such as searching records, creating/updating/deleting data, inspecting model fields, and performing server-side aggregations.

    It supports two primary modes of operation:

    • Standard mode (Production): Requires Odoo version 16.0+ with the Odoo MCP module installed for enterprise security and access controls.
    • YOLO mode (Testing/Demos): Works with any Odoo version that has XML-RPC enabled; no additional module is required.
  2. Choose a transport protocol

    main

    The server supports two transport modes:

    1. stdio (Default): Best for desktop AI applications like Claude Desktop. No extra configuration is needed.
    2. streamable-http: Best for REST API-style access and remote connectivity.

    ⚠️ Security Warning for HTTP: The streamable-http transport has no built-in client authentication. Anyone who can reach the port can use the server's Odoo credentials. It is highly recommended to bind to localhost and use an authenticating reverse proxy (like Nginx with basic auth) for remote access.

    # Run with HTTP transport (localhost only)
    uvx mcp-server-odoo --transport streamable-http --port 8000
    
    # Run with HTTP transport bound to all interfaces (Exposes to network - USE CAUTION)
    uvx mcp-server-odoo --transport streamable-http --host 0.0.0.0 --port 8000
  3. Understand Smart Field Selection

    main

    When the fields parameter is omitted or set to null, the server uses a scoring algorithm to select relevant fields, optimizing for LLM context and performance.

    Selection Logic:

    • Included: Essential fields (id, name, display_name, active) and business-relevant fields (state, amount, email, etc.).
    • Excluded: Technical fields (message threads, activity tracking), expensive fields (binary, HTML, large text), and computed non-stored fields.
    • Credential Protection: Fields matching patterns like *password, *_pass, *secret, *_token, *apikey, or *_key are excluded from smart defaults and from ["__all__"] reads. You must request these explicitly by name to retrieve them.

    Configuration:

    • Adjust the default limit (15 fields) using ODOO_MCP_MAX_SMART_FIELDS.
  4. Use YOLO mode for development (No MCP module required)

    main

    YOLO mode allows the server to connect directly to standard Odoo XML-RPC endpoints without the mcp_server module installed. This bypasses all MCP security controls and is ONLY for development, testing, and demos.

    🚨 WARNING: Never use YOLO mode in production!

    YOLO Mode Levels

    • Read-Only (ODOO_YOLO=read): Allows search, read, and count. Blocks all write operations. Safe for demos.
    • Full Access (ODOO_YOLO=true): Allows all CRUD operations. Extremely dangerous; use only in isolated environments.

    Configuration Examples

    Read-Only Demo Configuration:

    {
      "mcpServers": {
        "odoo-demo": {
          "command": "uvx",
          "args": ["mcp-server-odoo"],
          "env": {
            "ODOO_URL": "http://localhost:8069",
            "ODOO_USER": "admin",
            "ODOO_PASSWORD": "admin",
            "ODOO_DB": "demo",
            "ODOO_YOLO": "read"
          }
        }
      }
    }

    Full Access Test Configuration (⚠️ Dangerous):

    {
      "mcpServers": {
        "odoo-test": {
          "command": "uvx",
          "args": ["mcp-server-odoo"],
          "env": {
            "ODOO_URL": "http://localhost:8069",
            "ODOO_USER": "admin",
            "ODOO_PASSWORD": "admin",
            "ODOO_DB": "test",
            "ODOO_YOLO": "true"
          }
        }
      }
    }
  5. Use Odoo Resource URIs for data access

    main

    The server provides direct access to Odoo data via URI patterns. This is particularly useful for fetching binary/image data, as the tools return URIs instead of inline base64.

    Supported URI Patterns:

    • odoo://{model}/record/{id}: Retrieve a specific record.
    • odoo://{model}/search: Search records (returns first 10).
    • odoo://{model}/count: Count all records in a model.
    • odoo://{model}/fields: Get field definitions and metadata.
    • odoo://{model}/record/{id}/{field}: Fetch a binary/image field (serves with correct mimeType).
    • odoo://attachment/{id}: Fetch an ir.attachment by ID.

    Important Notes:

    • Binary Data: Tool results carry URIs for binary fields. Your MCP client must support resources/read to fetch the actual bytes.
    • Size Limits: Binary/attachment reads are limited by ODOO_MCP_MAX_BINARY_SIZE (default 50 MB).
    • No Query Params: Resource URIs do not support query parameters. Use search_records for filtering or pagination.
    odoo://res.partner/record/1/image_128
    odoo://attachment/42
  6. Configure MCP Server for Odoo in Claude Code

    main

    For Claude Code, you can either add the configuration to a .mcp.json file in your project root or use the CLI to add it automatically.

    # Using CLI
    claude mcp add odoo \
      --env ODOO_URL=https://your-odoo-instance.com \
      --env ODOO_API_KEY=your-api-key-here \
      --env ODOO_DB=your-database-name \
      -- uvx mcp-server-odoo
    
    # Or via .mcp.json
    {
      "mcpServers": {
        "odoo": {
          "command": "uvx",
          "args": ["mcp-server-odoo"],
          "env": {
            "ODOO_URL": "https://your-odoo-instance.com",
            "ODOO_API_KEY": "your-api-key-here",
            "ODOO_DB": "your-database-name"
          }
        }
      }
    }
  7. Set up Odoo for MCP access (Standard Mode)

    main

    To use the server with full security and model-level permissions, follow these steps in your Odoo instance:

    1. Install the MCP module: Download the mcp_server module from the Odoo App Store and install it. Navigate to Settings > MCP Server to verify.
    2. Enable models: Go to Settings > MCP Server > Enabled Models. Add the models you want to expose (e.g., res.partner, product.product) and configure permissions (read, write, create, delete).
    3. Generate an API key: Go to Settings > Users & Companies > Users, select your user, go to the API Keys tab, and create a new key. Copy this key for your MCP configuration.
  8. Configure MCP Server for Odoo in VS Code (GitHub Copilot)

    main

    Add the following configuration to .vscode/mcp.json in your workspace.

    Note: VS Code requires the root key to be "servers" instead of "mcpServers".

    {
      "servers": {
        "odoo": {
          "type": "stdio",
          "command": "uvx",
          "args": ["mcp-server-odoo"],
          "env": {
            "ODOO_URL": "https://your-odoo-instance.com",
            "ODOO_API_KEY": "your-api-key-here",
            "ODOO_DB": "your-database-name"
          }
        }
      }
    }
  9. Run MCP Server for Odoo using Docker

    main

    You can run the server using Docker without needing a local Python installation.

    Standard Docker run (stdio): Use host.docker.internal instead of localhost if your Odoo instance is running on the host machine.

    HTTP Transport mode: To run with HTTP transport, use the --transport streamable-http flag.

    ⚠️ Security Warning: The HTTP transport has no built-in authentication. Anyone who can reach the port can access your Odoo instance using the server's credentials. It is recommended to use a reverse proxy or restrict access to trusted networks.

    # Standard Docker run
    {
      "mcpServers": {
        "odoo": {
          "command": "docker",
          "args": [
            "run", "-i", "--rm",
            "-e", "ODOO_URL=http://host.docker.internal:8069",
            "-e", "ODOO_API_KEY=your-api-key-here",
            "ivnvxd/mcp-server-odoo"
          ]
        }
      }
    }
    
    # HTTP transport mode
    docker run --rm -p 8000:8000 \
      -e ODOO_URL=http://host.docker.internal:8069 \
      -e ODOO_API_KEY=your-api-key-here \
      ivnvxd/mcp-server-odoo --transport streamable-http --host 0.0.0.0
  10. Install UV for local MCP server execution

    main

    The MCP server runs on your local computer (where your AI client is installed). It is highly recommended to use uv to manage the server execution.

    macOS/Linux:

    curl -LsSf https://astral.sh/uv/install.sh | sh

    Windows:

    powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

    After installation, restart your terminal to ensure uv is in your PATH.

    curl -LsSf https://astral.sh/uv/install.sh | sh
  11. Configure MCP Server for Odoo in Windsurf

    main

    Add the following configuration to ~/.codeium/windsurf/mcp_config.json to enable Odoo integration in Windsurf.

    {
      "mcpServers": {
        "odoo": {
          "command": "uvx",
          "args": ["mcp-server-odoo"],
          "env": {
            "ODOO_URL": "https://your-odoo-instance.com",
            "ODOO_API_KEY": "your-api-key-here",
            "ODOO_DB": "your-database-name"
          }
        }
      }
    }
  12. Configure MCP Server for Odoo in Claude Desktop

    main

    To use the Odoo MCP server with Claude Desktop, add the following configuration to your ~/Library/Application Support/Claude/claude_desktop_config.json file. This uses uvx to run the server without manual installation.

    Required environment variables:

    • ODOO_URL: Your Odoo instance URL.
    • ODOO_API_KEY: Your Odoo API key.
    • ODOO_DB: Your Odoo database name.
    {
      "mcpServers": {
        "odoo": {
          "command": "uvx",
          "args": ["mcp-server-odoo"],
          "env": {
            "ODOO_URL": "https://your-odoo-instance.com",
            "ODOO_API_KEY": "your-api-key-here",
            "ODOO_DB": "your-database-name"
          }
        }
      }
    }