Odoo 19 MCP Server
Provides tools to interact with Odoo 19's External JSON-2 API, enabling CRUD operations and complex queries on Odoo databases with multi-company support.
README
Odoo 19 MCP Server
A Model Context Protocol (MCP) server that provides tools to interact with Odoo 19's External JSON-2 API. This server enables Claude and other MCP clients to perform CRUD operations and queries on Odoo databases.
Features
- Multi-Company Support: Manage multiple Odoo instances/companies from a single MCP server
- Full CRUD Operations: Create, read, update, and delete records
- Advanced Search: Search with complex domain filters
- Batch Operations: Perform operations on multiple records
- Image Processing: Built-in support for processing images with Pillow (resize, format conversion)
- Robust Error Handling: Automatic retry with exponential backoff for transient failures
- Connection Pooling: Efficient HTTP connection reuse for better performance
- Configurable Timeouts: Prevent hanging on slow/unresponsive servers
- Type-Safe: Proper input validation and error handling
- Docker Support: Multi-stage builds with optimized image size and security
- Production Ready: Non-root user, health checks, and comprehensive logging
Available Tools
1. odoo_list_companies
List all available company configurations.
Parameters: None
Returns: List of configured company names
2. odoo_search_read
Search and read records from an Odoo model.
Parameters:
company(required): The company configuration name (from .env sections)model(required): The Odoo model name (e.g.,res.partner,account.move)domain(optional): Search criteria as a list (e.g.,[["name", "=", "John"]])fields(optional): List of field names to retrievelimit(optional): Maximum number of recordsoffset(optional): Number of records to skiporder(optional): Sorting order (e.g.,"name asc")
3. odoo_create
Create a new record in an Odoo model.
Parameters:
company(required): The company configuration namemodel(required): The Odoo model namevalues(required): Dictionary of field values
4. odoo_write
Update existing records.
Parameters:
company(required): The company configuration namemodel(required): The Odoo model nameids(required): List of record IDs to updatevalues(required): Dictionary of field values to update
5. odoo_unlink
Delete records from an Odoo model.
Parameters:
company(required): The company configuration namemodel(required): The Odoo model nameids(required): List of record IDs to delete
6. odoo_search
Search for record IDs without reading full records.
Parameters:
company(required): The company configuration namemodel(required): The Odoo model namedomain(optional): Search criterialimit,offset,order(optional): Same as search_read
7. odoo_read
Read specific records by their IDs.
Parameters:
company(required): The company configuration namemodel(required): The Odoo model nameids(required): List of record IDsfields(optional): List of field names to retrieve
8. odoo_search_count
Count records matching search criteria.
Parameters:
company(required): The company configuration namemodel(required): The Odoo model namedomain(optional): Search criteria
Prerequisites
- Python 3.10 or higher (for local development)
- Docker and Docker Compose (for containerized deployment)
- Odoo 19 instance with External API enabled
- Odoo API key (see Configuration section)
Configuration
Getting an Odoo API Key
- Log in to your Odoo instance
- Go to Settings → Users & Companies → Users
- Select your user
- Go to the Preferences tab
- In the API Keys section, click New API Key
- Give it a description and click Generate
- Copy the generated API key (it will only be shown once)
Multi-Company Configuration
The server supports managing multiple Odoo instances/companies through a single MCP server instance. Each company is configured in the .env file using INI-style sections.
Create a .env file in the project root:
cp .env.example .env
Edit .env with your company configurations:
# Company 1
[company1]
ODOO_URL=http://localhost:8069
ODOO_DATABASE=database_name
ODOO_API_KEY=your_api_key_here
COMPANY_ID=1 # Optional, defaults to 1
# Company 2 - same database, different company
[company2]
ODOO_URL=http://localhost:8069
ODOO_DATABASE=database_name
ODOO_API_KEY=another_api_key
COMPANY_ID=2
# Company 3 - different database
[production]
ODOO_URL=https://instance.odoo.com
ODOO_DATABASE=production_db
ODOO_API_KEY=production_key
COMPANY_ID=1
Key Points:
- Each
[section_name]defines a company configuration - The section name is used as the
companyparameter in tool calls - Multiple companies can connect to the same Odoo instance/database with different API keys
COMPANY_IDis optional and defaults to 1 if not specified
Advanced Configuration
You can configure request behavior using environment variables:
[company1]
ODOO_URL=http://localhost:8069
ODOO_DATABASE=database_name
ODOO_API_KEY=your_api_key_here
COMPANY_ID=1
# Optional: Override global settings per company
ODOO_REQUEST_TIMEOUT=30 # Request timeout in seconds (default: 30)
ODOO_MAX_RETRIES=3 # Maximum retry attempts (default: 3)
Or set global defaults in your environment/docker-compose:
# docker-compose.yml
environment:
- ODOO_REQUEST_TIMEOUT=60 # Longer timeout for slow networks
- ODOO_MAX_RETRIES=5 # More retries for unreliable connections
Performance Tuning:
- Lower
ODOO_REQUEST_TIMEOUTfor faster failure detection on bad connections - Increase
ODOO_MAX_RETRIESfor unreliable networks (max recommended: 5) - Retry uses exponential backoff: waits 1s, 2s, 4s between attempts
Installation & Usage
Option 1: Docker (Recommended)
- Build and run with Docker Compose:
docker-compose up -d
- View logs:
docker-compose logs -f
- Stop the server:
docker-compose down
Option 2: Local Development
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run the server:
python src/odoo_mcp_server.py
Using with Claude Desktop
Quick Setup (Recommended)
Run the automated setup script:
./setup-claude-desktop.sh
This script will:
- Build the Docker image
- Verify Docker is running
- Show you the exact configuration to add to Claude Desktop
Manual Setup
For detailed instructions, including troubleshooting and advanced configurations, see CLAUDE_DESKTOP_SETUP.md.
Configuration file location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Docker Setup (Recommended):
{
"mcpServers": {
"odoo": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"--env-file",
"/absolute/path/to/claude-odoo-api/.env",
"odoo-mcp-server"
]
}
}
}
Local Python Setup:
{
"mcpServers": {
"odoo": {
"command": "python",
"args": [
"/absolute/path/to/claude-odoo-api/src/odoo_mcp_server.py"
],
"env": {
"ODOO_CONFIG_FILE": "/absolute/path/to/claude-odoo-api/.env"
}
}
}
}
Important Notes:
- Replace paths with your actual absolute paths
- If your Odoo is on localhost, use
host.docker.internalin.envor add"--network", "host"to Docker args - After updating the configuration, restart Claude Desktop completely
See CLAUDE_DESKTOP_SETUP.md for complete setup instructions and troubleshooting.
Examples & Scripts
Check out the examples/ directory for ready-to-use scripts:
process_contact_images.py: Export and process contact images with automatic resizing and HTML gallery generationpython examples/process_contact_images.py
See examples/README.md for detailed documentation and more examples.
Example Usage
Once connected, you can ask Claude to interact with your Odoo instances:
List available companies:
List all available Odoo companies
Search for partners:
Find all partners with 'John' in their name in company1
Create a new partner:
Create a new partner in company2 with name "Acme Corp" and email "contact@acme.com"
Update records:
Update partner ID 42 in production to set their phone to "555-1234"
Count records:
How many invoices do we have in draft status in company1?
Complex queries:
Find all sales orders in company2 created in the last 30 days with a total amount greater than $1000
Multi-company operations:
Compare the number of active customers between company1 and company2
Odoo Domain Syntax
Odoo uses a domain filter syntax for searching. Here are common examples:
# Equals
[["name", "=", "John"]]
# Not equals
[["state", "!=", "draft"]]
# Greater than / Less than
[["amount_total", ">", 1000]]
# In list
[["state", "in", ["sale", "done"]]]
# Like (contains)
[["name", "ilike", "john"]] # case-insensitive
# AND conditions (default)
[["name", "=", "John"], ["city", "=", "New York"]]
# OR conditions
["|", ["name", "=", "John"], ["name", "=", "Jane"]]
# Complex nested conditions
["|", ["state", "=", "draft"], "&", ["amount_total", ">", 1000], ["partner_id", "!=", False]]
Common Odoo Models
res.partner- Customers, vendors, contactsproduct.product- Productsproduct.template- Product templatessale.order- Sales orderssale.order.line- Sales order linesaccount.move- Invoices, bills, journal entriesaccount.move.line- Invoice/bill linesstock.picking- Warehouse transferspurchase.order- Purchase ordersproject.project- Projectsproject.task- Taskshr.employee- Employeescrm.lead- CRM leads/opportunities
Troubleshooting
Connection Issues
- Verify Odoo is accessible:
curl http://your-odoo-url:8069/web/database/selector
- Test API key authentication:
curl -X POST http://your-odoo-url:8069/json/2/res.partner/search_count \
-H "Authorization: Bearer your_api_key" \
-H "X-Odoo-Database: your_database" \
-H "Content-Type: application/json" \
-d '{"domain": []}'
Docker Network Issues
If running Odoo locally and the container can't reach it, use host.docker.internal instead of localhost:
ODOO_URL=http://host.docker.internal:8069
Or use host networking:
docker run --network host ...
API Access Denied
Ensure your Odoo plan supports the External API. According to Odoo documentation:
- External API access requires Custom Odoo pricing plans
- Not available on One App Free or Standard plans
Testing
The project includes comprehensive unit tests.
Running Tests Locally
- Install test dependencies:
pip install -r requirements.txt
- Run all tests:
pytest tests/ -v
- Run with coverage report:
pytest tests/ -v --cov=src --cov-report=html
- View coverage report:
open htmlcov/index.html # macOS
# or
xdg-open htmlcov/index.html # Linux
Continuous Integration
The project uses GitHub Actions for CI/CD:
- Tests: Run on Python 3.10, 3.11, and 3.12
- Linting: Code style checks with flake8, black, and isort
- Docker: Automated Docker image builds
See .github/workflows/ci.yml for workflow details.
Development
Project Structure
claude-odoo-api/
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions CI/CD workflow
├── src/
│ └── odoo_mcp_server.py # Main MCP server implementation
├── tests/
│ ├── __init__.py
│ ├── test_odoo_mcp_server.py # Unit tests
│ └── README.md # Test documentation
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── requirements.txt # Python dependencies (includes test deps)
├── pytest.ini # Pytest configuration
├── pyproject.toml # Python project metadata
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules
├── CLAUDE.md # Developer documentation
├── README.md # This file
└── create_odoo_invoices.py # Example usage script
Adding New Tools
To add new Odoo API operations:
- Add a method to the
OdooClientclass (if needed) - Add the tool definition in
list_tools()- Include
companyas a required parameter for Odoo operations
- Include
- Add the tool handler in
call_tool()- Extract company parameter and get client instance
- Add corresponding unit tests in
tests/
See CLAUDE.md for detailed implementation guide.
Resources
- Odoo 19 External API Documentation
- Model Context Protocol Documentation
- Odoo Development Documentation
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。