obsidian-sync-mcp 0.2.0 → 0.3.0
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 +113 -127
- package/dist/{chunk-F7WFTFMH.js → chunk-TFJDIQK4.js} +2 -1
- package/dist/{chunk-F7WFTFMH.js.map → chunk-TFJDIQK4.js.map} +1 -1
- package/dist/main.js +6 -5
- package/dist/main.js.map +1 -1
- package/dist/{vault-GDCDM6GS.js → vault-J2V2D3HA.js} +3 -2
- package/dist/{vault-GDCDM6GS.js.map → vault-J2V2D3HA.js.map} +1 -1
- package/dist/{vault-local-WRHVJLBZ.js → vault-local-3C2JVBRO.js} +3 -2
- package/dist/{vault-local-WRHVJLBZ.js.map → vault-local-3C2JVBRO.js.map} +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|
|
|
10
|
-
Give any AI agent
|
|
10
|
+
Give any AI agent access to your Obsidian vault over MCP. Run it locally against your vault files, or pair it with [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) and deploy to the cloud so it works even when your machine is off.
|
|
11
11
|
|
|
12
12
|
> **Example:** From your phone, ask your AI: "What's in my daily note for today?" — and get the full content back, with a link to open it in Obsidian.
|
|
13
13
|
|
|
@@ -15,10 +15,10 @@ Give any AI agent remote read/write access to your Obsidian vault over MCP. Run
|
|
|
15
15
|
|
|
16
16
|
## How it works
|
|
17
17
|
|
|
18
|
-
The server
|
|
18
|
+
The server connects to your vault in two ways:
|
|
19
19
|
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
20
|
+
- **Filesystem mode** — reads `.md` files directly from your vault folder. No database needed.
|
|
21
|
+
- **CouchDB mode** — reads from a CouchDB database, locally or in the cloud. Your vault syncs to CouchDB via [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync), the community Obsidian plugin (600k+ downloads). The MCP server reads from CouchDB directly using [livesync-commonlib](https://github.com/vrtmrz/livesync-commonlib) — the same library that powers the plugin — for proper chunk handling and E2E encryption support.
|
|
22
22
|
|
|
23
23
|
Both modes expose the same MCP tools over HTTP, so any MCP-compatible agent can connect: Claude, Copilot, custom agents, anything that speaks the [Model Context Protocol](https://modelcontextprotocol.io).
|
|
24
24
|
|
|
@@ -26,175 +26,162 @@ Both modes expose the same MCP tools over HTTP, so any MCP-compatible agent can
|
|
|
26
26
|
|
|
27
27
|
## Choose your setup
|
|
28
28
|
|
|
29
|
-
|
|
|
29
|
+
| Need it always available? | Have LiveSync? | Go to |
|
|
30
30
|
|---|---|---|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
31
|
+
| Yes | Yes | [Setup A](#a-deploy-mcp-to-the-cloud) — add MCP alongside your existing CouchDB |
|
|
32
|
+
| Yes | No | [Setup B](#b-deploy-everything-to-the-cloud) — CouchDB + MCP + LiveSync from scratch |
|
|
33
|
+
| No | — | [Setup C](#c-run-on-your-machine) — filesystem or CouchDB, npx or Docker |
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## A. Deploy MCP to the cloud
|
|
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
|
-
|
|
41
|
+
**Using Fly.io setup script:**
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Set your CouchDB connection:
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
COUCHDB_URL=https://your-couchdb:5984 \
|
|
51
|
-
COUCHDB_USER=admin \
|
|
52
|
-
COUCHDB_PASSWORD=yourpassword \
|
|
53
|
-
COUCHDB_DATABASE=obsidian \
|
|
54
|
-
VAULT_NAME=MyVault \
|
|
55
|
-
MCP_AUTH_TOKEN=yourpassword \
|
|
56
|
-
npx obsidian-sync-mcp
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Or deploy to Fly.io (MCP only, no CouchDB)
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
fly launch --image ghcr.io/es617/obsidian-sync-mcp:latest
|
|
63
|
-
fly secrets set \
|
|
64
|
-
COUCHDB_URL=https://your-couchdb:5984 \
|
|
65
|
-
COUCHDB_USER=admin \
|
|
66
|
-
COUCHDB_PASSWORD=yourpassword \
|
|
67
|
-
COUCHDB_DATABASE=obsidian \
|
|
68
|
-
VAULT_NAME=MyVault \
|
|
69
|
-
MCP_AUTH_TOKEN=$(openssl rand -hex 16) \
|
|
70
|
-
BASE_URL=https://your-app.fly.dev
|
|
44
|
+
git clone https://github.com/es617/obsidian-sync-mcp.git
|
|
45
|
+
cd obsidian-sync-mcp
|
|
46
|
+
./deploy/setup.sh # choose option 2 (MCP only)
|
|
71
47
|
```
|
|
72
48
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Your MCP endpoint is `https://your-app.fly.dev/mcp`.
|
|
76
|
-
|
|
77
|
-
> If you use E2E encryption in LiveSync, also set `COUCHDB_PASSPHRASE` to the same passphrase.
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Local mode + tunnel
|
|
49
|
+
The script asks for your CouchDB connection details, vault name, and encryption passphrase.
|
|
82
50
|
|
|
83
|
-
|
|
51
|
+
**Or run the Docker image on any always-on server:**
|
|
84
52
|
|
|
85
53
|
```bash
|
|
86
|
-
|
|
54
|
+
docker run -p 8787:8787 \
|
|
55
|
+
-e COUCHDB_URL=https://your-couchdb:5984 \
|
|
56
|
+
-e COUCHDB_USER=admin -e COUCHDB_PASSWORD=yourpassword \
|
|
57
|
+
-e COUCHDB_DATABASE=obsidian -e VAULT_NAME=MyVault \
|
|
58
|
+
-e MCP_AUTH_TOKEN=yourpassword \
|
|
59
|
+
ghcr.io/es617/obsidian-sync-mcp:latest
|
|
87
60
|
```
|
|
88
61
|
|
|
89
|
-
|
|
62
|
+
Your MCP endpoint is `https://your-app.fly.dev/mcp` (Fly.io) or `http://your-server:8787/mcp` (Docker).
|
|
90
63
|
|
|
91
|
-
|
|
92
|
-
VAULT_PATH=~/Documents/MyVault \
|
|
93
|
-
VAULT_NAME=MyVault \
|
|
94
|
-
MCP_AUTH_TOKEN=yourpassword \
|
|
95
|
-
npx obsidian-sync-mcp
|
|
96
|
-
```
|
|
64
|
+
See [Cost](#cost-flyio) for Fly.io pricing.
|
|
97
65
|
|
|
98
|
-
|
|
66
|
+
Requires [flyctl](https://fly.io/docs/flyctl/install/) for the Fly.io path:
|
|
99
67
|
|
|
100
68
|
```bash
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
ngrok http 8787 # ngrok
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Use the tunnel URL + `/mcp` as your MCP server endpoint. Set `BASE_URL` to the tunnel URL when using authentication.
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
Your Mac
|
|
111
|
-
├── Obsidian (vault on disk)
|
|
112
|
-
├── obsidian-sync-mcp (reads files directly)
|
|
113
|
-
└── tunnel → remote MCP agents
|
|
69
|
+
curl -L https://fly.io/install.sh | sh
|
|
70
|
+
export PATH="$HOME/.fly/bin:$PATH" # add to ~/.zshrc or ~/.bashrc
|
|
71
|
+
fly auth login
|
|
114
72
|
```
|
|
115
73
|
|
|
116
74
|
---
|
|
117
75
|
|
|
118
|
-
##
|
|
119
|
-
|
|
120
|
-
For a fresh setup with everything in the cloud. One Fly.io app runs both CouchDB and the MCP server. A persistent volume keeps your data.
|
|
76
|
+
## B. Deploy everything to the cloud
|
|
121
77
|
|
|
122
|
-
|
|
78
|
+
Starting fresh — no LiveSync yet. Deploy CouchDB and MCP together, then set up LiveSync in Obsidian.
|
|
123
79
|
|
|
124
|
-
|
|
80
|
+
**Using Fly.io setup script:**
|
|
125
81
|
|
|
126
82
|
```bash
|
|
127
83
|
git clone https://github.com/es617/obsidian-sync-mcp.git
|
|
128
84
|
cd obsidian-sync-mcp
|
|
129
|
-
./deploy/setup.sh
|
|
85
|
+
./deploy/setup.sh # choose option 1 (CouchDB + MCP)
|
|
130
86
|
```
|
|
131
87
|
|
|
132
|
-
|
|
88
|
+
The script generates credentials, creates the database, and deploys. Save the credentials it prints.
|
|
133
89
|
|
|
134
|
-
|
|
90
|
+
**Or with Docker Compose on any always-on server:**
|
|
135
91
|
|
|
136
92
|
```bash
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
93
|
+
git clone https://github.com/es617/obsidian-sync-mcp.git
|
|
94
|
+
cd obsidian-sync-mcp
|
|
95
|
+
|
|
96
|
+
cat > .env <<EOF
|
|
97
|
+
COUCHDB_PASSWORD=changeme
|
|
98
|
+
VAULT_NAME=MyVault
|
|
99
|
+
EOF
|
|
100
|
+
|
|
101
|
+
docker compose up -d
|
|
146
102
|
```
|
|
147
103
|
|
|
148
|
-
|
|
104
|
+
**After deployment:**
|
|
149
105
|
|
|
150
|
-
1. In Obsidian, install [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) and configure it
|
|
151
|
-
|
|
152
|
-
- Username / password: from setup
|
|
153
|
-
- Database: `obsidian`
|
|
154
|
-
2. Your MCP endpoint is `https://your-app.fly.dev/mcp`
|
|
106
|
+
1. In Obsidian, install [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) and configure it with the credentials from the setup output
|
|
107
|
+
2. Your MCP endpoint is `https://your-app.fly.dev/mcp` (Fly.io) or `http://your-server:8787/mcp` (Docker)
|
|
155
108
|
3. The `MCP_AUTH_TOKEN` is the password you enter when an agent connects
|
|
156
109
|
|
|
157
|
-
If you enable E2E encryption in LiveSync, also set: `fly secrets set COUCHDB_PASSPHRASE=your-passphrase`
|
|
158
|
-
|
|
159
110
|
```
|
|
160
|
-
|
|
161
|
-
├── CouchDB + persistent
|
|
111
|
+
Always-on server
|
|
112
|
+
├── CouchDB + persistent storage
|
|
162
113
|
└── MCP server
|
|
163
114
|
↑ ↑
|
|
164
|
-
Obsidian + LiveSync
|
|
115
|
+
Obsidian + LiveSync AI agents
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Requires [flyctl](https://fly.io/docs/flyctl/install/) for the Fly.io path:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
curl -L https://fly.io/install.sh | sh
|
|
122
|
+
export PATH="$HOME/.fly/bin:$PATH" # add to ~/.zshrc or ~/.bashrc
|
|
123
|
+
fly auth login
|
|
165
124
|
```
|
|
166
125
|
|
|
167
|
-
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### Cost (Fly.io)
|
|
129
|
+
|
|
130
|
+
Applies to both Setup A and Setup B.
|
|
168
131
|
|
|
169
132
|
| Component | Cost |
|
|
170
133
|
|---|---|
|
|
171
|
-
|
|
|
134
|
+
| CouchDB + MCP VM (shared, 512MB) | ~$3-4/month (kept alive by LiveSync) |
|
|
135
|
+
| MCP-only VM (shared, 256MB) | ~$0-2/month (suspends when idle) |
|
|
172
136
|
| 1GB persistent volume | ~$0.15/month |
|
|
173
|
-
| **Total** | **~$3-4/month** |
|
|
174
137
|
|
|
175
|
-
|
|
138
|
+
As of March 2026, Fly.io [may waive charges under $5/month](https://community.fly.io/t/bill-clarification-under-5-usd-of-usage-bill-charges-are-waived/26366), which could make this effectively free with a shared IPv4. Either way, cheaper than Obsidian Sync ($4/month) and you own the data.
|
|
176
139
|
|
|
177
140
|
---
|
|
178
141
|
|
|
179
|
-
##
|
|
142
|
+
## C. Run on your machine
|
|
143
|
+
|
|
144
|
+
Run the MCP server locally. Works with filesystem mode (reads vault files directly) or CouchDB mode (if you have LiveSync). Machine must stay on for agents to reach it.
|
|
180
145
|
|
|
181
|
-
|
|
146
|
+
**Filesystem mode (simplest):**
|
|
182
147
|
|
|
183
148
|
```bash
|
|
184
|
-
|
|
185
|
-
|
|
149
|
+
VAULT_PATH=~/Documents/MyVault \
|
|
150
|
+
VAULT_NAME=MyVault \
|
|
151
|
+
npx obsidian-sync-mcp
|
|
152
|
+
```
|
|
186
153
|
|
|
187
|
-
|
|
188
|
-
COUCHDB_PASSWORD=changeme
|
|
189
|
-
VAULT_NAME=MyVault
|
|
190
|
-
EOF
|
|
154
|
+
**CouchDB mode (if you have LiveSync):**
|
|
191
155
|
|
|
192
|
-
|
|
156
|
+
```bash
|
|
157
|
+
COUCHDB_URL=http://localhost:5984 \
|
|
158
|
+
COUCHDB_USER=admin \
|
|
159
|
+
COUCHDB_PASSWORD=yourpassword \
|
|
160
|
+
COUCHDB_DATABASE=obsidian \
|
|
161
|
+
VAULT_NAME=MyVault \
|
|
162
|
+
npx obsidian-sync-mcp
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Or with Docker:**
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
docker run -p 8787:8787 \
|
|
169
|
+
-e VAULT_PATH=/vault -v ~/Documents/MyVault:/vault \
|
|
170
|
+
-e VAULT_NAME=MyVault \
|
|
171
|
+
ghcr.io/es617/obsidian-sync-mcp:latest
|
|
193
172
|
```
|
|
194
173
|
|
|
195
|
-
|
|
174
|
+
Your MCP endpoint is `http://localhost:8787/mcp`.
|
|
175
|
+
|
|
176
|
+
**Want remote access?** Add a tunnel (machine must stay on):
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
cloudflared tunnel --url http://localhost:8787 # free
|
|
180
|
+
tailscale funnel 8787 # or Tailscale
|
|
181
|
+
ngrok http 8787 # or ngrok
|
|
182
|
+
```
|
|
196
183
|
|
|
197
|
-
|
|
184
|
+
Set `BASE_URL` to the tunnel URL when using authentication.
|
|
198
185
|
|
|
199
186
|
---
|
|
200
187
|
|
|
@@ -234,7 +221,7 @@ The session is shared across all your Claude interfaces (Desktop, Web, Mobile) a
|
|
|
234
221
|
|
|
235
222
|
For non-OAuth clients (curl, MCP Inspector, custom agents), you can also pass the token directly as `Authorization: Bearer <MCP_AUTH_TOKEN>`.
|
|
236
223
|
|
|
237
|
-
Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable for local
|
|
224
|
+
Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable for local use or behind a private network.
|
|
238
225
|
|
|
239
226
|
---
|
|
240
227
|
|
|
@@ -242,12 +229,12 @@ Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable fo
|
|
|
242
229
|
|
|
243
230
|
| Variable | Required | Default | Description |
|
|
244
231
|
|---|---|---|---|
|
|
245
|
-
| `VAULT_PATH` |
|
|
246
|
-
| `COUCHDB_URL` |
|
|
247
|
-
| `COUCHDB_USER` |
|
|
248
|
-
| `COUCHDB_PASSWORD` |
|
|
249
|
-
| `COUCHDB_DATABASE` |
|
|
250
|
-
| `COUCHDB_PASSPHRASE` |
|
|
232
|
+
| `VAULT_PATH` | Filesystem mode | — | Path to your Obsidian vault directory |
|
|
233
|
+
| `COUCHDB_URL` | CouchDB mode | — | CouchDB server URL |
|
|
234
|
+
| `COUCHDB_USER` | CouchDB mode | `admin` | CouchDB username |
|
|
235
|
+
| `COUCHDB_PASSWORD` | CouchDB mode | `password` | CouchDB password |
|
|
236
|
+
| `COUCHDB_DATABASE` | CouchDB mode | `obsidian` | CouchDB database name |
|
|
237
|
+
| `COUCHDB_PASSPHRASE` | CouchDB mode | — | LiveSync E2E encryption passphrase (must match plugin setting) |
|
|
251
238
|
| `VAULT_NAME` | Both | `MyVault` | Vault name for Obsidian deep links |
|
|
252
239
|
| `MCP_AUTH_TOKEN` | Optional | — | Password for authentication |
|
|
253
240
|
| `BASE_URL` | Optional | `http://localhost:PORT` | Public URL (for OAuth callbacks when using a tunnel) |
|
|
@@ -256,7 +243,7 @@ Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable fo
|
|
|
256
243
|
| `DATA_DIR` | Optional | `~/.obsidian-mcp` | Directory for persisted data (search index, auth tokens) |
|
|
257
244
|
| `MCP_REFRESH_DAYS` | Optional | `14` | Days before auth session expires |
|
|
258
245
|
|
|
259
|
-
Set `VAULT_PATH` for
|
|
246
|
+
Set `VAULT_PATH` for filesystem mode or `COUCHDB_URL` for CouchDB mode.
|
|
260
247
|
|
|
261
248
|
---
|
|
262
249
|
|
|
@@ -273,21 +260,20 @@ Set transport to **Streamable HTTP**, enter `http://localhost:8787/mcp`, and con
|
|
|
273
260
|
|
|
274
261
|
---
|
|
275
262
|
|
|
276
|
-
##
|
|
263
|
+
## How to update
|
|
277
264
|
|
|
278
265
|
| How you run it | How to update |
|
|
279
266
|
|---|---|
|
|
280
267
|
| `npx obsidian-sync-mcp` | Automatic — npx pulls latest |
|
|
281
|
-
| Fly.io
|
|
282
|
-
|
|
|
283
|
-
| Docker Compose | `docker compose pull && docker compose up -d` |
|
|
268
|
+
| Fly.io | From the same directory where you ran setup: `fly deploy`. If you lost the fly.toml, run `fly config save --app your-app-name` to restore it. |
|
|
269
|
+
| Docker | `docker pull ghcr.io/es617/obsidian-sync-mcp:latest` and restart |
|
|
284
270
|
|
|
285
271
|
---
|
|
286
272
|
|
|
287
273
|
## Known limitations
|
|
288
274
|
|
|
289
275
|
- **Single vault per instance.** Each server connects to one vault. For multiple vaults, run multiple instances on different ports.
|
|
290
|
-
- **
|
|
276
|
+
- **Single machine on Fly.io.** Auth state is in-memory, so multiple machines break the OAuth flow. The setup script enforces this automatically.
|
|
291
277
|
- **No conflict resolution.** If an agent and Obsidian edit the same note simultaneously, last write wins.
|
|
292
278
|
- **Text only.** Binary attachments are not exposed through MCP tools.
|
|
293
279
|
- **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.
|
|
@@ -315,7 +301,7 @@ This software is provided as-is under the [MIT license](https://github.com/es617
|
|
|
315
301
|
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
316
302
|
cd obsidian-sync-mcp
|
|
317
303
|
npm install && npm run build
|
|
318
|
-
npm test #
|
|
304
|
+
npm test # unit tests
|
|
319
305
|
npm run test:e2e # integration tests
|
|
320
306
|
```
|
|
321
307
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
// Node polyfills for livesync-commonlib browser globals
|
|
2
3
|
if(!("navigator" in globalThis)){globalThis.navigator={language:"en"};}
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
@@ -79,4 +80,4 @@ export {
|
|
|
79
80
|
parseFrontmatterAndLinks,
|
|
80
81
|
extractSnippet
|
|
81
82
|
};
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
83
|
+
//# sourceMappingURL=chunk-TFJDIQK4.js.map
|
|
@@ -1 +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 idx = content.toLowerCase().indexOf(query.toLowerCase());\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":"
|
|
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 idx = content.toLowerCase().indexOf(query.toLowerCase());\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;AAGA,aAAW,SAAS,QAAQ,SAAS,mBAAmB,GAAG;AACvD,SAAK,IAAI,MAAM,CAAC,CAAC;AAAA,EACrB;AAGA,aAAW,SAAS,QAAQ,SAAS,iCAAiC,GAAG;AACrE,UAAM,KAAK,MAAM,CAAC,CAAC;AAAA,EACvB;AAGA,aAAW,SAAS,QAAQ,SAAS,8BAA8B,GAAG;AAClE,UAAM,KAAK,MAAM,CAAC,CAAC;AAAA,EACvB;AAEA,SAAO,EAAE,aAAa,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,EAAE;AACtE;AAEO,SAAS,eAAe,SAAiB,OAAe,UAAU,IAAY;AACjF,QAAM,MAAM,QAAQ,YAAY,EAAE,QAAQ,MAAM,YAAY,CAAC;AAC7D,MAAI,QAAQ,IAAI;AACZ,WAAO,QAAQ,MAAM,GAAG,GAAG,KAAK,QAAQ,SAAS,MAAM,QAAQ;AAAA,EACnE;AACA,QAAM,QAAQ,KAAK,IAAI,GAAG,MAAM,OAAO;AACvC,QAAM,MAAM,KAAK,IAAI,QAAQ,QAAQ,MAAM,MAAM,SAAS,OAAO;AACjE,UAAQ,QAAQ,IAAI,QAAQ,MAAM,QAAQ,MAAM,OAAO,GAAG,KAAK,MAAM,QAAQ,SAAS,QAAQ;AAClG;","names":[]}
|
package/dist/main.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
// Node polyfills for livesync-commonlib browser globals
|
|
2
3
|
if(!("navigator" in globalThis)){globalThis.navigator={language:"en"};}
|
|
3
4
|
import {
|
|
4
5
|
extractSnippet
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-TFJDIQK4.js";
|
|
6
7
|
|
|
7
8
|
// src/main.ts
|
|
8
9
|
import { FastMCP } from "fastmcp";
|
|
@@ -607,11 +608,11 @@ var BASE_URL = process.env.BASE_URL ?? `http://localhost:${PORT}`;
|
|
|
607
608
|
var AUTH_TOKEN = process.env.MCP_AUTH_TOKEN;
|
|
608
609
|
var vault;
|
|
609
610
|
if (VAULT_PATH) {
|
|
610
|
-
const { LocalVault } = await import("./vault-local-
|
|
611
|
+
const { LocalVault } = await import("./vault-local-3C2JVBRO.js");
|
|
611
612
|
vault = new LocalVault(VAULT_PATH);
|
|
612
613
|
console.log(`Local mode: ${VAULT_PATH}`);
|
|
613
614
|
} else if (COUCHDB_URL) {
|
|
614
|
-
const { Vault } = await import("./vault-
|
|
615
|
+
const { Vault } = await import("./vault-J2V2D3HA.js");
|
|
615
616
|
vault = new Vault({
|
|
616
617
|
couchdbUrl: COUCHDB_URL,
|
|
617
618
|
couchdbUser: COUCHDB_USER,
|
|
@@ -670,8 +671,8 @@ if (VAULT_PATH) {
|
|
|
670
671
|
}
|
|
671
672
|
var serverOptions = {
|
|
672
673
|
name: "obsidian-sync-mcp",
|
|
673
|
-
version: "0.
|
|
674
|
-
instructions: "Access and manage an Obsidian vault. You can read, write, list, search, and delete markdown notes. Every response includes
|
|
674
|
+
version: "0.3.0",
|
|
675
|
+
instructions: "Access and manage an Obsidian vault. You can read, write, list, search, move, and delete markdown notes. 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."
|
|
675
676
|
};
|
|
676
677
|
var auth = null;
|
|
677
678
|
if (AUTH_TOKEN) {
|