obsidian-sync-mcp 0.3.0 → 0.4.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 +24 -10
- package/dist/{chunk-TFJDIQK4.js → chunk-GK3PAZZJ.js} +43 -2
- package/dist/chunk-GK3PAZZJ.js.map +1 -0
- package/dist/main.js +507 -103
- package/dist/main.js.map +1 -1
- package/dist/vault-H5LOSSPH.js +11124 -0
- package/dist/vault-H5LOSSPH.js.map +1 -0
- package/dist/{vault-local-3C2JVBRO.js → vault-local-NFQ7FPNH.js} +22 -6
- package/dist/vault-local-NFQ7FPNH.js.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-TFJDIQK4.js.map +0 -1
- package/dist/vault-J2V2D3HA.js +0 -4869
- package/dist/vault-J2V2D3HA.js.map +0 -1
- package/dist/vault-local-3C2JVBRO.js.map +0 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ Both modes expose the same MCP tools over HTTP, so any MCP-compatible agent can
|
|
|
38
38
|
|
|
39
39
|
You already have LiveSync and CouchDB on an always-on server. You just need the MCP server deployed alongside it.
|
|
40
40
|
|
|
41
|
-
**Using Fly.io setup script
|
|
41
|
+
**Using Fly.io setup script** (macOS/Linux, or WSL on Windows):
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
44
|
git clone https://github.com/es617/obsidian-sync-mcp.git
|
|
@@ -52,14 +52,19 @@ The script asks for your CouchDB connection details, vault name, and encryption
|
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
54
|
docker run -p 8787:8787 \
|
|
55
|
+
-v mcp-data:/data -e DATA_DIR=/data \
|
|
55
56
|
-e COUCHDB_URL=https://your-couchdb:5984 \
|
|
56
57
|
-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=yourpassword \
|
|
57
58
|
-e COUCHDB_DATABASE=obsidian -e VAULT_NAME=MyVault \
|
|
59
|
+
-e COUCHDB_PASSPHRASE=your-encryption-passphrase \
|
|
58
60
|
-e MCP_AUTH_TOKEN=yourpassword \
|
|
61
|
+
-e BASE_URL=https://your-server-url \
|
|
59
62
|
ghcr.io/es617/obsidian-sync-mcp:latest
|
|
60
63
|
```
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
Set `COUCHDB_PASSPHRASE` if you use E2E encryption in LiveSync. Set `BASE_URL` to your public URL (required for OAuth callbacks when agents connect over HTTPS).
|
|
66
|
+
|
|
67
|
+
Your MCP endpoint is `https://your-app.fly.dev/mcp` (Fly.io) or `https://your-server:8787/mcp` (Docker behind HTTPS).
|
|
63
68
|
|
|
64
69
|
See [Cost](#cost-flyio) for Fly.io pricing.
|
|
65
70
|
|
|
@@ -77,7 +82,7 @@ fly auth login
|
|
|
77
82
|
|
|
78
83
|
Starting fresh — no LiveSync yet. Deploy CouchDB and MCP together, then set up LiveSync in Obsidian.
|
|
79
84
|
|
|
80
|
-
**Using Fly.io setup script
|
|
85
|
+
**Using Fly.io setup script** (macOS/Linux, or WSL on Windows):
|
|
81
86
|
|
|
82
87
|
```bash
|
|
83
88
|
git clone https://github.com/es617/obsidian-sync-mcp.git
|
|
@@ -158,14 +163,18 @@ COUCHDB_URL=http://localhost:5984 \
|
|
|
158
163
|
COUCHDB_USER=admin \
|
|
159
164
|
COUCHDB_PASSWORD=yourpassword \
|
|
160
165
|
COUCHDB_DATABASE=obsidian \
|
|
166
|
+
COUCHDB_PASSPHRASE=your-encryption-passphrase \
|
|
161
167
|
VAULT_NAME=MyVault \
|
|
162
168
|
npx obsidian-sync-mcp
|
|
163
169
|
```
|
|
164
170
|
|
|
171
|
+
Omit `COUCHDB_PASSPHRASE` if you don't use E2E encryption in LiveSync.
|
|
172
|
+
|
|
165
173
|
**Or with Docker:**
|
|
166
174
|
|
|
167
175
|
```bash
|
|
168
176
|
docker run -p 8787:8787 \
|
|
177
|
+
-v mcp-data:/data -e DATA_DIR=/data \
|
|
169
178
|
-e VAULT_PATH=/vault -v ~/Documents/MyVault:/vault \
|
|
170
179
|
-e VAULT_NAME=MyVault \
|
|
171
180
|
ghcr.io/es617/obsidian-sync-mcp:latest
|
|
@@ -190,16 +199,19 @@ Set `BASE_URL` to the tunnel URL when using authentication.
|
|
|
190
199
|
| Tool | Description |
|
|
191
200
|
|---|---|
|
|
192
201
|
| `read_note` | Read a note's markdown content by path |
|
|
193
|
-
| `write_note` | Create or overwrite a note (
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
202
|
+
| `write_note` | Create or overwrite a note (replaces entire content) |
|
|
203
|
+
| `edit_note` | Edit a note without rewriting it — append, prepend (after frontmatter), or replace exact text |
|
|
204
|
+
| `list_folders` | List all folders in the vault with note counts — use to discover folder names |
|
|
205
|
+
| `list_tags` | List all tags in the vault with counts — use to discover tags before filtering |
|
|
206
|
+
| `list_notes` | List notes with timestamps. Filter by folder, tag, or date. Sort by name or modified. |
|
|
207
|
+
| `search_vault` | Full-text search across all notes. Filter by tag or date, optionally include content snippets. |
|
|
196
208
|
| `delete_note` | Delete a note |
|
|
197
209
|
| `move_note` | Move or rename a note — works across folders, creates destination folders automatically |
|
|
198
|
-
| `get_note_metadata` | Get frontmatter, tags, links, size, and timestamps
|
|
210
|
+
| `get_note_metadata` | Get frontmatter, tags, outgoing links, backlinks, size, and timestamps — navigate the knowledge graph |
|
|
199
211
|
|
|
200
212
|
Every tool response includes an [Obsidian deep link](https://help.obsidian.md/Extending+Obsidian/Obsidian+URI) (`obsidian://open?vault=...&file=...`) that works on Mac and iOS.
|
|
201
213
|
|
|
202
|
-
> "
|
|
214
|
+
> "Add a bullet point to my daily note." "Find my notes about the MCP server and fix the typo in the second one."
|
|
203
215
|
|
|
204
216
|
---
|
|
205
217
|
|
|
@@ -232,15 +244,16 @@ Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable fo
|
|
|
232
244
|
| `VAULT_PATH` | Filesystem mode | — | Path to your Obsidian vault directory |
|
|
233
245
|
| `COUCHDB_URL` | CouchDB mode | — | CouchDB server URL |
|
|
234
246
|
| `COUCHDB_USER` | CouchDB mode | `admin` | CouchDB username |
|
|
235
|
-
| `COUCHDB_PASSWORD` | CouchDB mode |
|
|
247
|
+
| `COUCHDB_PASSWORD` | CouchDB mode | — | CouchDB password (required) |
|
|
236
248
|
| `COUCHDB_DATABASE` | CouchDB mode | `obsidian` | CouchDB database name |
|
|
237
249
|
| `COUCHDB_PASSPHRASE` | CouchDB mode | — | LiveSync E2E encryption passphrase (must match plugin setting) |
|
|
238
|
-
| `VAULT_NAME` | Both | `MyVault` | Vault name for
|
|
250
|
+
| `VAULT_NAME` | Both | `MyVault` | Vault name (used for deep links and index storage) |
|
|
239
251
|
| `MCP_AUTH_TOKEN` | Optional | — | Password for authentication |
|
|
240
252
|
| `BASE_URL` | Optional | `http://localhost:PORT` | Public URL (for OAuth callbacks when using a tunnel) |
|
|
241
253
|
| `PORT` | Optional | `8787` | HTTP port |
|
|
242
254
|
| `HOST` | Optional | `0.0.0.0` | Bind address (`127.0.0.1` to restrict to localhost) |
|
|
243
255
|
| `DATA_DIR` | Optional | `~/.obsidian-mcp` | Directory for persisted data (search index, auth tokens) |
|
|
256
|
+
| `LOG_LEVEL` | Optional | — | Set to `debug` for verbose logging (library logs, change feed, index sync) |
|
|
244
257
|
| `MCP_REFRESH_DAYS` | Optional | `14` | Days before auth session expires |
|
|
245
258
|
|
|
246
259
|
Set `VAULT_PATH` for filesystem mode or `COUCHDB_URL` for CouchDB mode.
|
|
@@ -278,6 +291,7 @@ Set transport to **Streamable HTTP**, enter `http://localhost:8787/mcp`, and con
|
|
|
278
291
|
- **Text only.** Binary attachments are not exposed through MCP tools.
|
|
279
292
|
- **Deep links depend on the client.** Obsidian `obsidian://` deep links are included in every tool response. They work on Claude Mobile and in browsers, but some clients (Claude Desktop) may not render them as clickable links.
|
|
280
293
|
- **Node 22+ required.**
|
|
294
|
+
- **Setup script requires bash.** The `deploy/setup.sh` script works on macOS and Linux. On Windows, use WSL or Git Bash.
|
|
281
295
|
|
|
282
296
|
---
|
|
283
297
|
|
|
@@ -66,7 +66,48 @@ function parseFrontmatterAndLinks(content) {
|
|
|
66
66
|
return { frontmatter, tags: [...tags], links: [...new Set(links)] };
|
|
67
67
|
}
|
|
68
68
|
function extractSnippet(content, query, context = 80) {
|
|
69
|
-
const
|
|
69
|
+
const lower = content.toLowerCase();
|
|
70
|
+
let idx = lower.indexOf(query.toLowerCase());
|
|
71
|
+
if (idx === -1) {
|
|
72
|
+
const words = query.split(/\s+/).filter((w) => w.length >= 3).map((w) => w.toLowerCase());
|
|
73
|
+
if (words.length > 1) {
|
|
74
|
+
let bestStart = -1;
|
|
75
|
+
let bestLen = Infinity;
|
|
76
|
+
const first = words[0];
|
|
77
|
+
let pos = 0;
|
|
78
|
+
while (pos < lower.length) {
|
|
79
|
+
const start2 = lower.indexOf(first, pos);
|
|
80
|
+
if (start2 === -1) break;
|
|
81
|
+
let spanEnd = start2 + first.length;
|
|
82
|
+
let allFound = true;
|
|
83
|
+
for (let i = 1; i < words.length; i++) {
|
|
84
|
+
const wi = lower.indexOf(words[i], Math.max(0, start2 - 200));
|
|
85
|
+
if (wi === -1) {
|
|
86
|
+
allFound = false;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
spanEnd = Math.max(spanEnd, wi + words[i].length);
|
|
90
|
+
}
|
|
91
|
+
if (allFound) {
|
|
92
|
+
const spanStart = Math.min(start2, ...words.map((w) => lower.indexOf(w, Math.max(0, start2 - 200))).filter((i) => i >= 0));
|
|
93
|
+
const len = spanEnd - spanStart;
|
|
94
|
+
if (len < bestLen) {
|
|
95
|
+
bestStart = spanStart;
|
|
96
|
+
bestLen = len;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
pos = start2 + 1;
|
|
100
|
+
}
|
|
101
|
+
if (bestStart >= 0 && bestLen <= 500) idx = bestStart;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (idx === -1) {
|
|
105
|
+
const words = query.split(/\s+/).filter((w) => w.length >= 3).sort((a, b) => b.length - a.length);
|
|
106
|
+
for (const word of words) {
|
|
107
|
+
idx = lower.indexOf(word.toLowerCase());
|
|
108
|
+
if (idx !== -1) break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
70
111
|
if (idx === -1) {
|
|
71
112
|
return content.slice(0, 160) + (content.length > 160 ? "..." : "");
|
|
72
113
|
}
|
|
@@ -80,4 +121,4 @@ export {
|
|
|
80
121
|
parseFrontmatterAndLinks,
|
|
81
122
|
extractSnippet
|
|
82
123
|
};
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-GK3PAZZJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/parse.ts"],"sourcesContent":["/**\n * Parse Obsidian markdown content for frontmatter, tags, and links.\n */\n\nexport interface NoteMetadata {\n frontmatter: Record<string, string>;\n tags: string[];\n links: string[];\n}\n\nexport function parseFrontmatterAndLinks(content: string): NoteMetadata {\n const frontmatter: Record<string, any> = {};\n const tags = new Set<string>();\n const links: string[] = [];\n\n // Parse YAML frontmatter\n if (content.startsWith(\"---\\n\")) {\n const end = content.indexOf(\"\\n---\", 4);\n if (end !== -1) {\n const yaml = content.slice(4, end);\n let inTagsList = false;\n for (const line of yaml.split(\"\\n\")) {\n // Multi-line tags list item: \" - tagname\"\n if (inTagsList) {\n const listItem = line.match(/^\\s+-\\s+(.+)/);\n if (listItem) {\n const trimmed = listItem[1].trim();\n if (trimmed) tags.add(trimmed);\n continue;\n }\n inTagsList = false;\n }\n\n const match = line.match(/^(\\w[\\w-]*)\\s*:\\s*(.+)/);\n if (match) {\n frontmatter[match[1]] = match[2].trim();\n }\n // Frontmatter tags (inline: [a, b] or start of multi-line list)\n if (/^tags\\s*:/.test(line)) {\n const value = line.replace(/^tags\\s*:\\s*/, \"\").trim();\n if (value) {\n // Inline: tags: [a, b] or tags: a, b\n const tagValues = value.replace(/[[\\]]/g, \"\");\n for (const t of tagValues.split(\",\")) {\n const trimmed = t.trim();\n if (trimmed) tags.add(trimmed);\n }\n } else {\n // Multi-line list follows\n inTagsList = true;\n }\n }\n }\n }\n }\n\n // Inline #tags\n for (const match of content.matchAll(/(^|\\s)#([\\w/-]+)/g)) {\n tags.add(match[2]);\n }\n\n // [[wikilinks]]\n for (const match of content.matchAll(/\\[\\[([^\\]|]+)(?:\\|[^\\]]+)?\\]\\]/g)) {\n links.push(match[1]);\n }\n\n // [markdown links](path.md)\n for (const match of content.matchAll(/\\[([^\\]]+)\\]\\(([^)]+\\.md)\\)/g)) {\n links.push(match[2]);\n }\n\n return { frontmatter, tags: [...tags], links: [...new Set(links)] };\n}\n\nexport function extractSnippet(content: string, query: string, context = 80): string {\n const lower = content.toLowerCase();\n\n // Try exact phrase first\n let idx = lower.indexOf(query.toLowerCase());\n\n // Try to find the smallest span containing all query words\n if (idx === -1) {\n const words = query.split(/\\s+/).filter((w) => w.length >= 3).map((w) => w.toLowerCase());\n if (words.length > 1) {\n let bestStart = -1;\n let bestLen = Infinity;\n // For each occurrence of the first word, find the nearest span containing all words\n const first = words[0];\n let pos = 0;\n while (pos < lower.length) {\n const start = lower.indexOf(first, pos);\n if (start === -1) break;\n // Find last position needed to include all words from this start\n let spanEnd = start + first.length;\n let allFound = true;\n for (let i = 1; i < words.length; i++) {\n const wi = lower.indexOf(words[i], Math.max(0, start - 200));\n if (wi === -1) { allFound = false; break; }\n spanEnd = Math.max(spanEnd, wi + words[i].length);\n }\n if (allFound) {\n const spanStart = Math.min(start, ...words.map((w) => lower.indexOf(w, Math.max(0, start - 200))).filter((i) => i >= 0));\n const len = spanEnd - spanStart;\n if (len < bestLen) { bestStart = spanStart; bestLen = len; }\n }\n pos = start + 1;\n }\n if (bestStart >= 0 && bestLen <= 500) idx = bestStart;\n }\n }\n\n // Fall back to longest matching word\n if (idx === -1) {\n const words = query.split(/\\s+/).filter((w) => w.length >= 3).sort((a, b) => b.length - a.length);\n for (const word of words) {\n idx = lower.indexOf(word.toLowerCase());\n if (idx !== -1) break;\n }\n }\n\n if (idx === -1) {\n return content.slice(0, 160) + (content.length > 160 ? \"...\" : \"\");\n }\n const start = Math.max(0, idx - context);\n const end = Math.min(content.length, idx + query.length + context);\n return (start > 0 ? \"...\" : \"\") + content.slice(start, end) + (end < content.length ? \"...\" : \"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAUO,SAAS,yBAAyB,SAA+B;AACpE,QAAM,cAAmC,CAAC;AAC1C,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAkB,CAAC;AAGzB,MAAI,QAAQ,WAAW,OAAO,GAAG;AAC7B,UAAM,MAAM,QAAQ,QAAQ,SAAS,CAAC;AACtC,QAAI,QAAQ,IAAI;AACZ,YAAM,OAAO,QAAQ,MAAM,GAAG,GAAG;AACjC,UAAI,aAAa;AACjB,iBAAW,QAAQ,KAAK,MAAM,IAAI,GAAG;AAEjC,YAAI,YAAY;AACZ,gBAAM,WAAW,KAAK,MAAM,cAAc;AAC1C,cAAI,UAAU;AACV,kBAAM,UAAU,SAAS,CAAC,EAAE,KAAK;AACjC,gBAAI,QAAS,MAAK,IAAI,OAAO;AAC7B;AAAA,UACJ;AACA,uBAAa;AAAA,QACjB;AAEA,cAAM,QAAQ,KAAK,MAAM,wBAAwB;AACjD,YAAI,OAAO;AACP,sBAAY,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,EAAE,KAAK;AAAA,QAC1C;AAEA,YAAI,YAAY,KAAK,IAAI,GAAG;AACxB,gBAAM,QAAQ,KAAK,QAAQ,gBAAgB,EAAE,EAAE,KAAK;AACpD,cAAI,OAAO;AAEP,kBAAM,YAAY,MAAM,QAAQ,UAAU,EAAE;AAC5C,uBAAW,KAAK,UAAU,MAAM,GAAG,GAAG;AAClC,oBAAM,UAAU,EAAE,KAAK;AACvB,kBAAI,QAAS,MAAK,IAAI,OAAO;AAAA,YACjC;AAAA,UACJ,OAAO;AAEH,yBAAa;AAAA,UACjB;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;A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