biszx-odoo-mcp 1.1.1__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.

Potentially problematic release.


This version of biszx-odoo-mcp might be problematic. Click here for more details.

Files changed (31) hide show
  1. biszx_odoo_mcp-1.1.1/LICENSE +21 -0
  2. biszx_odoo_mcp-1.1.1/PKG-INFO +181 -0
  3. biszx_odoo_mcp-1.1.1/README.md +159 -0
  4. biszx_odoo_mcp-1.1.1/pyproject.toml +47 -0
  5. biszx_odoo_mcp-1.1.1/setup.cfg +4 -0
  6. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/__init__.py +3 -0
  7. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/__main__.py +49 -0
  8. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/exceptions.py +226 -0
  9. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/main.py +135 -0
  10. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/server/__init__.py +0 -0
  11. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/server/context.py +19 -0
  12. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/server/resources.py +230 -0
  13. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/server/response.py +36 -0
  14. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/server/tools.py +465 -0
  15. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/tools/__init__.py +0 -0
  16. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/tools/config.py +98 -0
  17. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp/tools/odoo_client.py +632 -0
  18. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp.egg-info/PKG-INFO +181 -0
  19. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp.egg-info/SOURCES.txt +29 -0
  20. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp.egg-info/dependency_links.txt +1 -0
  21. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp.egg-info/entry_points.txt +2 -0
  22. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp.egg-info/requires.txt +4 -0
  23. biszx_odoo_mcp-1.1.1/src/biszx_odoo_mcp.egg-info/top_level.txt +1 -0
  24. biszx_odoo_mcp-1.1.1/tests/test_config.py +235 -0
  25. biszx_odoo_mcp-1.1.1/tests/test_context.py +64 -0
  26. biszx_odoo_mcp-1.1.1/tests/test_exceptions.py +282 -0
  27. biszx_odoo_mcp-1.1.1/tests/test_main.py +197 -0
  28. biszx_odoo_mcp-1.1.1/tests/test_odoo_client.py +466 -0
  29. biszx_odoo_mcp-1.1.1/tests/test_resources.py +343 -0
  30. biszx_odoo_mcp-1.1.1/tests/test_response.py +155 -0
  31. biszx_odoo_mcp-1.1.1/tests/test_tools.py +732 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lê Anh Tuấn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: biszx-odoo-mcp
