diff --git a/README.md b/README.md index e55c9f6..3b97638 100644 --- a/README.md +++ b/README.md @@ -44,20 +44,25 @@ There are two ways to configure the environment with the Obsidian REST API Key. ], "env": { "OBSIDIAN_API_KEY": "", - "OBSIDIAN_HOST": "" + "OBSIDIAN_HOST": "", + "OBSIDIAN_PORT": "" } } } ``` -2. Create a `.env` file in the working directory with the following required variable: +2. Create a `.env` file in the working directory with the following required variables: ``` OBSIDIAN_API_KEY=your_api_key_here OBSIDIAN_HOST=your_obsidian_host +OBSIDIAN_PORT=your_obsidian_port ``` -Note: You can find the key in the Obsidian plugin config. +Note: +- You can find the API key in the Obsidian plugin config +- Default port is 27124 if not specified +- Default host is 127.0.0.1 if not specified ## Quickstart @@ -88,7 +93,12 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json` "/mcp-obsidian", "run", "mcp-obsidian" - ] + ], + "env": { + "OBSIDIAN_API_KEY": "", + "OBSIDIAN_HOST": "", + "OBSIDIAN_PORT": "" + } } } } @@ -107,7 +117,9 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json` "mcp-obsidian" ], "env": { - "OBSIDIAN_API_KEY" : "" + "OBSIDIAN_API_KEY": "", + "OBSIDIAN_HOST": "", + "OBSIDIAN_PORT": "" } } } diff --git a/src/mcp_obsidian/obsidian.py b/src/mcp_obsidian/obsidian.py index a2c235f..29fc36e 100644 --- a/src/mcp_obsidian/obsidian.py +++ b/src/mcp_obsidian/obsidian.py @@ -1,5 +1,6 @@ import requests import urllib.parse +import os from typing import Any class Obsidian(): @@ -8,7 +9,7 @@ class Obsidian(): api_key: str, protocol: str = 'https', host: str = "127.0.0.1", - port: int = 27124, + port: int = int(os.getenv('OBSIDIAN_PORT', '27124')), verify_ssl: bool = False, ): self.api_key = api_key