mcp-odoo 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_odoo-1.0.0/.dockerignore +22 -0
- mcp_odoo-1.0.0/.env.example +131 -0
- mcp_odoo-1.0.0/.github/workflows/ci.yml +528 -0
- mcp_odoo-1.0.0/.github/workflows/docker.yml +65 -0
- mcp_odoo-1.0.0/.github/workflows/publish.yml +77 -0
- mcp_odoo-1.0.0/.gitignore +138 -0
- mcp_odoo-1.0.0/AGENTS.md +38 -0
- mcp_odoo-1.0.0/CHANGELOG.md +46 -0
- mcp_odoo-1.0.0/Dockerfile +27 -0
- mcp_odoo-1.0.0/Dockerfile.odoo +8 -0
- mcp_odoo-1.0.0/LICENSE +21 -0
- mcp_odoo-1.0.0/PKG-INFO +1402 -0
- mcp_odoo-1.0.0/README.es.md +1401 -0
- mcp_odoo-1.0.0/README.md +1363 -0
- mcp_odoo-1.0.0/assets/odoo-mcp-logo.png +0 -0
- mcp_odoo-1.0.0/assets/odoo-mcp-logo.svg +197 -0
- mcp_odoo-1.0.0/docker-compose.yml +31 -0
- mcp_odoo-1.0.0/mcp_server_odoo/__init__.py +23 -0
- mcp_odoo-1.0.0/mcp_server_odoo/__main__.py +153 -0
- mcp_odoo-1.0.0/mcp_server_odoo/access_control.py +862 -0
- mcp_odoo-1.0.0/mcp_server_odoo/binary_reads.py +130 -0
- mcp_odoo-1.0.0/mcp_server_odoo/config.py +405 -0
- mcp_odoo-1.0.0/mcp_server_odoo/error_handling.py +311 -0
- mcp_odoo-1.0.0/mcp_server_odoo/error_sanitizer.py +628 -0
- mcp_odoo-1.0.0/mcp_server_odoo/field_security.py +171 -0
- mcp_odoo-1.0.0/mcp_server_odoo/file_types.py +111 -0
- mcp_odoo-1.0.0/mcp_server_odoo/formatters.py +625 -0
- mcp_odoo-1.0.0/mcp_server_odoo/json2_client.py +363 -0
- mcp_odoo-1.0.0/mcp_server_odoo/json_values.py +43 -0
- mcp_odoo-1.0.0/mcp_server_odoo/logging_config.py +341 -0
- mcp_odoo-1.0.0/mcp_server_odoo/odoo_connection.py +1733 -0
- mcp_odoo-1.0.0/mcp_server_odoo/odoo_errors.py +150 -0
- mcp_odoo-1.0.0/mcp_server_odoo/performance.py +551 -0
- mcp_odoo-1.0.0/mcp_server_odoo/resources.py +1704 -0
- mcp_odoo-1.0.0/mcp_server_odoo/schemas.py +436 -0
- mcp_odoo-1.0.0/mcp_server_odoo/server.py +505 -0
- mcp_odoo-1.0.0/mcp_server_odoo/tools.py +4940 -0
- mcp_odoo-1.0.0/mcp_server_odoo/uri_schema.py +398 -0
- mcp_odoo-1.0.0/mcp_server_odoo/user_context.py +266 -0
- mcp_odoo-1.0.0/pyproject.toml +116 -0
- mcp_odoo-1.0.0/tests/__init__.py +1 -0
- mcp_odoo-1.0.0/tests/conftest.py +237 -0
- mcp_odoo-1.0.0/tests/docker/test-lb/compose.yml +35 -0
- mcp_odoo-1.0.0/tests/docker/test-lb/nginx.conf +46 -0
- mcp_odoo-1.0.0/tests/helpers/__init__.py +1 -0
- mcp_odoo-1.0.0/tests/helpers/flaky_proxy.py +241 -0
- mcp_odoo-1.0.0/tests/helpers/mcp_simple_diagnostic.py +91 -0
- mcp_odoo-1.0.0/tests/helpers/mcp_test_client.py +288 -0
- mcp_odoo-1.0.0/tests/helpers/model_discovery.py +223 -0
- mcp_odoo-1.0.0/tests/helpers/server_testing.py +242 -0
- mcp_odoo-1.0.0/tests/helpers/transport_client.py +226 -0
- mcp_odoo-1.0.0/tests/mcp_client_validation.sh +86 -0
- mcp_odoo-1.0.0/tests/test_access_control.py +898 -0
- mcp_odoo-1.0.0/tests/test_access_control_yolo.py +207 -0
- mcp_odoo-1.0.0/tests/test_advanced_resources.py +474 -0
- mcp_odoo-1.0.0/tests/test_attachment_tools.py +486 -0
- mcp_odoo-1.0.0/tests/test_auth_matrix.py +567 -0
- mcp_odoo-1.0.0/tests/test_authentication.py +722 -0
- mcp_odoo-1.0.0/tests/test_basic_resources.py +2182 -0
- mcp_odoo-1.0.0/tests/test_batch_write_tools.py +283 -0
- mcp_odoo-1.0.0/tests/test_binary_reads.py +40 -0
- mcp_odoo-1.0.0/tests/test_caching.py +243 -0
- mcp_odoo-1.0.0/tests/test_config.py +687 -0
- mcp_odoo-1.0.0/tests/test_context_param.py +457 -0
- mcp_odoo-1.0.0/tests/test_data_formatting.py +878 -0
- mcp_odoo-1.0.0/tests/test_database_discovery.py +440 -0
- mcp_odoo-1.0.0/tests/test_datetime_formatting.py +99 -0
- mcp_odoo-1.0.0/tests/test_e2e_yolo.py +737 -0
- mcp_odoo-1.0.0/tests/test_error_handling.py +354 -0
- mcp_odoo-1.0.0/tests/test_error_sanitization_integration.py +157 -0
- mcp_odoo-1.0.0/tests/test_error_sanitizer.py +841 -0
- mcp_odoo-1.0.0/tests/test_fixes_integration.py +194 -0
- mcp_odoo-1.0.0/tests/test_integration_e2e.py +647 -0
- mcp_odoo-1.0.0/tests/test_json2_client.py +946 -0
- mcp_odoo-1.0.0/tests/test_keepalive_recovery_e2e.py +400 -0
- mcp_odoo-1.0.0/tests/test_locale.py +326 -0
- mcp_odoo-1.0.0/tests/test_main_cli.py +105 -0
- mcp_odoo-1.0.0/tests/test_mcp_client_validation.py +246 -0
- mcp_odoo-1.0.0/tests/test_odoo_connection_basic.py +559 -0
- mcp_odoo-1.0.0/tests/test_odoo_connection_crud.py +802 -0
- mcp_odoo-1.0.0/tests/test_package_structure.py +98 -0
- mcp_odoo-1.0.0/tests/test_performance.py +782 -0
- mcp_odoo-1.0.0/tests/test_protocol_v2.py +184 -0
- mcp_odoo-1.0.0/tests/test_resource_query_params.py +289 -0
- mcp_odoo-1.0.0/tests/test_schema_rules.py +158 -0
- mcp_odoo-1.0.0/tests/test_search_resources.py +594 -0
- mcp_odoo-1.0.0/tests/test_search_smart_defaults.py +315 -0
- mcp_odoo-1.0.0/tests/test_server_foundation.py +1362 -0
- mcp_odoo-1.0.0/tests/test_smart_fields.py +600 -0
- mcp_odoo-1.0.0/tests/test_tools.py +7364 -0
- mcp_odoo-1.0.0/tests/test_tools_yolo.py +842 -0
- mcp_odoo-1.0.0/tests/test_transport_e2e.py +229 -0
- mcp_odoo-1.0.0/tests/test_transport_integration.py +214 -0
- mcp_odoo-1.0.0/tests/test_uri_schema.py +355 -0
- mcp_odoo-1.0.0/tests/test_user_context.py +501 -0
- mcp_odoo-1.0.0/tests/test_write_operations.py +161 -0
- mcp_odoo-1.0.0/tests/test_write_tools.py +1103 -0
- mcp_odoo-1.0.0/tests/test_xmlrpc_operations.py +328 -0
- mcp_odoo-1.0.0/uv.lock +1806 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Odoo MCP Server Configuration
|
|
2
|
+
# Copy this file to .env and update with your Odoo instance details
|
|
3
|
+
|
|
4
|
+
# Server Configuration
|
|
5
|
+
# ====================
|
|
6
|
+
|
|
7
|
+
# Odoo server URL (required)
|
|
8
|
+
# The URL where your Odoo instance is running
|
|
9
|
+
ODOO_URL=http://localhost:8069
|
|
10
|
+
|
|
11
|
+
# Database name (optional)
|
|
12
|
+
# If not specified, will be auto-detected from Odoo
|
|
13
|
+
# ODOO_DB=your-database-name
|
|
14
|
+
|
|
15
|
+
# Authentication Configuration
|
|
16
|
+
# ============================
|
|
17
|
+
|
|
18
|
+
# Authentication method 1: API key (preferred)
|
|
19
|
+
# Generate in Odoo: Settings > Users & Companies > Users > API Keys
|
|
20
|
+
ODOO_API_KEY=your-api-key-here
|
|
21
|
+
|
|
22
|
+
# Authentication method 2: Username/password (fallback)
|
|
23
|
+
# Only used if ODOO_API_KEY is not provided
|
|
24
|
+
# ODOO_USER=your-username
|
|
25
|
+
# ODOO_PASSWORD=your-password
|
|
26
|
+
|
|
27
|
+
# Locale Configuration
|
|
28
|
+
# ====================
|
|
29
|
+
|
|
30
|
+
# Language/locale for Odoo responses (optional)
|
|
31
|
+
# When set, Odoo returns translated field labels, selection values, and messages
|
|
32
|
+
# Must be a locale installed in your Odoo instance (e.g. es_ES, fr_FR, de_DE)
|
|
33
|
+
# ODOO_LOCALE=es_ES
|
|
34
|
+
|
|
35
|
+
# Company scope (optional, multi-company databases)
|
|
36
|
+
# Comma-separated company IDs. Every call runs with these as Odoo's allowed
|
|
37
|
+
# companies; the first one is the active company. Each ID must be one of the
|
|
38
|
+
# user's companies, or the server does not start. If the user cannot read their
|
|
39
|
+
# own res.users record (standard mode without res.users enabled), the check is
|
|
40
|
+
# skipped with a warning and Odoo refuses a foreign company on each call.
|
|
41
|
+
# This is not a security boundary: restrict the user's companies in Odoo for that.
|
|
42
|
+
# ODOO_ALLOWED_COMPANIES=1,3
|
|
43
|
+
|
|
44
|
+
# YOLO Mode (Development/Testing Only!)
|
|
45
|
+
# ======================================
|
|
46
|
+
|
|
47
|
+
# Bypasses MCP module — connects directly to standard XML-RPC endpoints, or to
|
|
48
|
+
# JSON-2 (/json/2) on Odoo 19 and later with an API key (see ODOO_RPC_TRANSPORT)
|
|
49
|
+
# Valid values: off (default), read (read-only), true (full CRUD)
|
|
50
|
+
# In standard mode (off), the server keeps each model's MCP permissions for
|
|
51
|
+
# 5 minutes. A permission removed in Odoo is refused at once, because the
|
|
52
|
+
# module checks every call. A permission granted in Odoo can take up to
|
|
53
|
+
# 5 minutes to work; restart the server to apply it at once.
|
|
54
|
+
# ODOO_YOLO=off
|
|
55
|
+
|
|
56
|
+
# Enable the call_model_method tool (generic XML-RPC execute_kw escape hatch).
|
|
57
|
+
# Requires ODOO_YOLO=true; ignored otherwise. The tool can invoke any public
|
|
58
|
+
# Odoo method including destructive ones — enable only in trusted environments.
|
|
59
|
+
# ODOO_MCP_ENABLE_METHOD_CALLS=false
|
|
60
|
+
|
|
61
|
+
# RPC protocol to Odoo in YOLO mode: auto (default), xmlrpc or json2.
|
|
62
|
+
# json2 uses Odoo's JSON-2 API (/json/2), which needs Odoo 19 or later and an
|
|
63
|
+
# API key with the rpc scope. It reads the user from the key, so ODOO_USER is
|
|
64
|
+
# not needed. auto uses JSON-2 when YOLO mode has an API key and Odoo is 19 or
|
|
65
|
+
# later, and XML-RPC otherwise (then ODOO_USER is needed with the key).
|
|
66
|
+
# Standard mode always uses XML-RPC.
|
|
67
|
+
# ODOO_RPC_TRANSPORT=auto
|
|
68
|
+
|
|
69
|
+
# Logging Configuration
|
|
70
|
+
# =====================
|
|
71
|
+
|
|
72
|
+
# Log level (optional)
|
|
73
|
+
# Valid levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
|
|
74
|
+
# ODOO_MCP_LOG_LEVEL=INFO
|
|
75
|
+
|
|
76
|
+
# Enable structured JSON log output (optional)
|
|
77
|
+
# ODOO_MCP_LOG_JSON=false
|
|
78
|
+
|
|
79
|
+
# Path for rotating log file — 10 MB, 5 backups (optional)
|
|
80
|
+
# ODOO_MCP_LOG_FILE=/var/log/odoomcp.log
|
|
81
|
+
|
|
82
|
+
# Custom Python logging format string (optional)
|
|
83
|
+
# ODOO_MCP_LOG_FORMAT=%(asctime)s - %(name)s - %(levelname)s - %(message)s
|
|
84
|
+
|
|
85
|
+
# Performance Configuration
|
|
86
|
+
# =========================
|
|
87
|
+
|
|
88
|
+
# Default pagination limit (optional)
|
|
89
|
+
# Number of records to return by default
|
|
90
|
+
# ODOO_MCP_DEFAULT_LIMIT=25
|
|
91
|
+
|
|
92
|
+
# Maximum pagination limit (optional)
|
|
93
|
+
# Maximum number of records that can be requested
|
|
94
|
+
# ODOO_MCP_MAX_LIMIT=100
|
|
95
|
+
|
|
96
|
+
# Maximum fields returned by smart field selection (optional)
|
|
97
|
+
# ODOO_MCP_MAX_SMART_FIELDS=15
|
|
98
|
+
|
|
99
|
+
# Threshold in milliseconds above which an operation is logged as slow (optional)
|
|
100
|
+
# ODOO_MCP_SLOW_OPERATION_THRESHOLD_MS=1000
|
|
101
|
+
|
|
102
|
+
# Transport Configuration
|
|
103
|
+
# =======================
|
|
104
|
+
|
|
105
|
+
# Transport type (optional)
|
|
106
|
+
# Valid values: stdio (default), streamable-http
|
|
107
|
+
# ODOO_MCP_TRANSPORT=stdio
|
|
108
|
+
|
|
109
|
+
# Server host for HTTP transport (optional)
|
|
110
|
+
# Only used when transport is streamable-http
|
|
111
|
+
# ODOO_MCP_HOST=localhost
|
|
112
|
+
|
|
113
|
+
# Server port for HTTP transport (optional)
|
|
114
|
+
# Only used when transport is streamable-http
|
|
115
|
+
# ODOO_MCP_PORT=8000
|
|
116
|
+
|
|
117
|
+
# Allowed Host headers for HTTP transport DNS-rebinding protection (optional)
|
|
118
|
+
# Comma-separated; set when running streamable-http behind a reverse proxy
|
|
119
|
+
# that forwards an external host. Unset, protection is auto-enabled only for
|
|
120
|
+
# a loopback bind (the default localhost), which then accepts loopback Host
|
|
121
|
+
# headers alone; any other bind (e.g. 0.0.0.0) runs with no validation.
|
|
122
|
+
# ODOO_MCP_ALLOWED_HOSTS=odoo.example.com,localhost
|
|
123
|
+
|
|
124
|
+
# Seconds of inactivity before an HTTP session is closed (optional)
|
|
125
|
+
# Frees the session's server-side state. Unset = sessions never expire.
|
|
126
|
+
# The server holds at most 10,000 open sessions (HTTP 503 beyond that).
|
|
127
|
+
# ODOO_MCP_SESSION_IDLE_TIMEOUT=600
|
|
128
|
+
|
|
129
|
+
# Max bytes for a single binary/attachment resource read (optional)
|
|
130
|
+
# Checked before the payload is fetched. Default 52428800 (50 MB).
|
|
131
|
+
# ODOO_MCP_MAX_BINARY_SIZE=52428800
|
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
# push runs only on long-lived branches; the pull_request trigger covers
|
|
4
|
+
# feature branches ('*' did not match slash-named branches and double-ran
|
|
5
|
+
# flat-named branches with open PRs)
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main, dev]
|
|
9
|
+
pull_request:
|
|
10
|
+
# '**', not '*': '*' does not match a '/', so PRs against release/* ran no CI
|
|
11
|
+
branches: ['**']
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
15
|
+
cancel-in-progress: true
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
lint:
|
|
19
|
+
name: Lint and Type Check
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v7
|
|
24
|
+
|
|
25
|
+
- name: Set up Python
|
|
26
|
+
uses: actions/setup-python@v7
|
|
27
|
+
with:
|
|
28
|
+
python-version: '3.10'
|
|
29
|
+
|
|
30
|
+
- name: Install uv
|
|
31
|
+
uses: astral-sh/setup-uv@v7
|
|
32
|
+
with:
|
|
33
|
+
version: "latest"
|
|
34
|
+
enable-cache: true
|
|
35
|
+
|
|
36
|
+
- name: Install dependencies
|
|
37
|
+
run: |
|
|
38
|
+
uv pip install --system -e ".[dev]"
|
|
39
|
+
|
|
40
|
+
- name: Check code formatting with Ruff
|
|
41
|
+
run: |
|
|
42
|
+
ruff format --check --diff .
|
|
43
|
+
|
|
44
|
+
- name: Lint with Ruff
|
|
45
|
+
run: |
|
|
46
|
+
ruff check . --output-format=github
|
|
47
|
+
|
|
48
|
+
- name: Type check with ty
|
|
49
|
+
run: |
|
|
50
|
+
ty check .
|
|
51
|
+
|
|
52
|
+
test:
|
|
53
|
+
name: Test Python ${{ matrix.python-version }}
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
strategy:
|
|
56
|
+
matrix:
|
|
57
|
+
python-version: ['3.10', '3.13']
|
|
58
|
+
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/checkout@v7
|
|
61
|
+
|
|
62
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
63
|
+
uses: actions/setup-python@v7
|
|
64
|
+
with:
|
|
65
|
+
python-version: ${{ matrix.python-version }}
|
|
66
|
+
|
|
67
|
+
- name: Install uv
|
|
68
|
+
uses: astral-sh/setup-uv@v7
|
|
69
|
+
with:
|
|
70
|
+
version: "latest"
|
|
71
|
+
enable-cache: true
|
|
72
|
+
|
|
73
|
+
- name: Install dependencies
|
|
74
|
+
run: |
|
|
75
|
+
uv pip install --system -e ".[dev]"
|
|
76
|
+
|
|
77
|
+
- name: Run unit tests with coverage
|
|
78
|
+
run: |
|
|
79
|
+
pytest -m "not yolo and not mcp" --cov=mcp_server_odoo --cov-report=xml:coverage-unit.xml --cov-report=term
|
|
80
|
+
env:
|
|
81
|
+
ODOO_URL: ${{ vars.ODOO_URL || 'http://localhost:8069' }}
|
|
82
|
+
ODOO_DB: ${{ vars.ODOO_DB || 'test' }}
|
|
83
|
+
ODOO_API_KEY: ${{ vars.ODOO_API_KEY || 'test_api_key' }}
|
|
84
|
+
ODOO_USER: ${{ vars.ODOO_USER || 'admin' }}
|
|
85
|
+
ODOO_PASSWORD: ${{ vars.ODOO_PASSWORD || 'admin' }}
|
|
86
|
+
|
|
87
|
+
- name: Upload coverage artifact
|
|
88
|
+
if: matrix.python-version == '3.10'
|
|
89
|
+
uses: actions/upload-artifact@v7
|
|
90
|
+
with:
|
|
91
|
+
name: coverage-unit
|
|
92
|
+
path: coverage-unit.xml
|
|
93
|
+
|
|
94
|
+
yolo-integration-test:
|
|
95
|
+
# ODOO_RPC_TRANSPORT=auto takes JSON-2 on Odoo 19 and later; those
|
|
96
|
+
# versions also run once over XML-RPC. Each leg fails unless the
|
|
97
|
+
# transport in use is the one in its name (tests/test_transport_e2e.py).
|
|
98
|
+
name: YOLO Integration Tests (Odoo ${{ matrix.odoo }}, ${{ matrix.label }})
|
|
99
|
+
runs-on: ubuntu-latest
|
|
100
|
+
needs: [lint, test]
|
|
101
|
+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
|
|
102
|
+
strategy:
|
|
103
|
+
fail-fast: false
|
|
104
|
+
matrix:
|
|
105
|
+
include:
|
|
106
|
+
- {odoo: '16', rpc: auto, expect: xmlrpc, label: XML-RPC}
|
|
107
|
+
- {odoo: '17', rpc: auto, expect: xmlrpc, label: XML-RPC}
|
|
108
|
+
- {odoo: '18', rpc: auto, expect: xmlrpc, label: XML-RPC}
|
|
109
|
+
- {odoo: '19', rpc: auto, expect: json2, label: JSON-2}
|
|
110
|
+
- {odoo: '19', rpc: xmlrpc, expect: xmlrpc, label: XML-RPC}
|
|
111
|
+
- {odoo: '20', rpc: auto, expect: json2, label: JSON-2}
|
|
112
|
+
- {odoo: '20', rpc: xmlrpc, expect: xmlrpc, label: XML-RPC}
|
|
113
|
+
|
|
114
|
+
services:
|
|
115
|
+
postgres:
|
|
116
|
+
image: postgres:17
|
|
117
|
+
env:
|
|
118
|
+
POSTGRES_DB: postgres
|
|
119
|
+
POSTGRES_USER: odoo
|
|
120
|
+
POSTGRES_PASSWORD: odoo
|
|
121
|
+
ports:
|
|
122
|
+
- 5432:5432
|
|
123
|
+
options: >-
|
|
124
|
+
--health-cmd="pg_isready -U odoo"
|
|
125
|
+
--health-interval=10s
|
|
126
|
+
--health-timeout=5s
|
|
127
|
+
--health-retries=5
|
|
128
|
+
|
|
129
|
+
steps:
|
|
130
|
+
- uses: actions/checkout@v7
|
|
131
|
+
|
|
132
|
+
- name: Set up Python
|
|
133
|
+
uses: actions/setup-python@v7
|
|
134
|
+
with:
|
|
135
|
+
python-version: '3.13'
|
|
136
|
+
|
|
137
|
+
- name: Install uv
|
|
138
|
+
uses: astral-sh/setup-uv@v7
|
|
139
|
+
with:
|
|
140
|
+
version: "latest"
|
|
141
|
+
enable-cache: true
|
|
142
|
+
|
|
143
|
+
- name: Install dependencies
|
|
144
|
+
run: |
|
|
145
|
+
uv pip install --system -e ".[dev]"
|
|
146
|
+
|
|
147
|
+
- name: Start Odoo and initialize database
|
|
148
|
+
run: |
|
|
149
|
+
# --http-interface 0.0.0.0: Odoo 20 listens on 127.0.0.1 by default,
|
|
150
|
+
# which the published port cannot reach
|
|
151
|
+
docker run -d --name odoo --network "${{ job.services.postgres.network }}" \
|
|
152
|
+
-e HOST=postgres -e USER=odoo -e PASSWORD=odoo \
|
|
153
|
+
-p 8069:8069 \
|
|
154
|
+
odoo:${{ matrix.odoo }} -- --http-interface 0.0.0.0 --database test --init base,mail --without-demo all
|
|
155
|
+
|
|
156
|
+
# Wait for Odoo to finish initializing
|
|
157
|
+
echo "Waiting for Odoo to initialize database..."
|
|
158
|
+
for i in $(seq 1 60); do
|
|
159
|
+
if python -c "
|
|
160
|
+
import xmlrpc.client
|
|
161
|
+
try:
|
|
162
|
+
proxy = xmlrpc.client.ServerProxy('http://localhost:8069/xmlrpc/2/common')
|
|
163
|
+
uid = proxy.authenticate('test', 'admin', 'admin', {})
|
|
164
|
+
if uid:
|
|
165
|
+
print(f'Odoo ready, authenticated as uid={uid}')
|
|
166
|
+
exit(0)
|
|
167
|
+
except Exception as e:
|
|
168
|
+
exit(1)
|
|
169
|
+
" 2>/dev/null; then
|
|
170
|
+
echo "Odoo is ready!"
|
|
171
|
+
exit 0
|
|
172
|
+
fi
|
|
173
|
+
echo "Waiting... ($i/60)"
|
|
174
|
+
sleep 5
|
|
175
|
+
done
|
|
176
|
+
# Fail here: tests/conftest.py skips every test when Odoo does not
|
|
177
|
+
# answer, so the leg would pass while testing nothing
|
|
178
|
+
echo "::error::Odoo did not answer within 5 minutes"
|
|
179
|
+
docker logs --tail 50 odoo
|
|
180
|
+
exit 1
|
|
181
|
+
|
|
182
|
+
- name: Generate API key for admin user
|
|
183
|
+
id: yolo-apikey
|
|
184
|
+
run: |
|
|
185
|
+
# Generate a random API key and compute its passlib hash inside the
|
|
186
|
+
# Odoo container (which already has passlib installed).
|
|
187
|
+
KEY_AND_HASH=$(docker exec odoo python3 -c "
|
|
188
|
+
import secrets
|
|
189
|
+
from passlib.context import CryptContext
|
|
190
|
+
key = secrets.token_hex(20)
|
|
191
|
+
ctx = CryptContext(['pbkdf2_sha512'])
|
|
192
|
+
key_hash = ctx.hash(key)
|
|
193
|
+
# Use pipe separator — safe because neither key nor hash contains |
|
|
194
|
+
print(f'{key}|{key_hash}')
|
|
195
|
+
")
|
|
196
|
+
|
|
197
|
+
API_KEY=$(echo "$KEY_AND_HASH" | cut -d'|' -f1)
|
|
198
|
+
KEY_HASH=$(echo "$KEY_AND_HASH" | cut -d'|' -f2)
|
|
199
|
+
INDEX=${API_KEY:0:8}
|
|
200
|
+
|
|
201
|
+
# Insert into Odoo's API key table using dollar-quoting for the hash
|
|
202
|
+
# (passlib hashes contain $ characters that break normal SQL quoting).
|
|
203
|
+
# Note: res_users_apikeys has _log_access=False, so no create_uid/write_uid columns.
|
|
204
|
+
# Scope 'rpc': Odoo 20 matches the scope exactly; 16 to 19 also accept NULL.
|
|
205
|
+
PGPASSWORD=odoo psql -h localhost -U odoo -d test -c \
|
|
206
|
+
"INSERT INTO res_users_apikeys (name, user_id, scope, index, key)
|
|
207
|
+
VALUES ('CI Test Key', 2, 'rpc', '${INDEX}', \$hash\$${KEY_HASH}\$hash\$)"
|
|
208
|
+
|
|
209
|
+
echo "key=${API_KEY}" >> "$GITHUB_OUTPUT"
|
|
210
|
+
echo "API key generated and inserted for admin user"
|
|
211
|
+
|
|
212
|
+
- name: Run YOLO integration tests
|
|
213
|
+
run: |
|
|
214
|
+
pytest -m "yolo" -v --cov=mcp_server_odoo --cov-report=xml:coverage-yolo-${{ matrix.odoo }}-${{ matrix.rpc }}.xml --cov-report=term
|
|
215
|
+
env:
|
|
216
|
+
ODOO_URL: http://localhost:8069
|
|
217
|
+
ODOO_DB: test
|
|
218
|
+
ODOO_USER: admin
|
|
219
|
+
ODOO_PASSWORD: admin
|
|
220
|
+
ODOO_YOLO: "true"
|
|
221
|
+
ODOO_MCP_ENABLE_METHOD_CALLS: "true"
|
|
222
|
+
ODOO_API_KEY: ${{ steps.yolo-apikey.outputs.key }}
|
|
223
|
+
ODOO_RPC_TRANSPORT: ${{ matrix.rpc }}
|
|
224
|
+
ODOO_EXPECT_RPC_TRANSPORT: ${{ matrix.expect }}
|
|
225
|
+
|
|
226
|
+
- name: Upload coverage artifact
|
|
227
|
+
if: always()
|
|
228
|
+
uses: actions/upload-artifact@v7
|
|
229
|
+
with:
|
|
230
|
+
name: coverage-yolo-${{ matrix.odoo }}-${{ matrix.rpc }}
|
|
231
|
+
path: coverage-yolo-${{ matrix.odoo }}-${{ matrix.rpc }}.xml
|
|
232
|
+
|
|
233
|
+
mcp-integration-test:
|
|
234
|
+
# Each leg runs the module branch of its Odoo version
|
|
235
|
+
name: MCP Integration Tests (Odoo ${{ matrix.odoo }})
|
|
236
|
+
runs-on: ubuntu-latest
|
|
237
|
+
needs: [lint, test]
|
|
238
|
+
# Disabled: this job checks out the Odoo MCP module from
|
|
239
|
+
# much-GmbH/much-mcp-server (previous repository) using
|
|
240
|
+
# secrets.MCP_MODULE_PAT — neither exists in this repository, so the
|
|
241
|
+
# checkout fails with "Input required and not supplied: token".
|
|
242
|
+
# Re-enable with the original `if:` guard once the module lives
|
|
243
|
+
# somewhere accessible. `build` already tolerates a skipped job.
|
|
244
|
+
if: false
|
|
245
|
+
strategy:
|
|
246
|
+
fail-fast: false
|
|
247
|
+
matrix:
|
|
248
|
+
odoo: ['16', '17', '18', '19', '20']
|
|
249
|
+
|
|
250
|
+
services:
|
|
251
|
+
postgres:
|
|
252
|
+
image: postgres:17
|
|
253
|
+
env:
|
|
254
|
+
POSTGRES_DB: postgres
|
|
255
|
+
POSTGRES_USER: odoo
|
|
256
|
+
POSTGRES_PASSWORD: odoo
|
|
257
|
+
ports:
|
|
258
|
+
- 5432:5432
|
|
259
|
+
options: >-
|
|
260
|
+
--health-cmd="pg_isready -U odoo"
|
|
261
|
+
--health-interval=10s
|
|
262
|
+
--health-timeout=5s
|
|
263
|
+
--health-retries=5
|
|
264
|
+
|
|
265
|
+
steps:
|
|
266
|
+
- uses: actions/checkout@v7
|
|
267
|
+
|
|
268
|
+
- name: Checkout MCP Odoo module
|
|
269
|
+
uses: actions/checkout@v7
|
|
270
|
+
with:
|
|
271
|
+
repository: much-GmbH/much-mcp-server
|
|
272
|
+
ref: '${{ matrix.odoo }}.0'
|
|
273
|
+
path: odoo-apps
|
|
274
|
+
token: ${{ secrets.MCP_MODULE_PAT }}
|
|
275
|
+
|
|
276
|
+
- name: Set up Python
|
|
277
|
+
uses: actions/setup-python@v7
|
|
278
|
+
with:
|
|
279
|
+
python-version: '3.13'
|
|
280
|
+
|
|
281
|
+
- name: Install uv
|
|
282
|
+
uses: astral-sh/setup-uv@v7
|
|
283
|
+
with:
|
|
284
|
+
version: "latest"
|
|
285
|
+
enable-cache: true
|
|
286
|
+
|
|
287
|
+
- name: Install dependencies
|
|
288
|
+
run: |
|
|
289
|
+
uv pip install --system -e ".[dev]"
|
|
290
|
+
|
|
291
|
+
- name: Build Odoo image with the module's Python dependencies
|
|
292
|
+
run: |
|
|
293
|
+
# mcp_server declares external_dependencies in its manifest (2.x:
|
|
294
|
+
# authlib, defusedxml, packaging; 1.x: defusedxml); Odoo refuses to
|
|
295
|
+
# install the module if any are missing. They are read from the
|
|
296
|
+
# branch's own manifest, with its version constraints.
|
|
297
|
+
# PIP_BREAK_SYSTEM_PACKAGES, not the flag: pip 20 and 22 in the
|
|
298
|
+
# odoo:16 and odoo:17 images do not know --break-system-packages.
|
|
299
|
+
DEPS=$(python -c "import ast, shlex; m = ast.literal_eval(open('odoo-apps/mcp_server/__manifest__.py').read()); print(' '.join(shlex.quote(d) for d in m.get('external_dependencies', {}).get('python', [])))")
|
|
300
|
+
echo "Module dependencies: $DEPS"
|
|
301
|
+
cat > Dockerfile.ci <<EOF
|
|
302
|
+
FROM odoo:${{ matrix.odoo }}
|
|
303
|
+
USER root
|
|
304
|
+
ENV PIP_BREAK_SYSTEM_PACKAGES=1
|
|
305
|
+
RUN python3 -m pip install --no-cache-dir $DEPS
|
|
306
|
+
USER odoo
|
|
307
|
+
EOF
|
|
308
|
+
docker build -t odoo-mcp-ci:${{ matrix.odoo }} -f Dockerfile.ci .
|
|
309
|
+
|
|
310
|
+
- name: Start Odoo with MCP module and initialize database
|
|
311
|
+
run: |
|
|
312
|
+
# --http-interface 0.0.0.0: see the YOLO job
|
|
313
|
+
docker run -d --name odoo-mcp --network "${{ job.services.postgres.network }}" \
|
|
314
|
+
-e HOST=postgres -e USER=odoo -e PASSWORD=odoo \
|
|
315
|
+
-v "${{ github.workspace }}/odoo-apps:/mnt/extra-addons" \
|
|
316
|
+
-p 8069:8069 \
|
|
317
|
+
odoo-mcp-ci:${{ matrix.odoo }} -- --http-interface 0.0.0.0 --database test --init base,mcp_server --without-demo all
|
|
318
|
+
|
|
319
|
+
# Wait for Odoo to finish initializing (includes MCP module install)
|
|
320
|
+
echo "Waiting for Odoo to initialize database with MCP module..."
|
|
321
|
+
for i in $(seq 1 90); do
|
|
322
|
+
if python -c "
|
|
323
|
+
import xmlrpc.client
|
|
324
|
+
try:
|
|
325
|
+
proxy = xmlrpc.client.ServerProxy('http://localhost:8069/xmlrpc/2/common')
|
|
326
|
+
uid = proxy.authenticate('test', 'admin', 'admin', {})
|
|
327
|
+
if uid:
|
|
328
|
+
print(f'Odoo ready, authenticated as uid={uid}')
|
|
329
|
+
exit(0)
|
|
330
|
+
except Exception as e:
|
|
331
|
+
exit(1)
|
|
332
|
+
" 2>/dev/null; then
|
|
333
|
+
echo "Odoo is ready!"
|
|
334
|
+
exit 0
|
|
335
|
+
fi
|
|
336
|
+
echo "Waiting... ($i/90)"
|
|
337
|
+
sleep 5
|
|
338
|
+
done
|
|
339
|
+
echo "::error::Odoo did not answer within 7.5 minutes"
|
|
340
|
+
docker logs --tail 50 odoo-mcp
|
|
341
|
+
exit 1
|
|
342
|
+
|
|
343
|
+
- name: Configure MCP module
|
|
344
|
+
run: |
|
|
345
|
+
python -c "
|
|
346
|
+
import xmlrpc.client
|
|
347
|
+
|
|
348
|
+
url = 'http://localhost:8069'
|
|
349
|
+
db = 'test'
|
|
350
|
+
|
|
351
|
+
common = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/common')
|
|
352
|
+
uid = common.authenticate(db, 'admin', 'admin', {})
|
|
353
|
+
assert uid, 'Failed to authenticate'
|
|
354
|
+
print(f'Authenticated as uid={uid}')
|
|
355
|
+
|
|
356
|
+
models = xmlrpc.client.ServerProxy(f'{url}/xmlrpc/2/object')
|
|
357
|
+
|
|
358
|
+
# Enable MCP with API key validation. Rate limiting is disabled in CI:
|
|
359
|
+
# the suite hits the addon's ~300/min ceiling because all tests run
|
|
360
|
+
# under the single admin API key. Disabling it here keeps tests
|
|
361
|
+
# deterministic — production deployments leave it on (default True).
|
|
362
|
+
for param, value in [
|
|
363
|
+
('mcp_server.enabled', 'True'),
|
|
364
|
+
('mcp_server.use_api_keys', 'True'),
|
|
365
|
+
('mcp_server.enable_rate_limiting', 'False'),
|
|
366
|
+
]:
|
|
367
|
+
# search/write/create, not set_param: Odoo 20 replaced it with
|
|
368
|
+
# typed setters (set_bool, set_str)
|
|
369
|
+
ids = models.execute_kw(db, uid, 'admin', 'ir.config_parameter', 'search', [[('key', '=', param)]])
|
|
370
|
+
if ids:
|
|
371
|
+
models.execute_kw(db, uid, 'admin', 'ir.config_parameter', 'write', [ids, {'value': value}])
|
|
372
|
+
else:
|
|
373
|
+
models.execute_kw(db, uid, 'admin', 'ir.config_parameter', 'create', [{'key': param, 'value': value}])
|
|
374
|
+
print('MCP enabled, API keys enabled, rate limiting disabled (CI only)')
|
|
375
|
+
|
|
376
|
+
# Enable models with permissions matching auth-test-matrix.md:
|
|
377
|
+
# - res.partner: read+write+unlink only (create=False for restricted ops test)
|
|
378
|
+
# - res.company: full CRUD (used by write cycle tests)
|
|
379
|
+
# - res.country: read only (unlink=False for restricted ops test)
|
|
380
|
+
# - res.users: NOT enabled (read denied for restricted ops test)
|
|
381
|
+
model_permissions = {
|
|
382
|
+
'res.partner': {'allow_read': True, 'allow_create': False, 'allow_write': True, 'allow_unlink': True},
|
|
383
|
+
'res.company': {'allow_read': True, 'allow_create': True, 'allow_write': True, 'allow_unlink': True},
|
|
384
|
+
'res.country': {'allow_read': True, 'allow_create': False, 'allow_write': False, 'allow_unlink': False},
|
|
385
|
+
}
|
|
386
|
+
for model_name, perms in model_permissions.items():
|
|
387
|
+
model_ids = models.execute_kw(db, uid, 'admin', 'ir.model', 'search', [
|
|
388
|
+
[('model', '=', model_name)]
|
|
389
|
+
])
|
|
390
|
+
if model_ids:
|
|
391
|
+
models.execute_kw(db, uid, 'admin', 'mcp.enabled.model', 'create', [{
|
|
392
|
+
'model_id': model_ids[0],
|
|
393
|
+
**perms,
|
|
394
|
+
}])
|
|
395
|
+
print(f'Enabled model: {model_name} {perms}')
|
|
396
|
+
print('MCP setup complete (res.users intentionally NOT enabled)')
|
|
397
|
+
"
|
|
398
|
+
|
|
399
|
+
- name: Generate API key for admin user
|
|
400
|
+
id: mcp-apikey
|
|
401
|
+
run: |
|
|
402
|
+
KEY_AND_HASH=$(docker exec odoo-mcp python3 -c "
|
|
403
|
+
import secrets
|
|
404
|
+
from passlib.context import CryptContext
|
|
405
|
+
key = secrets.token_hex(20)
|
|
406
|
+
ctx = CryptContext(['pbkdf2_sha512'])
|
|
407
|
+
key_hash = ctx.hash(key)
|
|
408
|
+
print(f'{key}|{key_hash}')
|
|
409
|
+
")
|
|
410
|
+
|
|
411
|
+
API_KEY=$(echo "$KEY_AND_HASH" | cut -d'|' -f1)
|
|
412
|
+
KEY_HASH=$(echo "$KEY_AND_HASH" | cut -d'|' -f2)
|
|
413
|
+
INDEX=${API_KEY:0:8}
|
|
414
|
+
|
|
415
|
+
PGPASSWORD=odoo psql -h localhost -U odoo -d test -c \
|
|
416
|
+
"INSERT INTO res_users_apikeys (name, user_id, scope, index, key)
|
|
417
|
+
VALUES ('CI Test Key', 2, 'rpc', '${INDEX}', \$hash\$${KEY_HASH}\$hash\$)"
|
|
418
|
+
|
|
419
|
+
echo "key=${API_KEY}" >> "$GITHUB_OUTPUT"
|
|
420
|
+
echo "API key generated and inserted for admin user"
|
|
421
|
+
|
|
422
|
+
- name: Restart Odoo and require /mcp/health
|
|
423
|
+
run: |
|
|
424
|
+
# The 1.x module (Odoo 16 and 17) caches is_mcp_enabled() for five
|
|
425
|
+
# minutes, so the configuration above takes effect only after a
|
|
426
|
+
# restart. A new container without --init: restarting the old one
|
|
427
|
+
# would run the module install again.
|
|
428
|
+
docker rm -f odoo-mcp
|
|
429
|
+
docker run -d --name odoo-mcp --network "${{ job.services.postgres.network }}" \
|
|
430
|
+
-e HOST=postgres -e USER=odoo -e PASSWORD=odoo \
|
|
431
|
+
-v "${{ github.workspace }}/odoo-apps:/mnt/extra-addons" \
|
|
432
|
+
-p 8069:8069 \
|
|
433
|
+
odoo-mcp-ci:${{ matrix.odoo }} -- --http-interface 0.0.0.0 --database test
|
|
434
|
+
|
|
435
|
+
# Without /mcp/health, tests/conftest.py skips every mcp-marked test
|
|
436
|
+
# and the leg would pass while testing nothing.
|
|
437
|
+
for i in $(seq 1 60); do
|
|
438
|
+
if curl -fsS http://localhost:8069/mcp/health; then
|
|
439
|
+
exit 0
|
|
440
|
+
fi
|
|
441
|
+
sleep 2
|
|
442
|
+
done
|
|
443
|
+
echo "::error::GET /mcp/health did not answer, so every mcp-marked test would skip"
|
|
444
|
+
docker logs --tail 50 odoo-mcp
|
|
445
|
+
exit 1
|
|
446
|
+
|
|
447
|
+
- name: Run MCP integration tests
|
|
448
|
+
run: |
|
|
449
|
+
pytest -m "mcp" -v --cov=mcp_server_odoo --cov-report=xml:coverage-mcp-${{ matrix.odoo }}.xml --cov-report=term
|
|
450
|
+
env:
|
|
451
|
+
ODOO_URL: http://localhost:8069
|
|
452
|
+
ODOO_DB: test
|
|
453
|
+
ODOO_USER: admin
|
|
454
|
+
ODOO_PASSWORD: admin
|
|
455
|
+
ODOO_API_KEY: ${{ steps.mcp-apikey.outputs.key }}
|
|
456
|
+
|
|
457
|
+
- name: Upload coverage artifact
|
|
458
|
+
if: always()
|
|
459
|
+
uses: actions/upload-artifact@v7
|
|
460
|
+
with:
|
|
461
|
+
name: coverage-mcp-${{ matrix.odoo }}
|
|
462
|
+
path: coverage-mcp-${{ matrix.odoo }}.xml
|
|
463
|
+
|
|
464
|
+
coverage:
|
|
465
|
+
name: Upload Coverage
|
|
466
|
+
runs-on: ubuntu-latest
|
|
467
|
+
needs: [test, yolo-integration-test, mcp-integration-test]
|
|
468
|
+
if: always()
|
|
469
|
+
|
|
470
|
+
steps:
|
|
471
|
+
- uses: actions/checkout@v7
|
|
472
|
+
|
|
473
|
+
- name: Download coverage artifacts
|
|
474
|
+
uses: actions/download-artifact@v8
|
|
475
|
+
with:
|
|
476
|
+
pattern: coverage-*
|
|
477
|
+
merge-multiple: true
|
|
478
|
+
path: coverage-reports
|
|
479
|
+
|
|
480
|
+
- name: Set up Python
|
|
481
|
+
uses: actions/setup-python@v7
|
|
482
|
+
with:
|
|
483
|
+
python-version: '3.10'
|
|
484
|
+
|
|
485
|
+
- name: Merge and upload coverage
|
|
486
|
+
uses: codecov/codecov-action@v7
|
|
487
|
+
with:
|
|
488
|
+
directory: coverage-reports
|
|
489
|
+
flags: all
|
|
490
|
+
fail_ci_if_error: false
|
|
491
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
492
|
+
|
|
493
|
+
build:
|
|
494
|
+
name: Build Package
|
|
495
|
+
runs-on: ubuntu-latest
|
|
496
|
+
needs: [lint, test, yolo-integration-test, mcp-integration-test]
|
|
497
|
+
if: |
|
|
498
|
+
always()
|
|
499
|
+
&& needs.lint.result == 'success'
|
|
500
|
+
&& needs.test.result == 'success'
|
|
501
|
+
&& (needs.yolo-integration-test.result == 'success' || needs.yolo-integration-test.result == 'skipped')
|
|
502
|
+
&& (needs.mcp-integration-test.result == 'success' || needs.mcp-integration-test.result == 'skipped')
|
|
503
|
+
|
|
504
|
+
steps:
|
|
505
|
+
- uses: actions/checkout@v7
|
|
506
|
+
|
|
507
|
+
- name: Set up Python
|
|
508
|
+
uses: actions/setup-python@v7
|
|
509
|
+
with:
|
|
510
|
+
python-version: '3.10'
|
|
511
|
+
|
|
512
|
+
- name: Install build tools
|
|
513
|
+
run: |
|
|
514
|
+
pip install build twine
|
|
515
|
+
|
|
516
|
+
- name: Build package
|
|
517
|
+
run: |
|
|
518
|
+
python -m build
|
|
519
|
+
|
|
520
|
+
- name: Check package
|
|
521
|
+
run: |
|
|
522
|
+
twine check dist/*
|
|
523
|
+
|
|
524
|
+
- name: Upload artifacts
|
|
525
|
+
uses: actions/upload-artifact@v7
|
|
526
|
+
with:
|
|
527
|
+
name: python-package-distributions
|
|
528
|
+
path: dist/
|