3
+ Version: 1.1.1
4
+ Summary: MCP Server for Odoo Integration
5
+ Author-email: Biszx <isares.br@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://gitlab.com/biszx/biszx-odoo-mcp
8
+ Project-URL: Issues, https://gitlab.com/biszx/biszx-odoo-mcp/issues
9
+ Keywords: odoo,mcp,server
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: asyncio>=3.4.3
18
+ Requires-Dist: loguru>=0.7.3
19
+ Requires-Dist: mcp[cli]>=1.9.4
20
+ Requires-Dist: odoorpc>=0.10.1
21
+ Dynamic: license-file
22
+
23
+ # Odoo MCP Server
24
+
25
+ An MCP server implementation for Odoo ERP systems, providing a set of tools for managing Odoo records, models, and custom methods.
26
+ Inspired by [tuanle96/mcp-odoo](https://github.com/tuanle96/mcp-odoo).
27
+
28
+ ## Tools
29
+
30
+ ### Core CRUD Operations
31
+
32
+ - **create_record**: Create a single new record
33
+
34
+ - Inputs: `model_name` (string), `values` (object)
35
+ - Returns: Dictionary with created record ID
36
+
37
+ - **create_records**: Create multiple records at once
38
+
39
+ - Inputs: `model_name` (string), `values_list` (array of objects)
40
+ - Returns: Dictionary with created record IDs
41
+
42
+ - **read_records**: Read specific records by their IDs
43
+
44
+ - Inputs: `model_name` (string), `ids` (array), `fields` (optional array)
45
+ - Returns: Dictionary with record data
46
+
47
+ - **write_record**: Update a single record
48
+
49
+ - Inputs: `model_name` (string), `record_id` (number), `values` (object)
50
+ - Returns: Dictionary with operation result
51
+
52
+ - **write_records**: Update multiple records
53
+
54
+ - Inputs: `model_name` (string), `record_ids` (array), `values` (object)
55
+ - Returns: Dictionary with operation result
56
+
57
+ - **unlink_record**: Delete a single record
58
+
59
+ - Inputs: `model_name` (string), `record_id` (number)
60
+ - Returns: Dictionary with operation result
61
+
62
+ - **unlink_records**: Delete multiple records
63
+ - Inputs: `model_name` (string), `record_ids` (array)
64
+ - Returns: Dictionary with operation result
65
+
66
+ ### Search and Query Operations
67
+
68
+ - **search_records**: Search for records with advanced filtering
69
+
70
+ - Inputs: `model_name` (string), `domain` (array), `fields` (optional array), `limit` (optional number), `offset` (optional number), `order` (optional string)
71
+ - Returns: Dictionary with matching records
72
+
73
+ - **search_ids**: Get only IDs of matching records
74
+
75
+ - Inputs: `model_name` (string), `domain` (array), `offset` (optional number), `limit` (optional number), `order` (optional string)
76
+ - Returns: Dictionary with list of IDs
77
+
78
+ - **search_count**: Count records matching a domain
79
+ - Inputs: `model_name` (string), `domain` (array)
80
+ - Returns: Dictionary with count
81
+
82
+ ### Model Operations
83
+
84
+ - **search_models**: Search for available models in the Odoo system
85
+
86
+ - Inputs: `query` (string) - Search term for model names and display names
87
+ - Returns: Dictionary with matching models
88
+
89
+ - **get_model_info**: Get information about a specific model
90
+
91
+ - Inputs: `model_name` (string)
92
+ - Returns: Dictionary with model information
93
+
94
+ - **get_model_fields**: Get field definitions for a model
95
+ - Inputs: `model_name` (string), `query_field` (string)
96
+ - Returns: Dictionary with field definitions
97
+
98
+ ### Utility Operations
99
+
100
+ - **search_and_update**: Search and update records in one operation
101
+
102
+ - Inputs: `model_name` (string), `domain` (array), `values` (object)
103
+ - Returns: Dictionary with affected record count and IDs
104
+
105
+ - **call_method**: Call custom methods on models
106
+
107
+ - Inputs: `model_name` (string), `method_name` (string), `args` (optional array), `kwargs` (optional object)
108
+ - Returns: Dictionary with method result
109
+
110
+ ## Resources
111
+
112
+ ### Model Information
113
+
114
+ - **odoo://models/search/{query}**: Search for models by name or description
115
+ - **odoo://models/{model_name}/info**: Information about a specific model
116
+ - **odoo://models/{model_name}/fields**: Field definitions for a specific model
117
+
118
+ ### Documentation
119
+
120
+ - **odoo://help/domains**: Complete guide to Odoo domain syntax with examples
121
+ - **odoo://help/operations**: Documentation of all available MCP tools and workflows
122
+
123
+ ## Configuration
124
+
125
+ ### Odoo Connection Setup
126
+
127
+ To connect to your Odoo instance, set the following environment variables:
128
+
129
+ - `ODOO_URL`: Your Odoo server URL
130
+ - `ODOO_DB`: Database name
131
+ - `ODOO_USERNAME`: Login username
132
+ - `ODOO_PASSWORD`: Password or API key
133
+ - `ODOO_TIMEOUT`: Connection timeout in seconds (default: 30)
134
+ - `ODOO_VERIFY_SSL`: Whether to verify SSL certificates (default: true)
135
+ - `LOG_LEVEL`: Logging level (default: INFO)
136
+
137
+ ### Usage with Claude Desktop
138
+
139
+ Add this to your `claude_desktop_config.json`:
140
+
141
+ ```json
142
+ {
143
+ "mcpServers": {
144
+ "odoo": {
145
+ "command": "uvx",
146
+ "args": ["biszx-odoo-mcp"],
147
+ "env": {
148
+ "ODOO_URL": "https://your-odoo-instance.com",
149
+ "ODOO_DB": "your-database-name",
150
+ "ODOO_USERNAME": "your-username",
151
+ "ODOO_PASSWORD": "your-password-or-api-key"
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ ## Installation
159
+
160
+ ### Python Package
161
+
162
+ ```bash
163
+ pip install biszx-odoo-mcp
164
+ ```
165
+
166
+ ### Running the Server
167
+
168
+ ```bash
169
+ # Using the installed package
170
+ biszx-odoo-mcp
171
+
172
+ # Using uv for development
173
+ uv run biszx-odoo-mcp
174
+
175
+ # Using the MCP development tools
176
+ uv run mcp dev src/biszx_odoo_mcp/main.py
177
+ ```
178
+
179
+ ## License
180
+
181
+ This MCP server is licensed under the MIT License.
@@ -0,0 +1,159 @@
1
+ # Odoo MCP Server
2
+
3
+ An MCP server implementation for Odoo ERP systems, providing a set of tools for managing Odoo records, models, and custom methods.
4
+ Inspired by [tuanle96/mcp-odoo](https://github.com/tuanle96/mcp-odoo).
5
+
6
+ ## Tools
7
+
8
+ ### Core CRUD Operations
9
+
10
+ - **create_record**: Create a single new record
11
+
12
+ - Inputs: `model_name` (string), `values` (object)
13
+ - Returns: Dictionary with created record ID
14
+
15
+ - **create_records**: Create multiple records at once
16
+
17
+ - Inputs: `model_name` (string), `values_list` (array of objects)
18
+ - Returns: Dictionary with created record IDs
19
+
20
+ - **read_records**: Read specific records by their IDs
21
+
22
+ - Inputs: `model_name` (string), `ids` (array), `fields` (optional array)
23
+ - Returns: Dictionary with record data
24
+
25
+ - **write_record**: Update a single record
26
+
27
+ - Inputs: `model_name` (string), `record_id` (number), `values` (object)
28
+ - Returns: Dictionary with operation result
29
+
30
+ - **write_records**: Update multiple records
31
+
32
+ - Inputs: `model_name` (string), `record_ids` (array), `values` (object)
33
+ - Returns: Dictionary with operation result
34
+
35
+ - **unlink_record**: Delete a single record
36
+
37
+ - Inputs: `model_name` (string), `record_id` (number)
38
+ - Returns: Dictionary with operation result
39
+
40
+ - **unlink_records**: Delete multiple records
41
+ - Inputs: `model_name` (string), `record_ids` (array)
42
+ - Returns: Dictionary with operation result
43
+
44
+ ### Search and Query Operations
45
+
46
+ - **search_records**: Search for records with advanced filtering
47
+
48
+ - Inputs: `model_name` (string), `domain` (array), `fields` (optional array), `limit` (optional number), `offset` (optional number), `order` (optional string)
49
+ - Returns: Dictionary with matching records
50
+
51
+ - **search_ids**: Get only IDs of matching records
52
+
53
+ - Inputs: `model_name` (string), `domain` (array), `offset` (optional number), `limit` (optional number), `order` (optional string)
54
+ - Returns: Dictionary with list of IDs
55
+
56
+ - **search_count**: Count records matching a domain
57
+ - Inputs: `model_name` (string), `domain` (array)
58
+ - Returns: Dictionary with count
59
+
60
+ ### Model Operations
61
+
62
+ - **search_models**: Search for available models in the Odoo system
63
+
64
+ - Inputs: `query` (string) - Search term for model names and display names
65
+ - Returns: Dictionary with matching models
66
+
67
+ - **get_model_info**: Get information about a specific model
68
+
69
+ - Inputs: `model_name` (string)
70
+ - Returns: Dictionary with model information
71
+
72
+ - **get_model_fields**: Get field definitions for a model
73
+ - Inputs: `model_name` (string), `query_field` (string)
74
+ - Returns: Dictionary with field definitions
75
+
76
+ ### Utility Operations
77
+
78
+ - **search_and_update**: Search and update records in one operation
79
+
80
+ - Inputs: `model_name` (string), `domain` (array), `values` (object)
81
+ - Returns: Dictionary with affected record count and IDs
82
+
83
+ - **call_method**: Call custom methods on models
84
+
85
+ - Inputs: `model_name` (string), `method_name` (string), `args` (optional array), `kwargs` (optional object)
86
+ - Returns: Dictionary with method result
87
+
88
+ ## Resources
89
+
90
+ ### Model Information
91
+
92
+ - **odoo://models/search/{query}**: Search for models by name or description
93
+ - **odoo://models/{model_name}/info**: Information about a specific model
94
+ - **odoo://models/{model_name}/fields**: Field definitions for a specific model
95
+
96
+ ### Documentation
97
+
98
+ - **odoo://help/domains**: Complete guide to Odoo domain syntax with examples
99
+ - **odoo://help/operations**: Documentation of all available MCP tools and workflows
100
+
101
+ ## Configuration
102
+
103
+ ### Odoo Connection Setup
104
+
105
+ To connect to your Odoo instance, set the following environment variables:
106
+
107
+ - `ODOO_URL`: Your Odoo server URL
108
+ - `ODOO_DB`: Database name
109
+ - `ODOO_USERNAME`: Login username
110
+ - `ODOO_PASSWORD`: Password or API key
111
+ - `ODOO_TIMEOUT`: Connection timeout in seconds (default: 30)
112
+ - `ODOO_VERIFY_SSL`: Whether to verify SSL certificates (default: true)
113
+ - `LOG_LEVEL`: Logging level (default: INFO)
114
+
115
+ ### Usage with Claude Desktop
116
+
117
+ Add this to your `claude_desktop_config.json`:
118
+
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "odoo": {
123
+ "command": "uvx",
124
+ "args": ["biszx-odoo-mcp"],
125
+ "env": {
126
+ "ODOO_URL": "https://your-odoo-instance.com",
127
+ "ODOO_DB": "your-database-name",
128
+ "ODOO_USERNAME": "your-username",
129
+ "ODOO_PASSWORD": "your-password-or-api-key"
130
+ }
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ ## Installation
137
+
138
+ ### Python Package
139
+
140
+ ```bash
141
+ pip install biszx-odoo-mcp
142
+ ```
143
+
144
+ ### Running the Server
145
+
146
+ ```bash
147
+ # Using the installed package
148
+ biszx-odoo-mcp
149
+
150
+ # Using uv for development
151
+ uv run biszx-odoo-mcp
152
+
153
+ # Using the MCP development tools
154
+ uv run mcp dev src/biszx_odoo_mcp/main.py
155
+ ```
156
+
157
+ ## License
158
+
159
+ This MCP server is licensed under the MIT License.
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name = "biszx-odoo-mcp"
3
+ version = "1.1.1"
4
+ description = "MCP Server for Odoo Integration"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = {text = "MIT"}
8
+ classifiers = [
9
+ "License :: OSI Approved :: MIT License",
10
+ "Programming Language :: Python :: 3",
11
+ "Programming Language :: Python :: 3.10",
12
+ "Operating System :: OS Independent",
13
+ ]
14
+ keywords = ["odoo", "mcp", "server"]
15
+ authors = [
16
+ {name = "Biszx", email = "isares.br@gmail.com"}
17
+ ]
18
+ dependencies = [
19
+ "asyncio>=3.4.3",
20
+ "loguru>=0.7.3",
21
+ "mcp[cli]>=1.9.4",
22
+ "odoorpc>=0.10.1",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://gitlab.com/biszx/biszx-odoo-mcp"
27
+ Issues = "https://gitlab.com/biszx/biszx-odoo-mcp/issues"
28
+
29
+ [project.scripts]
30
+ biszx-odoo-mcp = "biszx_odoo_mcp.__main__:main"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "flake8>=7.3.0",
35
+ "mypy>=1.16.1",
36
+ "pre-commit>=4.2.0",
37
+ "pylint>=3.3.7",
38
+ "pytest>=8.4.1",
39
+ "pytest-cov>=6.2.1",
40
+ "pytest-asyncio>=1.0.0",
41
+ "python-dotenv>=1.1.1",
42
+ "ruff>=0.12.0",
43
+ ]
44
+
45
+ [build-system]
46
+ requires = ["setuptools>=61.0"]
47
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """
2
+ Odoo MCP Server - MCP Server for Odoo Integration
3
+ """
@@ -0,0 +1,49 @@
1
+ """
2
+ Command line entry point for the Odoo MCP Server
3
+ """
4
+
5
+ import sys
6
+
7
+ from loguru import logger
8
+
9
+ from biszx_odoo_mcp.exceptions import OdooMCPError
10
+ from biszx_odoo_mcp.main import mcp
11
+
12
+
13
+ def main() -> int:
14
+ """
15
+ Run the MCP server
16
+ """
17
+ try:
18
+ logger.info("🚀 Odoo MCP Server starting")
19
+
20
+ # Simplified capability check
21
+ logger.debug(f"Python version: {sys.version.split()[0]}")
22
+ logger.debug("MCP server initialized with tools and resources")
23
+
24
+ logger.info("▶️ Starting MCP server...")
25
+
26
+ mcp.run()
27
+
28
+ logger.info("✅ MCP server stopped")
29
+ return 0
30
+ except KeyboardInterrupt:
31
+ logger.info("⏹️ Server stopped by user")
32
+ return 0
33
+ except OdooMCPError as e:
34
+ logger.error(f"Odoo MCP Error: {e}")
35
+ logger.debug(
36
+ f"Error details - Type: {e.__class__.__name__}, Code: {e.error_code}"
37
+ )
38
+ if e.details:
39
+ logger.debug(f"Additional details: {e.details}")
40
+ return 1
41
+ except Exception as e:
42
+ logger.error(f"Critical server error: {e}")
43
+ logger.debug(f"Exception type: {type(e)}")
44
+ logger.debug("Traceback:", exc_info=True)
45
+ return 1
46
+
47
+
48
+ if __name__ == "__main__":
49
+ sys.exit(main())
@@ -0,0 +1,226 @@
1
+ """
2
+ Custom exception classes for Odoo MCP Server.
3
+
4
+ This module defines a comprehensive hierarchy of custom exceptions for better
5
+ error handling and debugging in the Odoo MCP Server application.
6
+
7
+ Exception Hierarchy:
8
+ ===================
9
+
10
+ OdooMCPError (Base)
11
+ ├── OdooConnectionError
12
+ │ ├── ConnectionTimeoutError
13
+ │ ├── AuthenticationError
14
+ │ └── SSLVerificationError
15
+ ├── ModelError
16
+ │ └── ModelNotFoundError
17
+ ├── ServerError
18
+ │ ├── OdooRPCError
19
+ │ └── InternalServerError
20
+ └── MCPError
21
+ ├── ResourceError
22
+ └── ToolError
23
+ """
24
+
25
+ from typing import Any, Optional
26
+
27
+ from odoorpc.error import RPCError
28
+
29
+
30
+ class OdooMCPError(Exception):
31
+ """
32
+ Base exception class for all Odoo MCP Server errors.
33
+
34
+ This serves as the base class for all custom exceptions in the application,
35
+ providing a consistent interface for error handling and logging.
36
+
37
+ Attributes:
38
+ message: Human-readable error message
39
+ error_code: Machine-readable error code for programmatic handling
40
+ details: Additional context information about the error
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ message: str,
46
+ error_code: Optional[str] = None,
47
+ details: Optional[dict[str, Any]] = None,
48
+ original_error: Optional[Exception] = None,
49
+ ) -> None:
50
+ """
51
+ Initialize the exception.
52
+
53
+ Args:
54
+ message: Human-readable error message
55
+ error_code: Machine-readable error code
56
+ details: Additional context information
57
+ original_error: The original exception that caused this error
58
+ """
59
+ super().__init__(message)
60
+ self.message = message
61
+ self.error_code = error_code or self.__class__.__name__.upper()
62
+ self.details = details or {}
63
+ self.original_error = original_error
64
+
65
+ def to_dict(self) -> dict[str, Any]:
66
+ """
67
+ Convert the exception to a dictionary for JSON serialization.
68
+
69
+ Returns:
70
+ Dictionary representation of the exception
71
+ """
72
+ result = {
73
+ "error_type": self.__class__.__name__,
74
+ "error_code": self.error_code,
75
+ "message": self.message,
76
+ "details": self.details,
77
+ }
78
+
79
+ if self.original_error:
80
+ result["original_error"] = {
81
+ "type": self.original_error.__class__.__name__,
82
+ "message": str(self.original_error),
83
+ }
84
+
85
+ return result
86
+
87
+ def __str__(self) -> str:
88
+ """String representation of the exception."""
89
+ return f"{self.error_code}: {self.message}"
90
+
91
+
92
+ # =============================================================================
93
+ # CONNECTION RELATED ERRORS
94
+ # =============================================================================
95
+
96
+
97
+ class OdooConnectionError(OdooMCPError):
98
+ """Base class for Odoo connection-related errors."""
99
+
100
+
101
+ class ConnectionTimeoutError(OdooConnectionError):
102
+ """Raised when a connection to Odoo times out."""
103
+
104
+ def __init__(
105
+ self,
106
+ message: str = "Connection to Odoo server timed out",
107
+ timeout: Optional[float] = None,
108
+ **kwargs: Any,
109
+ ) -> None:
110
+ details = kwargs.get("details", {})
111
+ if timeout is not None:
112
+ details["timeout_seconds"] = timeout
113
+ kwargs["details"] = details
114
+ super().__init__(message, **kwargs)
115
+
116
+
117
+ class AuthenticationError(OdooConnectionError):
118
+ """Raised when authentication with Odoo fails."""
119
+
120
+ def __init__(
121
+ self,
122
+ message: str = "Authentication with Odoo failed",
123
+ username: Optional[str] = None,
124
+ database: Optional[str] = None,
125
+ **kwargs: Any,
126
+ ) -> None:
127
+ details = kwargs.get("details", {})
128
+ if username:
129
+ details["username"] = username
130
+ if database:
131
+ details["database"] = database
132
+ kwargs["details"] = details
133
+ super().__init__(message, **kwargs)
134
+
135
+
136
+ # =============================================================================
137
+ # MODEL RELATED ERRORS
138
+ # =============================================================================
139
+
140
+
141
+ class ModelError(OdooMCPError):
142
+ """Base class for model-related errors."""
143
+
144
+
145
+ class ModelNotFoundError(ModelError):
146
+ """Raised when a requested model doesn't exist."""
147
+
148
+ def __init__(
149
+ self, model_name: str, message: Optional[str] = None, **kwargs: Any
150
+ ) -> None:
151
+ message = message or f"Model '{model_name}' not found"
152
+ details = kwargs.get("details", {})
153
+ details["model_name"] = model_name
154
+ kwargs["details"] = details
155
+ super().__init__(message, **kwargs)
156
+
157
+
158
+ # =============================================================================
159
+ # SERVER RELATED ERRORS
160
+ # =============================================================================
161
+
162
+
163
+ class ServerError(OdooMCPError):
164
+ """Base class for server-related errors."""
165
+
166
+
167
+ class OdooRPCError(ServerError):
168
+ """Raised when an RPC call to Odoo fails."""
169
+
170
+ def __init__(
171
+ self,
172
+ error: RPCError,
173
+ method: str,
174
+ message: str = "RPC call failed",
175
+ **kwargs: Any,
176
+ ) -> None:
177
+ kwargs["details"] = {
178
+ "method": method,
179
+ "odoo_error": error.info,
180
+ }
181
+ super().__init__(message, **kwargs)
182
+
183
+
184
+ class InternalServerError(ServerError):
185
+ """Raised when an internal server error occurs."""
186
+
187
+
188
+ # =============================================================================
189
+ # MCP RELATED ERRORS
190
+ # =============================================================================
191
+
192
+
193
+ class MCPError(OdooMCPError):
194
+ """Base class for MCP protocol-related errors."""
195
+
196
+
197
+ class ResourceError(MCPError):
198
+ """Raised when an MCP resource operation fails."""
199
+
200
+ def __init__(
201
+ self,
202
+ message: str = "Resource operation failed",
203
+ resource_name: Optional[str] = None,
204
+ **kwargs: Any,
205
+ ) -> None:
206
+ details = kwargs.get("details", {})
207
+ if resource_name:
208
+ details["resource_name"] = resource_name
209
+ kwargs["details"] = details
210
+ super().__init__(message, **kwargs)
211
+
212
+
213
+ class ToolError(MCPError):
214
+ """Raised when an MCP tool operation fails."""
215
+
216
+ def __init__(
217
+ self,
218
+ message: str = "Tool operation failed",
219
+ tool_name: Optional[str] = None,
220
+ **kwargs: Any,
221
+ ) -> None:
222
+ details = kwargs.get("details", {})
223
+ if tool_name:
224
+ details["tool_name"] = tool_name
225
+ kwargs["details"] = details
226
+ super().__init__(message, **kwargs)