eribichesu/odoo-mcp-server
If you are the rightful owner of odoo-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
An MCP (Model Context Protocol) server for Odoo that allows interaction with Odoo online instances via XML-RPC API.
Odoo MCP Server
An MCP (Model Context Protocol) server for Odoo that allows interaction with Odoo online instances via XML-RPC API.
Features
- CRUD Operations: Create, read, update, and delete records in any Odoo model
- Model Introspection: Get field definitions and metadata for Odoo models
- Custom Method Calls: Execute custom methods on Odoo models
- Async Support: Built with async/await for better performance
- Error Handling: Comprehensive error handling with detailed error messages
- Type Safety: Full type hints throughout the codebase
Installation
- Clone the repository:
git clone <your-repo-url>
cd odoo.mcp
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Install the package in development mode:
pip install -e .
Configuration
The server can be configured using environment variables or by passing configuration directly.
Environment Variables
Create a .env
file in the project root:
ODOO_URL=https://your-odoo-instance.odoo.com
ODOO_DATABASE=your_database_name
ODOO_USERNAME=your_username
ODOO_PASSWORD=your_password
SERVER_NAME=odoo-mcp
Configuration Options
ODOO_URL
: Your Odoo instance URLODOO_DATABASE
: Database nameODOO_USERNAME
: Odoo usernameODOO_PASSWORD
: Odoo passwordSERVER_NAME
: MCP server name (default: "odoo-mcp")
Usage
Running the Server
To start the MCP server:
python -m odoo_mcp.server
Available Tools
The server provides the following MCP tools:
1. Search Records
Search for records in any Odoo model.
Parameters:
model
(required): Odoo model name (e.g., "res.partner")domain
(optional): Search filters as a listfields
(optional): Fields to retrievelimit
(optional): Maximum number of recordsoffset
(optional): Number of records to skiporder
(optional): Sort order
Example:
{
"model": "res.partner",
"domain": [["is_company", "=", true]],
"fields": ["id", "name", "email"],
"limit": 10
}
2. Create Record
Create a new record in an Odoo model.
Parameters:
model
(required): Odoo model namevalues
(required): Field values as a dictionary
Example:
{
"model": "res.partner",
"values": {
"name": "New Company",
"is_company": true,
"email": "contact@newcompany.com"
}
}
3. Update Record
Update an existing record.
Parameters:
model
(required): Odoo model namerecord_id
(required): ID of the record to updatevalues
(required): Field values to update
Example:
{
"model": "res.partner",
"record_id": 123,
"values": {
"email": "newemail@company.com",
"phone": "+1234567890"
}
}
4. Delete Record
Delete a record from an Odoo model.
Parameters:
model
(required): Odoo model namerecord_id
(required): ID of the record to delete
Example:
{
"model": "res.partner",
"record_id": 123
}
5. Get Model Fields
Get field definitions for an Odoo model.
Parameters:
model
(required): Odoo model name
Example:
{
"model": "res.partner"
}
6. Call Model Method
Execute a custom method on an Odoo model.
Parameters:
model
(required): Odoo model namemethod
(required): Method name to callargs
(optional): Positional arguments as a listkwargs
(optional): Keyword arguments as a dictionary
Example:
{
"model": "res.partner",
"method": "name_get",
"args": [[1, 2, 3]]
}
Resources
The server provides access to Odoo model documentation and schemas:
- Model Schemas: Introspect field definitions for any Odoo model
- API Documentation: Access to Odoo XML-RPC API documentation
Prompts
Pre-configured prompts for common Odoo operations:
- Analyze Model: Get comprehensive information about an Odoo model
- Data Migration: Help with data migration between Odoo instances
- Custom Reports: Generate custom reports from Odoo data
Development
Running Tests
pytest tests/
Code Formatting
The project uses several tools for code quality:
# Format code
black src/ tests/
# Sort imports
isort src/ tests/
# Type checking
mypy src/
Project Structure
odoo.mcp/
āāā src/
ā āāā odoo_mcp/
ā āāā __init__.py
ā āāā server.py # Main MCP server
ā āāā client.py # Odoo XML-RPC client
ā āāā config.py # Configuration management
ā āāā tools.py # MCP tool implementations
āāā tests/
ā āāā __init__.py
ā āāā test_basic.py
āāā config/
ā āāā .env.example
āāā pyproject.toml
āāā README.md
Error Handling
The server includes comprehensive error handling:
- Authentication Errors: Clear messages for login failures
- Permission Errors: Detailed access control error messages
- Validation Errors: Field validation and constraint errors
- Network Errors: Connection and timeout handling
- General Errors: Graceful handling of unexpected errors
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues and questions:
- Check the GitHub issues
- Create a new issue with detailed information
- Include error messages and configuration details