使用说明
MCP Odoo服务器
MCP(模型上下文协议)服务器,用于将Odoo与Claude和其他支持MCP的AI向导集成。
功能
该MCP服务器允许通过对话接口管理Odoo数据:
时间表(Timesheets)
list_projects-列出可用项目list_tasks-列出任务(可按项目筛选)list_timesheets-列出分数get_timesheet_summary_by_employee-每位员工的工时汇总create_timesheet-创建分数update_timesheet-更改分数delete_timesheet-删除分数
费用说明
list_expense_categories-列出支出类别list_expenses-列出费用报表create_expense-创建费用报告update_expense-更改费用报告(支持analytic-account-id)delete_expense-删除费用单add_expense_attachment-添加附件list_expense_attachments-列出附件
联系人
list_contacts-列出联系人(客户/供应商)get_contact-联系人详细信息create_contact-创建联系人
因素
list_invoices-列出发票get_invoice-发票详情
销售
list_sale_orders-列出订单/报价get_sale_order-订单详情
产品
list_products-列出产品get_product-产品详细信息
人力资源
list_employees-列出员工get_employee-员工详细信息list_departments-列出部门list_leave_types-可用假期类型create_leave_allocation-创建休假津贴list_leave_allocations-列出分配approve_leave_allocation-批准分配create_public_holiday-创建假日list_public_holidays-列出假期
实用程序
test_connection-Odoo连接测试仪search_records-搜索任何Odoo模型get_rd_project_costs-研发项目成本
安装
先决条件
- Python 3.11+
- 具有API访问权限的Odoo实例
- Odoo API密钥
- Redis(可选,用于缓存)
安装
# Cloner le repository
git clone https://github.com/industream/mcp-odoo.git
cd mcp-odoo
# Créer un environnement virtuel
python -m venv venv
source venv/bin/activate # Linux/Mac
# ou: venv\Scripts\activate # Windows
# Installation standard
pip install -e .
# Installation avec toutes les dépendances (dev + redis)
pip install -e ".[all]"
# Configurer les variables d'environnement
cp .env.example .env
# Éditer .env avec vos credentials Odoo
配置
创建文件 .env 从 .env.example :
# URL de votre instance Odoo (sans slash final)
ODOO_URL=https://votre-instance.odoo.com
# Nom de la base de données Odoo
ODOO_DB=votre-instance
# Votre nom d'utilisateur (email)
ODOO_USERNAME=votre-email@example.com
# Votre clé API Odoo
ODOO_API_KEY=votre-cle-api
# Redis Cache (optionnel)
REDIS_ENABLED=true
REDIS_URL=redis://localhost:6379/0
REDIS_DEFAULT_TTL=300
# Logging
LOG_LEVEL=INFO
LOG_FORMAT=json # ou "text" pour le développement
获取Odoo API密钥
- 连接到您的Odoo实例
- 单击右上角的个人资料
- 进去 偏好
- 选项卡 账户安全
- 部分 API密钥 > 新API密钥
- 为密钥命名并复制
与Claude代码一起使用
在Claude代码配置中添加MCP服务器(~/.config/claude-code/settings.json) :
{
"mcpServers": {
"odoo": {
"type": "stdio",
"command": "/chemin/vers/mcp-odoo/venv/bin/python",
"args": ["-m", "mcp_odoo.server"],
"cwd": "/chemin/vers/mcp-odoo/src"
}
}
}
重新启动Claude代码以加载服务器。
使用示例
配置后,您可以询问Claude:
- “列出我本周的分数”
- “在项目X上创建2小时的分数”
- “给我看11月份每位员工的工时汇总”
- “为客户餐增加50欧元的费用”
- “待定发票列表”
发展
可用命令(Makefile)
# Installation
make install # Installation production
make install-dev # Installation développement (avec linting, tests, etc.)
# Qualité du code
make lint # Vérifier le code (ruff)
make format # Formater le code (ruff)
make typecheck # Vérification des types (mypy)
# Tests
make test # Tests unitaires
make test-cov # Tests avec couverture
make test-integration # Tests d'intégration
# Build
make build # Construire le package
make clean # Nettoyer les artefacts
# Lancer le serveur
make run # Mode production
make run-dev # Mode debug (LOG_LEVEL=DEBUG)
# Docker
make docker-up # Démarrer les services (Redis, etc.)
make docker-down # Arrêter les services
项目结构
mcp-odoo/
├── src/
│ └── mcp_odoo/
│ ├── __init__.py
│ ├── server.py # Serveur MCP principal
│ ├── client.py # Client Odoo XML-RPC
│ ├── config.py # Configuration (pydantic-settings)
│ ├── cache.py # Cache Redis
│ ├── logging_config.py # Configuration logging
│ ├── validators.py # Validation des données
│ ├── formatters.py # Formatage des réponses
│ ├── decorators.py # Décorateurs utilitaires
│ ├── exceptions.py # Exceptions personnalisées
│ ├── constants.py # Constantes
│ └── tools/ # Outils MCP par domaine
│ ├── contacts.py
│ ├── products.py
│ ├── sales.py
│ ├── invoices.py
│ ├── expenses.py
│ ├── projects.py
│ ├── timesheets.py
│ ├── hr.py
│ └── utilities.py
├── tests/
│ ├── unit/ # Tests unitaires
│ └── integration/ # Tests d'intégration
├── server.py # Point d'entrée legacy
├── pyproject.toml # Configuration du projet
├── Makefile # Commandes de développement
├── docker-compose.yml # Services Docker (Redis, etc.)
└── .env.example # Template de configuration
码头工人
该项目包括 docker-compose.yml 使用Redis进行缓存:
# Démarrer Redis
docker-compose up -d redis
# Vérifier le statut
docker-compose ps
许可证
麻省理工学院
贡献
欢迎捐款!不要犹豫打开问题或拉取请求。
在贡献之前,请确保:
make lint # Pas d'erreurs de linting
make typecheck # Pas d'erreurs de typage
make test # Tous les tests passent
