obsidian-sync-mcp 0.1.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/LICENSE +21 -0
- package/README.md +360 -0
- package/dist/chunk-26MFONZB.js +20 -0
- package/dist/chunk-26MFONZB.js.map +1 -0
- package/dist/chunk-ZJJW3NJ5.js +43 -0
- package/dist/chunk-ZJJW3NJ5.js.map +1 -0
- package/dist/main.js +703 -0
- package/dist/main.js.map +1 -0
- package/dist/vault-IGTFVPKN.js +4890 -0
- package/dist/vault-IGTFVPKN.js.map +1 -0
- package/dist/vault-local-65IVVIHQ.js +135 -0
- package/dist/vault-local-65IVVIHQ.js.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Enrico Santagati and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# Obsidian Sync MCP
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.es617/obsidian-sync-mcp -->
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
Give any AI agent remote read/write access to your Obsidian vault over MCP. Run it locally from your machine, or deploy it to the cloud so it works even when your laptop is off.
|
|
11
|
+
|
|
12
|
+
> **Example:** From your phone, ask your Claude AI: "What's in my daily note for today?" — and get the full content back, with a link to open it in Obsidian.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Why this exists
|
|
17
|
+
|
|
18
|
+
Your Obsidian vault is locked to your device. Neither iCloud nor Obsidian Sync expose an API — Obsidian Sync is E2E encrypted with keys held only inside the app, intentionally inaccessible to external tools.
|
|
19
|
+
|
|
20
|
+
This server makes your vault available to any MCP-compatible agent — Claude, Copilot, custom agents, anything that speaks the [Model Context Protocol](https://modelcontextprotocol.io). It runs as a remote HTTP server, so agents can reach your notes from anywhere: web interfaces, mobile apps, CI pipelines, other machines.
|
|
21
|
+
|
|
22
|
+
Local agents (Claude Code, Cursor, etc.) can already read vault files directly. This project solves the harder problem: **remote access**.
|
|
23
|
+
|
|
24
|
+
In remote mode, the server uses [livesync-commonlib](https://github.com/vrtmrz/livesync-commonlib) — the same library that powers the [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) plugin — for proper chunk handling, content-defined splitting, and metadata management. No shortcuts or reimplementation.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Three ways to run it
|
|
29
|
+
|
|
30
|
+
| Option | Setup | Best for |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| **1. Local + tunnel** | Point at vault folder, expose with a tunnel | Simplest; no database needed; Mac must stay on |
|
|
33
|
+
| **2. Docker Compose** | CouchDB + MCP server in containers | Local dev; everything in Docker |
|
|
34
|
+
| **3. Fly.io** | Deploy to the cloud, always on | Production; no Mac needed |
|
|
35
|
+
|
|
36
|
+
Options 2 and 3 use [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) to sync your vault to CouchDB. The MCP server reads from CouchDB, so it works even when your Mac is off.
|
|
37
|
+
|
|
38
|
+
**Already have LiveSync?** Just point the MCP server at your existing CouchDB — no need to set up a new database. Run `COUCHDB_URL=https://your-db:5984 node dist/main.js` locally, or deploy the MCP-only Docker image (`ghcr.io/es617/obsidian-sync-mcp`) anywhere.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Option 1: Local mode + tunnel
|
|
43
|
+
|
|
44
|
+
No database, no containers. The server reads `.md` files directly from your vault.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
48
|
+
cd obsidian-sync-mcp
|
|
49
|
+
npm install && npm run build
|
|
50
|
+
|
|
51
|
+
VAULT_PATH=~/Documents/MyVault VAULT_NAME=MyVault node dist/main.js
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Expose it for remote agents:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Pick one:
|
|
58
|
+
cloudflared tunnel --url http://localhost:8787 # Cloudflare (free)
|
|
59
|
+
tailscale funnel 8787 # Tailscale
|
|
60
|
+
ngrok http 8787 # ngrok
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use the tunnel URL + `/mcp` as your MCP server endpoint.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
Your Mac
|
|
67
|
+
├── Obsidian (vault on disk)
|
|
68
|
+
├── obsidian-sync-mcp (reads files directly)
|
|
69
|
+
└── tunnel → remote MCP agents
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Option 2: Docker Compose
|
|
75
|
+
|
|
76
|
+
CouchDB and the MCP server run side by side in Docker. Your Obsidian vault syncs to CouchDB via the LiveSync plugin.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
80
|
+
cd obsidian-sync-mcp
|
|
81
|
+
|
|
82
|
+
# Optional: create a .env file
|
|
83
|
+
cat > .env <<EOF
|
|
84
|
+
COUCHDB_USER=admin
|
|
85
|
+
COUCHDB_PASSWORD=changeme
|
|
86
|
+
VAULT_NAME=MyVault
|
|
87
|
+
EOF
|
|
88
|
+
|
|
89
|
+
docker compose up -d
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This starts:
|
|
93
|
+
- **CouchDB** on port 5984
|
|
94
|
+
- **MCP server** on port 8787, pre-configured to talk to CouchDB
|
|
95
|
+
|
|
96
|
+
Then set up your vault:
|
|
97
|
+
|
|
98
|
+
1. Create the database: `curl -u admin:changeme -X PUT http://localhost:5984/obsidian`
|
|
99
|
+
2. In Obsidian, install the [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) plugin
|
|
100
|
+
3. Configure it: server `http://localhost:5984`, username/password from above, database `obsidian`
|
|
101
|
+
4. Enable LiveSync mode
|
|
102
|
+
|
|
103
|
+
Your MCP server is at `http://localhost:8787/mcp`. Expose it with a tunnel for remote access:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Install cloudflared (one-time)
|
|
107
|
+
brew install cloudflared
|
|
108
|
+
|
|
109
|
+
# Expose the MCP server
|
|
110
|
+
cloudflared tunnel --url http://localhost:8787
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Docker Compose
|
|
115
|
+
├── CouchDB (port 5984) ←── Obsidian + LiveSync plugin
|
|
116
|
+
└── MCP server (port 8787) ←── Remote agents (via tunnel)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Option 3: Fly.io
|
|
122
|
+
|
|
123
|
+
Always-on deployment. One Fly.io app runs both CouchDB and the MCP server. A persistent volume keeps your data. The database is created automatically on first boot.
|
|
124
|
+
|
|
125
|
+
### One-click deploy
|
|
126
|
+
|
|
127
|
+
[](https://fly.io/launch?repo=https://github.com/es617/obsidian-sync-mcp&ref=main&config=deploy/fly.toml)
|
|
128
|
+
|
|
129
|
+
After deploy, set your secrets in the Fly.io dashboard or CLI:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
fly secrets set COUCHDB_PASSWORD=$(openssl rand -hex 16) MCP_AUTH_TOKEN=$(openssl rand -hex 16) VAULT_NAME=MyVault
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Setup script
|
|
136
|
+
|
|
137
|
+
Generates credentials, creates the volume, and deploys — all in one command:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
git clone https://github.com/es617/obsidian-sync-mcp.git
|
|
141
|
+
cd obsidian-sync-mcp
|
|
142
|
+
./deploy/setup.sh
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Save the credentials it prints — they won't be shown again.
|
|
146
|
+
|
|
147
|
+
### Manual CLI
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
cd deploy
|
|
151
|
+
fly launch --no-deploy --copy-config
|
|
152
|
+
fly secrets set \
|
|
153
|
+
COUCHDB_USER=admin \
|
|
154
|
+
COUCHDB_PASSWORD=$(openssl rand -hex 16) \
|
|
155
|
+
COUCHDB_DATABASE=obsidian \
|
|
156
|
+
VAULT_NAME=MyVault \
|
|
157
|
+
MCP_AUTH_TOKEN=$(openssl rand -hex 16)
|
|
158
|
+
fly volumes create couchdb_data --size 1
|
|
159
|
+
fly deploy
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### After deployment
|
|
163
|
+
|
|
164
|
+
1. In Obsidian, install [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) and configure it:
|
|
165
|
+
- Server URL: `https://your-app.fly.dev:5984`
|
|
166
|
+
- Username / password: the CouchDB credentials from setup
|
|
167
|
+
- Database: `obsidian`
|
|
168
|
+
2. Your MCP endpoint is `https://your-app.fly.dev/mcp`
|
|
169
|
+
3. The `MCP_AUTH_TOKEN` is the password you (or your users) enter when an agent connects
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
Fly.io (always on)
|
|
173
|
+
├── CouchDB + persistent volume
|
|
174
|
+
└── MCP server
|
|
175
|
+
↑ ↑
|
|
176
|
+
Obsidian + LiveSync Remote MCP agents
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Cost
|
|
180
|
+
|
|
181
|
+
| Component | Cost |
|
|
182
|
+
|---|---|
|
|
183
|
+
| Fly.io VM (shared, 512MB) | ~$3-4/month |
|
|
184
|
+
| 1GB persistent volume | ~$0.15/month |
|
|
185
|
+
| **Total** | **~$3-4/month** |
|
|
186
|
+
|
|
187
|
+
Comparable to Obsidian Sync ($4/month) and you own the data.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## What the agent can do
|
|
192
|
+
|
|
193
|
+
- **Read notes** — fetch any markdown note by path, with full content
|
|
194
|
+
- **Write notes** — create or update notes; the server handles LiveSync's chunked format in remote mode
|
|
195
|
+
- **List notes** — browse the vault, optionally filtered by folder
|
|
196
|
+
- **Search** — sub-millisecond full-text search via [FlexSearch](https://github.com/nextapps-de/flexsearch) index, with context snippets
|
|
197
|
+
- **Delete notes** — remove notes from the vault
|
|
198
|
+
- **Deep links** — every response includes an `obsidian://` link to open the note in Obsidian on Mac or iOS
|
|
199
|
+
|
|
200
|
+
> "List all my notes in the projects/ folder, then read the one about the MCP server."
|
|
201
|
+
|
|
202
|
+
The agent handles multi-step flows. "Summarize my last 5 daily notes" means listing the folder, reading each note, and synthesizing — without you specifying each step.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Environment variables
|
|
207
|
+
|
|
208
|
+
| Variable | Required | Default | Description |
|
|
209
|
+
|---|---|---|---|
|
|
210
|
+
| `VAULT_PATH` | Local mode | — | Path to your Obsidian vault directory |
|
|
211
|
+
| `COUCHDB_URL` | Remote mode | — | CouchDB server URL (e.g. `http://localhost:5984`) |
|
|
212
|
+
| `COUCHDB_USER` | Remote mode | `admin` | CouchDB username |
|
|
213
|
+
| `COUCHDB_PASSWORD` | Remote mode | `password` | CouchDB password |
|
|
214
|
+
| `COUCHDB_DATABASE` | Remote mode | `obsidian` | CouchDB database name |
|
|
215
|
+
| `COUCHDB_PASSPHRASE` | Remote mode | — | LiveSync E2E encryption passphrase (if enabled) |
|
|
216
|
+
| `LIVESYNC_USER` | Remote mode | — | Non-admin CouchDB user for LiveSync (recommended). If set with `LIVESYNC_PASSWORD`, the entrypoint creates a restricted user with access only to the vault database. |
|
|
217
|
+
| `LIVESYNC_PASSWORD` | Remote mode | — | Password for the LiveSync user |
|
|
218
|
+
| `VAULT_NAME` | Both | `MyVault` | Vault name for deep links (must match your Obsidian vault name) |
|
|
219
|
+
| `PORT` | Both | `8787` | HTTP port |
|
|
220
|
+
| `BASE_URL` | Both | `http://localhost:PORT` | Public URL (for OAuth callbacks) |
|
|
221
|
+
| `MCP_AUTH_TOKEN` | Optional | — | Password for OAuth approval page. When set, all MCP requests require authentication. |
|
|
222
|
+
| `MCP_REFRESH_DAYS` | Optional | `14` | Days before the session expires and the user must re-enter the password. |
|
|
223
|
+
|
|
224
|
+
Set `VAULT_PATH` for local mode or `COUCHDB_URL` for remote mode. If neither is set, the server exits with an error.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Tools
|
|
229
|
+
|
|
230
|
+
| Tool | Description |
|
|
231
|
+
|---|---|
|
|
232
|
+
| `read_note` | Read a note's markdown content by path |
|
|
233
|
+
| `write_note` | Create or overwrite a note (preserves creation time on updates) |
|
|
234
|
+
| `list_notes` | List all `.md` files, optionally filtered by folder |
|
|
235
|
+
| `search_vault` | Full-text search across all notes (capped at 50 results) |
|
|
236
|
+
| `delete_note` | Delete a note |
|
|
237
|
+
| `move_note` | Move or rename a note — works across folders, creates destination folders automatically |
|
|
238
|
+
| `get_note_metadata` | Get frontmatter, tags, links, size, and timestamps without reading the full content |
|
|
239
|
+
|
|
240
|
+
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.
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Authentication
|
|
245
|
+
|
|
246
|
+
The server includes a **self-contained OAuth 2.1 provider** with password-gated approval. No Google, GitHub, or any third-party OAuth app needed.
|
|
247
|
+
|
|
248
|
+
Set `MCP_AUTH_TOKEN` to a password:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
MCP_AUTH_TOKEN=mysecretpassword node dist/main.js
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
When a remote agent connects:
|
|
255
|
+
|
|
256
|
+
1. The agent discovers the OAuth endpoints automatically
|
|
257
|
+
2. A browser window opens showing a password page
|
|
258
|
+
3. The user enters the `MCP_AUTH_TOKEN` password
|
|
259
|
+
4. The agent gets an access token and refreshes it transparently
|
|
260
|
+
|
|
261
|
+
You only enter the password once — the session is shared across all your Claude interfaces (Desktop, Web, Mobile). The refresh token keeps it alive for 14 days of inactivity (configurable via `MCP_REFRESH_DAYS`).
|
|
262
|
+
|
|
263
|
+
Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable for local testing or use behind a private tunnel.
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
## Try without an agent
|
|
268
|
+
|
|
269
|
+
Test the server interactively using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Start the server
|
|
273
|
+
VAULT_PATH=~/Documents/MyVault node dist/main.js
|
|
274
|
+
|
|
275
|
+
# In another terminal
|
|
276
|
+
npx @modelcontextprotocol/inspector
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Open the Inspector URL, set transport to **Streamable HTTP**, enter `http://localhost:8787/mcp`, and connect. You can call any tool from the web UI.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Development
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
287
|
+
cd obsidian-sync-mcp
|
|
288
|
+
npm install
|
|
289
|
+
npm run build
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
The `--recursive` flag is important — it pulls the `livesync-commonlib` submodule needed for remote mode.
|
|
293
|
+
|
|
294
|
+
### Build
|
|
295
|
+
|
|
296
|
+
[tsup](https://github.com/egoist/tsup) bundles `livesync-commonlib` (which uses Deno-style TypeScript imports) into standard Node.js modules via an esbuild plugin that resolves `.ts` imports, path aliases, and browser polyfills at build time.
|
|
297
|
+
|
|
298
|
+
### Docker
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Build the standalone MCP server image
|
|
302
|
+
docker build -t obsidian-sync-mcp .
|
|
303
|
+
|
|
304
|
+
# Build the combined CouchDB + MCP image (for Fly.io)
|
|
305
|
+
docker build -f deploy/Dockerfile.fly -t obsidian-sync-mcp-fly .
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## Updating
|
|
311
|
+
|
|
312
|
+
| How you run it | How to update |
|
|
313
|
+
|---|---|
|
|
314
|
+
| `npx obsidian-sync-mcp` | Automatic — npx pulls latest |
|
|
315
|
+
| `npm install -g obsidian-sync-mcp` | `npm update -g obsidian-sync-mcp` |
|
|
316
|
+
| Fly.io | `fly deploy` — pulls latest MCP image + CouchDB patch |
|
|
317
|
+
| Docker Compose | `docker compose pull && docker compose up -d` |
|
|
318
|
+
|
|
319
|
+
For Fly.io, `fly deploy` rebuilds the container from the latest published image on ghcr.io. No git clone or source code needed. Pin a specific version with:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
fly deploy --build-arg MCP_IMAGE=ghcr.io/es617/obsidian-sync-mcp:v1.0.0
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Known limitations
|
|
328
|
+
|
|
329
|
+
- **Search index rebuilds on cold start.** The FlexSearch full-text index lives in memory and persists to disk on shutdown. Typical rebuild: ~200ms for 2000 notes. Survives Fly.io suspend/resume (memory preserved). External edits (from Obsidian) are picked up automatically via filesystem watcher (local) or CouchDB `_changes` feed (remote).
|
|
330
|
+
- **No conflict resolution.** If an agent and Obsidian edit the same note simultaneously, CouchDB's revision system handles it in remote mode (last write wins). Local mode has no protection — the last write overwrites.
|
|
331
|
+
- **Text only.** Binary attachments (images, PDFs) are not exposed through the MCP tools. The underlying library supports them, but most agents can't do much with raw binary data.
|
|
332
|
+
- **Node 22+ required.** Uses `fs/promises.glob` in local mode.
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Safety
|
|
337
|
+
|
|
338
|
+
This server gives an AI agent read/write access to your Obsidian vault. That's the point — and it means you should understand what it can do.
|
|
339
|
+
|
|
340
|
+
**Agents can modify and delete notes.** A bad prompt or a misbehaving agent can overwrite or delete your notes. Keep backups. Use tool approval deliberately — "always allow" is convenient but means the agent can repeat any action without further confirmation.
|
|
341
|
+
|
|
342
|
+
**Local mode has filesystem scope.** The server restricts file access to your vault directory (path traversal is blocked), but the process itself runs with your user permissions.
|
|
343
|
+
|
|
344
|
+
**Authentication is optional.** Without `MCP_AUTH_TOKEN`, any client that can reach the server has full vault access. Always set a password when exposing the server to the internet.
|
|
345
|
+
|
|
346
|
+
**Use HTTPS in production.** The server doesn't handle TLS itself — use a tunnel (Cloudflare, Tailscale, ngrok) or deploy behind a reverse proxy. Without TLS, passwords and tokens travel in cleartext.
|
|
347
|
+
|
|
348
|
+
This software is provided as-is under the [MIT license](LICENSE). You are responsible for what agents do with your vault.
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## License
|
|
353
|
+
|
|
354
|
+
This project is licensed under the MIT License — see [LICENSE](LICENSE) for details.
|
|
355
|
+
|
|
356
|
+
## Acknowledgements
|
|
357
|
+
|
|
358
|
+
- [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) by vrtmrz — the Obsidian plugin and CouchDB sync protocol
|
|
359
|
+
- [livesync-commonlib](https://github.com/vrtmrz/livesync-commonlib) by vrtmrz — the shared library for reading/writing the LiveSync document format
|
|
360
|
+
- [FastMCP](https://github.com/punkpeye/fastmcp) — TypeScript MCP framework with built-in OAuth
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Node polyfills for livesync-commonlib browser globals
|
|
2
|
+
if(!("navigator" in globalThis)){globalThis.navigator={language:"en"};}
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
__reExport
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=chunk-26MFONZB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Node polyfills for livesync-commonlib browser globals
|
|
2
|
+
if(!("navigator" in globalThis)){globalThis.navigator={language:"en"};}
|
|
3
|
+
|
|
4
|
+
// src/parse.ts
|
|
5
|
+
function parseFrontmatterAndLinks(content) {
|
|
6
|
+
const frontmatter = {};
|
|
7
|
+
const tags = /* @__PURE__ */ new Set();
|
|
8
|
+
const links = [];
|
|
9
|
+
if (content.startsWith("---\n")) {
|
|
10
|
+
const end = content.indexOf("\n---", 4);
|
|
11
|
+
if (end !== -1) {
|
|
12
|
+
const yaml = content.slice(4, end);
|
|
13
|
+
for (const line of yaml.split("\n")) {
|
|
14
|
+
const match = line.match(/^(\w[\w-]*)\s*:\s*(.+)/);
|
|
15
|
+
if (match) {
|
|
16
|
+
frontmatter[match[1]] = match[2].trim();
|
|
17
|
+
}
|
|
18
|
+
if (/^tags\s*:/.test(line)) {
|
|
19
|
+
const tagValues = line.replace(/^tags\s*:\s*/, "").replace(/[[\]]/g, "");
|
|
20
|
+
for (const t of tagValues.split(",")) {
|
|
21
|
+
const trimmed = t.trim();
|
|
22
|
+
if (trimmed) tags.add(trimmed);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const match of content.matchAll(/(^|\s)#([\w/-]+)/g)) {
|
|
29
|
+
tags.add(match[2]);
|
|
30
|
+
}
|
|
31
|
+
for (const match of content.matchAll(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) {
|
|
32
|
+
links.push(match[1]);
|
|
33
|
+
}
|
|
34
|
+
for (const match of content.matchAll(/\[([^\]]+)\]\(([^)]+\.md)\)/g)) {
|
|
35
|
+
links.push(match[2]);
|
|
36
|
+
}
|
|
37
|
+
return { frontmatter, tags: [...tags], links: [...new Set(links)] };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
parseFrontmatterAndLinks
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=chunk-ZJJW3NJ5.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, any>;\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 for (const line of yaml.split(\"\\n\")) {\n const match = line.match(/^(\\w[\\w-]*)\\s*:\\s*(.+)/);\n if (match) {\n frontmatter[match[1]] = match[2].trim();\n }\n // Frontmatter tags\n if (/^tags\\s*:/.test(line)) {\n const tagValues = line.replace(/^tags\\s*:\\s*/, \"\").replace(/[[\\]]/g, \"\");\n for (const t of tagValues.split(\",\")) {\n const trimmed = t.trim();\n if (trimmed) tags.add(trimmed);\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"],"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,iBAAW,QAAQ,KAAK,MAAM,IAAI,GAAG;AACjC,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,YAAY,KAAK,QAAQ,gBAAgB,EAAE,EAAE,QAAQ,UAAU,EAAE;AACvE,qBAAW,KAAK,UAAU,MAAM,GAAG,GAAG;AAClC,kBAAM,UAAU,EAAE,KAAK;AACvB,gBAAI,QAAS,MAAK,IAAI,OAAO;AAAA,UACjC;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;","names":[]}
|