mcp-obsidian-cli 1.0.0 → 1.0.1
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.
- package/.claude/settings.local.json +15 -0
- package/README.md +17 -0
- package/package.json +1 -1
- package/server.js +34 -3
package/README.md
CHANGED
|
@@ -69,6 +69,23 @@ The generic `obsidian` tool means the MCP server never falls behind the CLI —
|
|
|
69
69
|
| `OBSIDIAN_VAULT` | _(none)_ | Target vault by name |
|
|
70
70
|
| `OBSIDIAN_CLI_PATH` | `obsidian` | Path to CLI binary |
|
|
71
71
|
| `OBSIDIAN_TIMEOUT_MS` | `15000` | Command timeout |
|
|
72
|
+
| `XDG_CONFIG_HOME` | `~/.config` | Base path for config file |
|
|
73
|
+
|
|
74
|
+
## Config file
|
|
75
|
+
|
|
76
|
+
The server can read settings from a YAML config file:
|
|
77
|
+
|
|
78
|
+
- Default: `~/.config/mcp-obsidian-cli/config.yaml`
|
|
79
|
+
- With `XDG_CONFIG_HOME`: `$XDG_CONFIG_HOME/mcp-obsidian-cli/config.yaml`
|
|
80
|
+
|
|
81
|
+
Config file format:
|
|
82
|
+
```yaml
|
|
83
|
+
vault: "my-vault"
|
|
84
|
+
cliPath: "obsidian"
|
|
85
|
+
timeoutMs: 15000
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Config precedence: env vars > config file > hardcoded defaults
|
|
72
89
|
|
|
73
90
|
## Compared to alternatives
|
|
74
91
|
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Requirements:
|
|
15
15
|
* - Obsidian must be running with the CLI plugin active.
|
|
16
|
-
* - The
|
|
16
|
+
* - The CLI binary is auto-discovered from common macOS locations.
|
|
17
|
+
* Set OBSIDIAN_CLI_PATH to override.
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -30,7 +31,8 @@ import { exec } from "node:child_process";
|
|
|
30
31
|
const execFileAsync = promisify(execFile);
|
|
31
32
|
const execAsync = promisify(exec);
|
|
32
33
|
|
|
33
|
-
const
|
|
34
|
+
const configBase = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
|
|
35
|
+
const CONFIG_DIR = join(configBase, "mcp-obsidian-cli");
|
|
34
36
|
const CONFIG_FILE = join(CONFIG_DIR, "config.yaml");
|
|
35
37
|
|
|
36
38
|
function loadConfig() {
|
|
@@ -58,8 +60,37 @@ function loadConfig() {
|
|
|
58
60
|
return config;
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
const KNOWN_CLI_PATHS = [
|
|
64
|
+
"/Applications/Obsidian.app/Contents/MacOS/obsidian",
|
|
65
|
+
join(homedir(), "Applications/Obsidian.app/Contents/MacOS/obsidian"),
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
async function resolveCliPath(configured) {
|
|
69
|
+
if (configured !== "obsidian") return configured;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
await execAsync("which obsidian", { timeout: 2000 });
|
|
73
|
+
return configured;
|
|
74
|
+
} catch { /* not on PATH */ }
|
|
75
|
+
|
|
76
|
+
for (const p of KNOWN_CLI_PATHS) {
|
|
77
|
+
if (existsSync(p)) return p;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const { stdout } = await execAsync(
|
|
82
|
+
"ps aux | grep -i obsidian | grep -v grep | grep -v Helper",
|
|
83
|
+
{ timeout: 2000 }
|
|
84
|
+
);
|
|
85
|
+
const match = stdout.match(/(\S*\/Contents\/MacOS\/obsidian)/i);
|
|
86
|
+
if (match && existsSync(match[1])) return match[1];
|
|
87
|
+
} catch { /* no running process */ }
|
|
88
|
+
|
|
89
|
+
return configured;
|
|
90
|
+
}
|
|
91
|
+
|
|
61
92
|
const config = loadConfig();
|
|
62
|
-
const CLI = config.cliPath;
|
|
93
|
+
const CLI = await resolveCliPath(config.cliPath);
|
|
63
94
|
const VAULT = config.vault;
|
|
64
95
|
const TIMEOUT_MS = config.timeoutMs;
|
|
65
96
|
|