From 897822ecaadd56ab16355523ac3bed31802f30ed Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 16 Aug 2025 19:04:03 +0000 Subject: [PATCH] fix: correctly parse legacy OBSIDIAN_HOST format 'host:port' to avoid double port in URL --- src/mcp_obsidian/obsidian.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mcp_obsidian/obsidian.py b/src/mcp_obsidian/obsidian.py index 3133eb6..4eec13c 100644 --- a/src/mcp_obsidian/obsidian.py +++ b/src/mcp_obsidian/obsidian.py @@ -84,10 +84,19 @@ class Obsidian(): host = parsed.hostname or '127.0.0.1' port = parsed.port or (27124 if protocol == 'https' else 27123) else: - # Legacy hostname/IP only format - protocol = 'https' - host = host_config - port = 27124 + # Support legacy formats + # 1) hostname/IP only + # 2) hostname:port (no protocol) + if ':' in host_config: + # Treat as host:port and default protocol to https + parsed = urlparse(f'https://{host_config}') + protocol = 'https' + host = parsed.hostname or '127.0.0.1' + port = parsed.port or 27124 + else: + protocol = 'https' + host = host_config + port = 27124 return protocol, host, port