pkm-mcp-server 1.5.1 → 1.5.3

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.
@@ -35,13 +35,20 @@ if [ -z "$CAPTURE_TYPE" ] || [ -z "$CAPTURE_TITLE" ] || [ -z "$CAPTURE_CONTENT"
35
35
  exit 0
36
36
  fi
37
37
 
38
- # MCP config for obsidian-pkm server
38
+ # MCP config auto-detect repo (../index.js exists) vs installed (use npx)
39
39
  SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd -P)
40
40
  MCP_CONFIG=$(node -e "
41
+ const { existsSync } = require('fs');
42
+ const path = require('path');
43
+ const localIndex = path.join(process.argv[1], '..', 'index.js');
44
+ const useLocal = existsSync(localIndex);
41
45
  const env = { VAULT_PATH: process.argv[2] };
42
46
  if (process.env.OPENAI_API_KEY) env.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
43
- console.log(JSON.stringify({ mcpServers: { 'obsidian-pkm': { command: 'node', args: [process.argv[1]], env } } }));
44
- " "$SCRIPT_DIR/../index.js" "${VAULT_PATH:-$HOME/Documents/PKM}")
47
+ const server = useLocal
48
+ ? { command: 'node', args: [localIndex], env }
49
+ : { command: 'npx', args: ['-y', 'pkm-mcp-server@latest'], env };
50
+ console.log(JSON.stringify({ mcpServers: { 'obsidian-pkm': server } }));
51
+ " "$SCRIPT_DIR" "${VAULT_PATH:-$HOME/Documents/PKM}")
45
52
 
46
53
  # Build prompt via Node.js to avoid shell injection from user content
47
54
  PROMPT_FILE=$(mktemp)
package/init.js CHANGED
@@ -208,8 +208,29 @@ export function patchMcpConfig(scriptContent, installType) {
208
208
  const argsJson = JSON.stringify(installType.args);
209
209
  const replacement = `MCP_CONFIG='{"mcpServers":{"obsidian-pkm":{"command":"${installType.command}","args":${argsJson},"env":{"VAULT_PATH":"'"$VAULT_PATH"'"}}}}'`;
210
210
  const lines = scriptContent.split("\n");
211
- const patched = lines.map(line => line.startsWith("MCP_CONFIG=") ? replacement : line);
212
- return patched.join("\n");
211
+ const result = [];
212
+ let i = 0;
213
+
214
+ while (i < lines.length) {
215
+ if (lines[i].startsWith("MCP_CONFIG=")) {
216
+ result.push(replacement);
217
+ // Multi-line command substitution: contains $( but closing ) is on a later line
218
+ if (lines[i].includes("$(") && !lines[i].trimEnd().endsWith(")")) {
219
+ i++;
220
+ while (i < lines.length && !lines[i].trimEnd().endsWith(")")) {
221
+ i++;
222
+ }
223
+ i++; // skip the closing line
224
+ } else {
225
+ i++;
226
+ }
227
+ } else {
228
+ result.push(lines[i]);
229
+ i++;
230
+ }
231
+ }
232
+
233
+ return result.join("\n");
213
234
  }
214
235
 
215
236
  const PKM_HOOK_BASENAMES = new Set(["session-start.js", "stop-sweep.js", "capture-handler.sh"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pkm-mcp-server",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "MCP server for Obsidian vault integration with Claude Code — 19 tools for notes, search, and graph traversal",
5
5
  "main": "cli.js",
6
6
  "exports": {