Skip to content

Fix OBSIDIAN_HOST environment variable parsing to support protocol and port#52

Open
crazy-matt wants to merge 1 commit intoMarkusPfundstein:mainfrom
crazy-matt:main
Open

Fix OBSIDIAN_HOST environment variable parsing to support protocol and port#52
crazy-matt wants to merge 1 commit intoMarkusPfundstein:mainfrom
crazy-matt:main

Conversation

@crazy-matt
Copy link

@crazy-matt crazy-matt commented May 26, 2025

Problem Root Cause

The code was reading OBSIDIAN_HOST from environment variables but ignoring its value, always using a hard-coded default.

Changes

  • Added URL parsing: parse_host_config() static method extracts components from full URLs
  • Fixed tools.py: Implemented create_obsidian_api() factory that parses OBSIDIAN_HOST and passes correct parameters
  • Updated documentation: Added clear examples of supported URL formats

Fixing

Potentially Related:

@gee842
Copy link

gee842 commented Sep 27, 2025

Hi bump this is getting in the way of multiple instances running at the same time

@elazar
Copy link

elazar commented Oct 5, 2025

Posting this comment for posterity, in hopes that it helps anyone else who lands here.

This PR is based on package version 0.2.1 (released December 5, 2024). As of October 5, 2025, it has merge conflicts with the main branch.

The core functionality provided by this PR -- environment variable support for OBSIDIAN_HOST with URL parsing -- has been implemented in the main branch through other PRs merged to the main branch after package version 0.2.2 was released (April 1, 2025), albeit using a simpler approach that doesn't centralize instantiation and configuration of the Obsidian client in the way that this PR does.

There hasn't been another release since 0.2.2, nor could I find any obvious indication of plans for such a release. The pyproject.toml file on the main branch currently reflects a package version of 0.2.1 despite the 0.2.2 release. No commits have been merged to the main branch since PR #44 was merged three months ago (on June 28, 2025; see 4aac5c2).

Until a new package version is released, the easiest way to use the package with these changes is by using the main branch, as shown in the examples below. You may want to make the value git+https://github.com/MarkusPfundstein/mcp-obsidian.git@4aac5c2b874a219652e783b13fde2fb89e9fb640 centrally configurable so it can be easily changed later.

Installation:

pip install git+https://github.com/MarkusPfundstein/mcp-obsidian.git@4aac5c2b874a219652e783b13fde2fb89e9fb640
# or
uv pip install --system git+https://github.com/MarkusPfundstein/mcp-obsidian.git@4aac5c2b874a219652e783b13fde2fb89e9fb640

Configuration:

{
  "mcpServers": {
    "obsidian": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/MarkusPfundstein/mcp-obsidian.git@4aac5c2b874a219652e783b13fde2fb89e9fb640",
        "mcp-obsidian"
      ],
      "env": {
        "OBSIDIAN_API_KEY": "<REDACTED>",
        "OBSIDIAN_HOST": "127.0.0.1",
        "OBSIDIAN_PORT": "27124",
        "OBSIDIAN_PROTOCOL": "https"
      }
    }
  }
}

I've successfully deployed the package with the main branch using separate environment variables for a remote Obsidian instance (e.g. http://192.168.1.105:27123) and it works perfectly.

Given that 1) the functionality from this PR is already available in the main branch; 2) this PR has merge conflicts that would require significant changes to resolve; and 3) the main branch includes additional features, bug fixes, and other improvements, barring any further activity on this PR I would suggest closing it in favor of using the main branch. Users who need URL-style configuration can use the separate environment variables, which provide the same flexibility with more explicit configuration.

For what it's worth, I personally think that the URL parsing approach implemented by this PR is an improvement and would like to see it be fixed up and merged to the main branch. I hope you'll consider rebasing this PR onto the current main branch, resolving conflicts with PR #37, and updating this PR to work with the current codebase.

@frntman
Copy link

frntman commented Oct 22, 2025

@elazar:

Posting this comment for posterity, in hopes that it helps anyone else who lands here.

I landed here, thank you for posting the workaround, it worked perfectly!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants