Skip to content

Commit 34afb29

Browse files
committed
fix: https connections and database validation
1 parent 4f13133 commit 34afb29

File tree

6 files changed

+31
-15
lines changed

6 files changed

+31
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.1.1] - 2025-06-16
9+
10+
### Fixed
11+
- **HTTPS Connection**: Fixed SSL/TLS support by using `SafeTransport` for HTTPS URLs instead of regular `Transport`
12+
- **Database Validation**: Skip database existence check when database is explicitly configured, as listing may be restricted for security
13+
814
## [0.1.0] - 2025-06-08
915

1016
### Added

mcp_server_odoo/odoo_connection.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,23 +394,24 @@ def auto_select_database(self) -> str:
394394
Raises:
395395
OdooConnectionError: If no suitable database can be selected
396396
"""
397-
# If database is explicitly configured, validate and use it
397+
# If database is explicitly configured, use it without validation
398+
# Database listing may be restricted for security reasons
398399
if self.config.database:
399400
db_name = self.config.database
400401
logger.info(f"Using configured database: {db_name}")
401-
402-
if not self.database_exists(db_name):
403-
raise OdooConnectionError(
404-
f"Configured database '{db_name}' does not exist on server"
405-
)
406-
402+
# Skip existence check as database listing might be restricted
407403
return db_name
408404

409405
# List available databases
410406
try:
411407
databases = self.list_databases()
412408
except Exception as e:
413-
raise OdooConnectionError(f"Failed to list databases for auto-selection: {e}") from e
409+
# If database listing is restricted, we cannot auto-select
410+
logger.warning(f"Cannot list databases (may be restricted): {e}")
411+
raise OdooConnectionError(
412+
"Database auto-selection failed. Database listing may be restricted. "
413+
"Please specify ODOO_DB in your configuration."
414+
) from e
414415

415416
# Handle different scenarios
416417
if not databases:

mcp_server_odoo/performance.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from dataclasses import dataclass
1616
from datetime import datetime
1717
from typing import Any, Dict, List, Optional, Tuple
18-
from xmlrpc.client import ServerProxy, Transport
18+
from xmlrpc.client import SafeTransport, ServerProxy, Transport
1919

2020
from .config import OdooConfig
2121
from .logging_config import get_logger
@@ -271,7 +271,11 @@ def __init__(self, config: OdooConfig, max_connections: int = 10):
271271
self._connections: List[Tuple[ServerProxy, float]] = []
272272
self._endpoint_map: List[str] = [] # Track endpoints for each connection
273273
self._lock = threading.RLock()
274-
self._transport = Transport()
274+
# Use SafeTransport for HTTPS, regular Transport for HTTP
275+
if config.url.startswith("https://"):
276+
self._transport = SafeTransport()
277+
else:
278+
self._transport = Transport()
275279
self._last_cleanup = time.time()
276280
self._stats = {
277281
"connections_created": 0,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "mcp-server-odoo"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
description = "A Model Context Protocol server for Odoo ERP systems"
99
readme = "README.md"
1010
requires-python = ">=3.10"

tests/test_database_discovery.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ def test_auto_select_configured_database(self):
113113
selected = connection.auto_select_database()
114114

115115
assert selected == "mydb"
116+
# list() should not be called when database is configured
117+
mock_proxy.list.assert_not_called()
116118

117119
def test_auto_select_configured_database_not_exists(self):
118-
"""Test auto-selection fails when configured database doesn't exist."""
120+
"""Test auto-selection uses configured database even if not in list (skip validation)."""
119121
# Create config with explicit database that doesn't exist
120122
config = OdooConfig(
121123
url="http://localhost:8069", api_key="test_api_key", database="nonexistent"
@@ -126,8 +128,11 @@ def test_auto_select_configured_database_not_exists(self):
126128
mock_proxy.list.return_value = ["db1", "test"]
127129
connection._db_proxy = mock_proxy
128130

129-
with pytest.raises(OdooConnectionError, match="does not exist"):
130-
connection.auto_select_database()
131+
# Should return configured database without validation
132+
selected = connection.auto_select_database()
133+
assert selected == "nonexistent"
134+
# list() should not be called when database is configured
135+
mock_proxy.list.assert_not_called()
131136

132137
def test_auto_select_single_database(self, connection):
133138
"""Test auto-selection with single database."""

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)