obsidian-sync-mcp 0.11.0 → 0.12.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/README.md +14 -4
- package/dist/chunk-AK3JXN67.js +59 -0
- package/dist/chunk-AK3JXN67.js.map +1 -0
- package/dist/main.js +15 -5
- package/dist/main.js.map +1 -1
- package/dist/{vault-7FFBJ5QT.js → vault-AV7JZZT2.js} +1807 -581
- package/dist/vault-AV7JZZT2.js.map +1 -0
- package/package.json +5 -3
- package/dist/chunk-GSVMRHWP.js +0 -33
- package/dist/chunk-GSVMRHWP.js.map +0 -1
- package/dist/vault-7FFBJ5QT.js.map +0 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ docker run -p 8787:8787 \
|
|
|
63
63
|
ghcr.io/es617/obsidian-sync-mcp:latest
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
Set `COUCHDB_PASSPHRASE` if you use E2E encryption in LiveSync. Set `COUCHDB_OBFUSCATE_PROPERTIES=true` if "Obfuscate Properties" is also enabled in your LiveSync settings. For an existing vault the server detects the actual setting from the database at startup and corrects a mismatch with a warning; only for a brand-new empty database does the value need to match your LiveSync settings. If the vault was created with LiveSync 1.0.33+ and path obfuscation, also set `COUCHDB_ID_DERIVATION_KEY` to your LiveSync recovery code (`sls-id-v1:...`, from "Show current recovery code") so the server can resolve note paths. Set `BASE_URL` to your public URL (required for OAuth callbacks when agents connect over HTTPS).
|
|
66
|
+
Set `COUCHDB_PASSPHRASE` if you use E2E encryption in LiveSync. Set `COUCHDB_OBFUSCATE_PROPERTIES=true` if "Obfuscate Properties" is also enabled in your LiveSync settings. For an existing vault the server detects the actual setting from the database at startup and corrects a mismatch with a warning; only for a brand-new empty database does the value need to match your LiveSync settings. If the vault was created with LiveSync 1.0.33+ and path obfuscation, also set `COUCHDB_ID_DERIVATION_KEY` to your LiveSync recovery code (`sls-id-v1:...`, from "Show current recovery code") so the server can resolve note paths. Unicode NFC path identity (the default for databases created with LiveSync 1.0.49+) is detected from the database automatically; a brand-new empty database gets NFC unless you set `COUCHDB_PATH_NORMALIZATION=legacy`. Set `BASE_URL` to your public URL (required for OAuth callbacks when agents connect over HTTPS).
|
|
67
67
|
|
|
68
68
|
Your MCP endpoint is `https://your-app.fly.dev/mcp` (Fly.io) or `https://your-server:8787/mcp` (Docker behind HTTPS).
|
|
69
69
|
|
|
@@ -171,7 +171,7 @@ VAULT_NAME=MyVault \
|
|
|
171
171
|
npx obsidian-sync-mcp
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
Omit `COUCHDB_PASSPHRASE` if you don't use E2E encryption in LiveSync. Set `COUCHDB_OBFUSCATE_PROPERTIES=true` if "Obfuscate Properties" is also enabled in your LiveSync settings. For an existing vault the server detects the actual setting from the database at startup and corrects a mismatch with a warning; only for a brand-new empty database does the value need to match your LiveSync settings. If the vault was created with LiveSync 1.0.33+ and path obfuscation, also set `COUCHDB_ID_DERIVATION_KEY` to your LiveSync recovery code (`sls-id-v1:...`) so the server can resolve note paths.
|
|
174
|
+
Omit `COUCHDB_PASSPHRASE` if you don't use E2E encryption in LiveSync. Set `COUCHDB_OBFUSCATE_PROPERTIES=true` if "Obfuscate Properties" is also enabled in your LiveSync settings. For an existing vault the server detects the actual setting from the database at startup and corrects a mismatch with a warning; only for a brand-new empty database does the value need to match your LiveSync settings. If the vault was created with LiveSync 1.0.33+ and path obfuscation, also set `COUCHDB_ID_DERIVATION_KEY` to your LiveSync recovery code (`sls-id-v1:...`) so the server can resolve note paths. Unicode NFC path identity (the default for databases created with LiveSync 1.0.49+) is detected from the database automatically; a brand-new empty database gets NFC unless you set `COUCHDB_PATH_NORMALIZATION=legacy`.
|
|
175
175
|
|
|
176
176
|
**Or with Docker:**
|
|
177
177
|
|
|
@@ -274,6 +274,7 @@ Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable fo
|
|
|
274
274
|
| `COUCHDB_OBFUSCATE_PROPERTIES` | CouchDB mode | `false` | Set to `true` if "Obfuscate Properties" is enabled in LiveSync (obfuscates file paths, sizes, dates in the database). For existing vaults the actual setting is auto-detected at startup; this value only decides the format for a brand-new empty database |
|
|
275
275
|
| `COUCHDB_ID_DERIVATION_KEY` | CouchDB mode | — | LiveSync "independent ID derivation" recovery code (`sls-id-v1:...`). Needed to read and write notes on vaults created with LiveSync 1.0.33+ that use path obfuscation; leave unset for older (passphrase-derived) vaults. Get it from LiveSync's "Show current recovery code" |
|
|
276
276
|
| `COUCHDB_CASE_SENSITIVE` | CouchDB mode | `false` | Set to `true` only if your LiveSync vault has "Handle filenames as case-sensitive" enabled. It must match the vault, or obfuscated document IDs won't resolve (the server fails to start with a clear message). Leave unset otherwise |
|
|
277
|
+
| `COUCHDB_PATH_NORMALIZATION` | CouchDB mode | `auto` | LiveSync path identity: how file names map to document IDs. `auto` follows the database, and uses `nfc` (Unicode NFC, so `Café.md` typed on macOS or Linux is the same note) for a brand-new empty database, matching LiveSync 1.0.49+. The server declares the choice in an empty database at startup, so set `legacy` before first starting it only if your LiveSync devices use legacy identity (vaults set up before 1.0.49). An explicit value that contradicts an existing database fails startup, since changing it needs a rebuild from LiveSync |
|
|
277
278
|
| `VAULT_NAME` | Both | `MyVault` | Vault name (used for deep links and index storage) |
|
|
278
279
|
| `MCP_AUTH_TOKEN` | Optional | — | Password for authentication |
|
|
279
280
|
| `BASE_URL` | Optional | `http://localhost:PORT` | Public URL (for OAuth callbacks when using a tunnel) |
|
|
@@ -355,10 +356,19 @@ This software is provided as-is under the [MIT license](https://github.com/es617
|
|
|
355
356
|
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
356
357
|
cd obsidian-sync-mcp
|
|
357
358
|
npm install && npm run build
|
|
358
|
-
npm test
|
|
359
|
-
npm run test:e2e
|
|
359
|
+
npm test # unit tests
|
|
360
|
+
npm run test:e2e # integration tests
|
|
361
|
+
npm run test:couchdb # CouchDB harness (needs a throwaway CouchDB on localhost:5985)
|
|
362
|
+
npm run test:smoke # full smoke test: built server over MCP against CouchDB, all vault configurations
|
|
360
363
|
```
|
|
361
364
|
|
|
365
|
+
The CouchDB tests drop and recreate their own databases, so never point them at a real vault. Start a throwaway CouchDB with `docker run -d -p 5985:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=test couchdb:3`. Set `TEST_PATH_NORMALIZATION=legacy` to run the harness on legacy path identity.
|
|
366
|
+
|
|
367
|
+
### Releasing
|
|
368
|
+
|
|
369
|
+
1. Commit the version bump to main: `package.json`, `package-lock.json`, `server.json`, and a `## <version>` section in `CHANGELOG.md`.
|
|
370
|
+
2. Either push a `v<version>` tag, or run the **Release** workflow (Actions → Release → Run workflow, which also works from a phone browser). The workflow checks the versions match, waits for CI on main's latest commit to pass, creates the tag and starts CI/CD on it, which publishes the GitHub release, the npm package and the Docker image.
|
|
371
|
+
|
|
362
372
|
---
|
|
363
373
|
|
|
364
374
|
## License
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Node polyfills for livesync-commonlib browser globals
|
|
3
|
+
if(!("navigator" in globalThis)){globalThis.navigator={language:"en"};}
|
|
4
|
+
|
|
5
|
+
// src/index-sync.ts
|
|
6
|
+
function deriveContent(doc) {
|
|
7
|
+
if (doc.deleted) return null;
|
|
8
|
+
return "data" in doc && Array.isArray(doc.data) ? doc.data.join("") : "";
|
|
9
|
+
}
|
|
10
|
+
function applyIndexChange(index, path, content, mtime) {
|
|
11
|
+
if (content !== null) {
|
|
12
|
+
index.update(path, content, mtime);
|
|
13
|
+
} else {
|
|
14
|
+
index.remove(path);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function pruneGhosts(index, preexisting, seen) {
|
|
18
|
+
const removed = [];
|
|
19
|
+
for (const p of preexisting) {
|
|
20
|
+
if (!seen.has(p)) {
|
|
21
|
+
index.remove(p);
|
|
22
|
+
removed.push(p);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return removed;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/path-identity-config.ts
|
|
29
|
+
var NAMES = { 0: "legacy", 1: "nfc" };
|
|
30
|
+
function parsePathNormalization(raw) {
|
|
31
|
+
const value = (raw ?? "").trim().toLowerCase();
|
|
32
|
+
if (value === "" || value === "auto") return "auto";
|
|
33
|
+
if (value === "nfc" || value === "legacy") return value;
|
|
34
|
+
throw new Error(`COUCHDB_PATH_NORMALIZATION must be "auto", "nfc" or "legacy" (got "${raw}").`);
|
|
35
|
+
}
|
|
36
|
+
function resolvePathIdentity(setting, state) {
|
|
37
|
+
if (state.status === "empty") {
|
|
38
|
+
if (setting === "legacy") return { version: 0 };
|
|
39
|
+
if (setting === "nfc") return { version: 1 };
|
|
40
|
+
return {
|
|
41
|
+
version: 1,
|
|
42
|
+
notice: "Empty database: using Unicode NFC path identity, the default for vaults created by LiveSync 1.0.49+. If your LiveSync devices use legacy path identity (vaults set up before 1.0.49), set COUCHDB_PATH_NORMALIZATION=legacy."
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const actual = state.pathNormalizationVersion;
|
|
46
|
+
if (setting === "auto" || setting === NAMES[actual]) return { version: actual };
|
|
47
|
+
throw new Error(
|
|
48
|
+
`COUCHDB_PATH_NORMALIZATION=${setting} but this database uses ${NAMES[actual]} path identity. An existing database can't change path identity without a rebuild from LiveSync. Unset COUCHDB_PATH_NORMALIZATION (or set it to auto) to follow the database.`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
deriveContent,
|
|
54
|
+
applyIndexChange,
|
|
55
|
+
pruneGhosts,
|
|
56
|
+
parsePathNormalization,
|
|
57
|
+
resolvePathIdentity
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=chunk-AK3JXN67.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index-sync.ts","../src/path-identity-config.ts"],"sourcesContent":["/**\n * Shared search-index sync helpers.\n *\n * Kept dependency-free (no livesync-commonlib imports) so the delete-vs-empty\n * routing is unit-testable in isolation.\n */\n\nexport interface IndexTarget {\n update(path: string, content: string, mtime?: number): void;\n remove(path: string): void;\n}\n\n/**\n * Derive index content from a LiveSync change doc.\n *\n * Returns `null` ONLY when the note is deleted. An existing note with no body\n * yields `\"\"` so a zero-byte note stays distinguishable from a deletion —\n * without this, a note that serializes with no `data` array would look deleted.\n */\nexport function deriveContent(doc: { deleted?: boolean; data?: unknown }): string | null {\n if (doc.deleted) return null;\n return \"data\" in doc && Array.isArray(doc.data) ? doc.data.join(\"\") : \"\";\n}\n\n/**\n * Route a change into the index: `null` content removes (the note was deleted),\n * any string — including `\"\"` — upserts. Using `content !== null` (rather than a\n * truthiness check) keeps zero-byte notes indexed instead of dropping them\n * (issues #5 / #6).\n */\nexport function applyIndexChange(index: IndexTarget, path: string, content: string | null, mtime?: number): void {\n if (content !== null) {\n index.update(path, content, mtime);\n } else {\n index.remove(path);\n }\n}\n\n/**\n * After a completed from-zero catch-up, remove index entries for notes that\n * vanished while the server was down (e.g. a remote \"Rebuild database\" that\n * left no tombstones to replay). Only paths present before the pass\n * (`preexisting`) that the pass did not re-deliver (`seen`) are dropped:\n * restricting the prune to pre-existing paths means an entry the live watcher\n * adds mid-pass is never pruned. Returns the removed paths.\n */\nexport function pruneGhosts(\n index: Pick<IndexTarget, \"remove\">,\n preexisting: Iterable<string>,\n seen: ReadonlySet<string>,\n): string[] {\n const removed: string[] = [];\n for (const p of preexisting) {\n if (!seen.has(p)) {\n index.remove(p);\n removed.push(p);\n }\n }\n return removed;\n}\n","/**\n * Decide the vault's path identity (LiveSync \"path normalisation version\")\n * from COUCHDB_PATH_NORMALIZATION and what the database declares.\n *\n * Kept dependency-free so the decision is unit-testable in isolation.\n *\n * Version 1 (`nfc-path-identity-v1`) applies Unicode NFC to a path before its\n * document ID is derived, so `Café.md` typed as NFC or NFD is the same note.\n * LiveSync 1.0.49+ uses it for new vaults; older vaults use version 0. The\n * library refuses a database whose declaration differs from the setting, and\n * a database with notes cannot change version without a rebuild.\n */\n\nexport type PathNormalizationSetting = \"auto\" | \"nfc\" | \"legacy\";\n\n/** What the database declares: nothing yet, or an existing version. */\nexport type PathIdentityState = { status: \"empty\" } | { status: \"configured\"; pathNormalizationVersion: 0 | 1 };\n\nexport interface PathIdentityDecision {\n version: 0 | 1;\n /** Startup message worth logging, if any. */\n notice?: string;\n}\n\nconst NAMES: Record<0 | 1, string> = { 0: \"legacy\", 1: \"nfc\" };\n\nexport function parsePathNormalization(raw: string | undefined): PathNormalizationSetting {\n const value = (raw ?? \"\").trim().toLowerCase();\n if (value === \"\" || value === \"auto\") return \"auto\";\n if (value === \"nfc\" || value === \"legacy\") return value;\n throw new Error(`COUCHDB_PATH_NORMALIZATION must be \"auto\", \"nfc\" or \"legacy\" (got \"${raw}\").`);\n}\n\nexport function resolvePathIdentity(setting: PathNormalizationSetting, state: PathIdentityState): PathIdentityDecision {\n if (state.status === \"empty\") {\n if (setting === \"legacy\") return { version: 0 };\n if (setting === \"nfc\") return { version: 1 };\n return {\n version: 1,\n notice:\n \"Empty database: using Unicode NFC path identity, the default for vaults created by LiveSync 1.0.49+. \" +\n \"If your LiveSync devices use legacy path identity (vaults set up before 1.0.49), set COUCHDB_PATH_NORMALIZATION=legacy.\",\n };\n }\n const actual = state.pathNormalizationVersion;\n if (setting === \"auto\" || setting === NAMES[actual]) return { version: actual };\n throw new Error(\n `COUCHDB_PATH_NORMALIZATION=${setting} but this database uses ${NAMES[actual]} path identity. ` +\n \"An existing database can't change path identity without a rebuild from LiveSync. \" +\n \"Unset COUCHDB_PATH_NORMALIZATION (or set it to auto) to follow the database.\",\n );\n}\n"],"mappings":";;;;;AAmBO,SAAS,cAAc,KAA2D;AACrF,MAAI,IAAI,QAAS,QAAO;AACxB,SAAO,UAAU,OAAO,MAAM,QAAQ,IAAI,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,IAAI;AAC1E;AAQO,SAAS,iBAAiB,OAAoB,MAAc,SAAwB,OAAsB;AAC7G,MAAI,YAAY,MAAM;AAClB,UAAM,OAAO,MAAM,SAAS,KAAK;AAAA,EACrC,OAAO;AACH,UAAM,OAAO,IAAI;AAAA,EACrB;AACJ;AAUO,SAAS,YACZ,OACA,aACA,MACQ;AACR,QAAM,UAAoB,CAAC;AAC3B,aAAW,KAAK,aAAa;AACzB,QAAI,CAAC,KAAK,IAAI,CAAC,GAAG;AACd,YAAM,OAAO,CAAC;AACd,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ;AACA,SAAO;AACX;;;ACnCA,IAAM,QAA+B,EAAE,GAAG,UAAU,GAAG,MAAM;AAEtD,SAAS,uBAAuB,KAAmD;AACtF,QAAM,SAAS,OAAO,IAAI,KAAK,EAAE,YAAY;AAC7C,MAAI,UAAU,MAAM,UAAU,OAAQ,QAAO;AAC7C,MAAI,UAAU,SAAS,UAAU,SAAU,QAAO;AAClD,QAAM,IAAI,MAAM,sEAAsE,GAAG,KAAK;AAClG;AAEO,SAAS,oBAAoB,SAAmC,OAAgD;AACnH,MAAI,MAAM,WAAW,SAAS;AAC1B,QAAI,YAAY,SAAU,QAAO,EAAE,SAAS,EAAE;AAC9C,QAAI,YAAY,MAAO,QAAO,EAAE,SAAS,EAAE;AAC3C,WAAO;AAAA,MACH,SAAS;AAAA,MACT,QACI;AAAA,IAER;AAAA,EACJ;AACA,QAAM,SAAS,MAAM;AACrB,MAAI,YAAY,UAAU,YAAY,MAAM,MAAM,EAAG,QAAO,EAAE,SAAS,OAAO;AAC9E,QAAM,IAAI;AAAA,IACN,8BAA8B,OAAO,2BAA2B,MAAM,MAAM,CAAC;AAAA,EAGjF;AACJ;","names":[]}
|
package/dist/main.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
if(!("navigator" in globalThis)){globalThis.navigator={language:"en"};}
|
|
4
4
|
import {
|
|
5
5
|
applyIndexChange,
|
|
6
|
+
parsePathNormalization,
|
|
6
7
|
pruneGhosts
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AK3JXN67.js";
|
|
8
9
|
import {
|
|
9
10
|
AttachmentExistsError,
|
|
10
11
|
AttachmentMoveIncompleteError,
|
|
@@ -1803,6 +1804,7 @@ var COUCHDB_PASSPHRASE = process.env.COUCHDB_PASSPHRASE || void 0;
|
|
|
1803
1804
|
var COUCHDB_OBFUSCATE_PROPERTIES = process.env.COUCHDB_OBFUSCATE_PROPERTIES === "true";
|
|
1804
1805
|
var COUCHDB_ID_DERIVATION_KEY = process.env.COUCHDB_ID_DERIVATION_KEY || void 0;
|
|
1805
1806
|
var COUCHDB_CASE_SENSITIVE = process.env.COUCHDB_CASE_SENSITIVE === "true";
|
|
1807
|
+
var COUCHDB_PATH_NORMALIZATION = process.env.COUCHDB_PATH_NORMALIZATION;
|
|
1806
1808
|
var VAULT_NAME = process.env.VAULT_NAME ?? "MyVault";
|
|
1807
1809
|
var PORT = parseInt(process.env.PORT ?? "8787");
|
|
1808
1810
|
var BASE_URL = process.env.BASE_URL ?? `http://localhost:${PORT}`;
|
|
@@ -1861,7 +1863,14 @@ if (VAULT_PATH) {
|
|
|
1861
1863
|
console.error("COUCHDB_PASSWORD is required in remote mode.");
|
|
1862
1864
|
process.exit(1);
|
|
1863
1865
|
}
|
|
1864
|
-
const { Vault } = await import("./vault-
|
|
1866
|
+
const { Vault } = await import("./vault-AV7JZZT2.js");
|
|
1867
|
+
let pathNormalization;
|
|
1868
|
+
try {
|
|
1869
|
+
pathNormalization = parsePathNormalization(COUCHDB_PATH_NORMALIZATION);
|
|
1870
|
+
} catch (err) {
|
|
1871
|
+
console.error(err.message);
|
|
1872
|
+
process.exit(1);
|
|
1873
|
+
}
|
|
1865
1874
|
vault = new Vault({
|
|
1866
1875
|
couchdbUrl: COUCHDB_URL,
|
|
1867
1876
|
couchdbUser: COUCHDB_USER,
|
|
@@ -1870,7 +1879,8 @@ if (VAULT_PATH) {
|
|
|
1870
1879
|
passphrase: COUCHDB_PASSPHRASE,
|
|
1871
1880
|
obfuscatePaths: COUCHDB_OBFUSCATE_PROPERTIES,
|
|
1872
1881
|
idDerivationKey: COUCHDB_ID_DERIVATION_KEY,
|
|
1873
|
-
caseSensitive: COUCHDB_CASE_SENSITIVE
|
|
1882
|
+
caseSensitive: COUCHDB_CASE_SENSITIVE,
|
|
1883
|
+
pathNormalization
|
|
1874
1884
|
});
|
|
1875
1885
|
console.log(`Remote mode: ${redactCredentials(COUCHDB_URL)}`);
|
|
1876
1886
|
} else {
|
|
@@ -2071,7 +2081,7 @@ var ATTACHMENT_INSTRUCTIONS = ATTACHMENTS_ENABLED ? " Images, PDFs, audio and vi
|
|
|
2071
2081
|
var BASE_INSTRUCTIONS = "Access and manage an Obsidian vault. You can read, write, list, search, move, and delete markdown notes." + ATTACHMENT_INSTRUCTIONS + " Every tool response includes an Obsidian deep link. Always show this link to the user using the format [obsidian://open?vault=...&file=...](obsidian://open?vault=...&file=...) so it is both clickable and visible as a URL.";
|
|
2072
2082
|
var serverOptions = {
|
|
2073
2083
|
name: "obsidian-sync-mcp",
|
|
2074
|
-
version: "0.
|
|
2084
|
+
version: "0.12.1",
|
|
2075
2085
|
instructions: MCP_EXTRA_INSTRUCTIONS ? `${BASE_INSTRUCTIONS}
|
|
2076
2086
|
|
|
2077
2087
|
${MCP_EXTRA_INSTRUCTIONS}` : BASE_INSTRUCTIONS
|
|
@@ -2169,7 +2179,7 @@ server.start({
|
|
|
2169
2179
|
transportType: "httpStream",
|
|
2170
2180
|
httpStream: { port: PORT, endpoint: "/mcp", host: process.env.HOST ?? "0.0.0.0" }
|
|
2171
2181
|
});
|
|
2172
|
-
console.log(`obsidian-sync-mcp v${"0.
|
|
2182
|
+
console.log(`obsidian-sync-mcp v${"0.12.1"} listening on port ${PORT}`);
|
|
2173
2183
|
process.on("unhandledRejection", (err) => {
|
|
2174
2184
|
console.error(`Unhandled rejection: ${describeError(err, debugLogging2)}`);
|
|
2175
2185
|
});
|