obsidian-sync-mcp 0.1.2 → 0.2.2
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 +145 -176
- package/dist/chunk-TFJDIQK4.js +83 -0
- package/dist/chunk-TFJDIQK4.js.map +1 -0
- package/dist/main.js +204 -187
- package/dist/main.js.map +1 -1
- package/dist/{vault-IGTFVPKN.js → vault-J2V2D3HA.js} +4 -25
- package/dist/{vault-IGTFVPKN.js.map → vault-J2V2D3HA.js.map} +1 -1
- package/dist/{vault-local-65IVVIHQ.js → vault-local-3C2JVBRO.js} +3 -20
- package/dist/vault-local-3C2JVBRO.js.map +1 -0
- package/package.json +3 -3
- package/dist/chunk-26MFONZB.js +0 -20
- package/dist/chunk-26MFONZB.js.map +0 -1
- package/dist/chunk-ZJJW3NJ5.js +0 -43
- package/dist/chunk-ZJJW3NJ5.js.map +0 -1
- package/dist/vault-local-65IVVIHQ.js.map +0 -1
package/README.md
CHANGED
|
@@ -9,152 +9,138 @@
|
|
|
9
9
|
|
|
10
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
11
|
|
|
12
|
-
> **Example:** From your phone, ask your
|
|
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
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## How it works
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
The server has two modes:
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
- **Local mode** — reads `.md` files directly from your vault folder. No database needed.
|
|
21
|
+
- **Remote mode** — reads from CouchDB via [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync), the community plugin that replaces iCloud/Obsidian Sync with a CouchDB backend (600k+ downloads). The server uses [livesync-commonlib](https://github.com/vrtmrz/livesync-commonlib) — the same library that powers the plugin — for proper chunk handling and E2E encryption support.
|
|
21
22
|
|
|
22
|
-
|
|
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.
|
|
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).
|
|
25
24
|
|
|
26
25
|
---
|
|
27
26
|
|
|
28
|
-
##
|
|
27
|
+
## Choose your setup
|
|
29
28
|
|
|
30
|
-
|
|
|
29
|
+
| You have... | Do this | What happens |
|
|
31
30
|
|---|---|---|
|
|
32
|
-
| **
|
|
33
|
-
| **
|
|
34
|
-
| **
|
|
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.
|
|
31
|
+
| **LiveSync already** | Point MCP server at your CouchDB | Add AI access to your existing setup |
|
|
32
|
+
| **A Mac that's always on** | Run in local mode + tunnel | Reads files directly, no database |
|
|
33
|
+
| **Nothing yet, want it always on** | Deploy to Fly.io | CouchDB + MCP server in the cloud |
|
|
39
34
|
|
|
40
35
|
---
|
|
41
36
|
|
|
42
|
-
##
|
|
37
|
+
## Already have LiveSync?
|
|
43
38
|
|
|
44
|
-
No database, no
|
|
39
|
+
If you're already using Self-hosted LiveSync, you just need the MCP server. No database setup, no plugin changes — point it at your existing CouchDB.
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
48
|
-
cd obsidian-sync-mcp
|
|
49
|
-
npm install && npm run build
|
|
41
|
+
### Run locally
|
|
50
42
|
|
|
51
|
-
|
|
43
|
+
```bash
|
|
44
|
+
npx obsidian-sync-mcp
|
|
52
45
|
```
|
|
53
46
|
|
|
54
|
-
|
|
47
|
+
Set your CouchDB connection:
|
|
55
48
|
|
|
56
49
|
```bash
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
61
57
|
```
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
### Or deploy to Fly.io (MCP only, no CouchDB)
|
|
64
60
|
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
70
71
|
```
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
No volume needed — the MCP server is stateless (it reads from your CouchDB).
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
Your MCP endpoint is `https://your-app.fly.dev/mcp`.
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
> If you use E2E encryption in LiveSync, also set `COUCHDB_PASSPHRASE` to the same passphrase.
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
80
|
-
cd obsidian-sync-mcp
|
|
79
|
+
---
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
cat > .env <<EOF
|
|
84
|
-
COUCHDB_USER=admin
|
|
85
|
-
COUCHDB_PASSWORD=changeme
|
|
86
|
-
VAULT_NAME=MyVault
|
|
87
|
-
EOF
|
|
81
|
+
## Local mode + tunnel
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
```
|
|
83
|
+
No database, no containers. The server reads `.md` files directly from your vault. Your Mac needs to stay on.
|
|
91
84
|
|
|
92
|
-
|
|
93
|
-
-
|
|
94
|
-
|
|
85
|
+
```bash
|
|
86
|
+
npx obsidian-sync-mcp
|
|
87
|
+
```
|
|
95
88
|
|
|
96
|
-
|
|
89
|
+
With configuration:
|
|
97
90
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
```bash
|
|
92
|
+
VAULT_PATH=~/Documents/MyVault \
|
|
93
|
+
VAULT_NAME=MyVault \
|
|
94
|
+
MCP_AUTH_TOKEN=yourpassword \
|
|
95
|
+
npx obsidian-sync-mcp
|
|
96
|
+
```
|
|
102
97
|
|
|
103
|
-
|
|
98
|
+
Expose it for remote agents:
|
|
104
99
|
|
|
105
100
|
```bash
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
cloudflared tunnel --url http://localhost:8787
|
|
101
|
+
# Pick one:
|
|
102
|
+
cloudflared tunnel --url http://localhost:8787 # Cloudflare (free)
|
|
103
|
+
tailscale funnel 8787 # Tailscale
|
|
104
|
+
ngrok http 8787 # ngrok
|
|
111
105
|
```
|
|
112
106
|
|
|
107
|
+
Use the tunnel URL + `/mcp` as your MCP server endpoint. Set `BASE_URL` to the tunnel URL when using authentication.
|
|
108
|
+
|
|
113
109
|
```
|
|
114
|
-
|
|
115
|
-
├──
|
|
116
|
-
|
|
110
|
+
Your Mac
|
|
111
|
+
├── Obsidian (vault on disk)
|
|
112
|
+
├── obsidian-sync-mcp (reads files directly)
|
|
113
|
+
└── tunnel → remote MCP agents
|
|
117
114
|
```
|
|
118
115
|
|
|
119
116
|
---
|
|
120
117
|
|
|
121
|
-
##
|
|
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.
|
|
118
|
+
## Full Fly.io deploy (CouchDB + MCP)
|
|
124
119
|
|
|
125
|
-
|
|
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.
|
|
126
121
|
|
|
127
|
-
[
|
|
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
|
-
```
|
|
122
|
+
Requires [flyctl](https://fly.io/docs/flyctl/install/) and a Fly.io account.
|
|
134
123
|
|
|
135
124
|
### Setup script
|
|
136
125
|
|
|
137
|
-
Generates credentials, creates the volume, and deploys — all in one command:
|
|
138
|
-
|
|
139
126
|
```bash
|
|
140
127
|
git clone https://github.com/es617/obsidian-sync-mcp.git
|
|
141
128
|
cd obsidian-sync-mcp
|
|
142
129
|
./deploy/setup.sh
|
|
143
130
|
```
|
|
144
131
|
|
|
145
|
-
|
|
132
|
+
Generates credentials, creates the volume, and deploys. Save the credentials it prints.
|
|
146
133
|
|
|
147
134
|
### Manual CLI
|
|
148
135
|
|
|
149
136
|
```bash
|
|
150
|
-
cd deploy
|
|
151
137
|
fly launch --no-deploy --copy-config
|
|
152
138
|
fly secrets set \
|
|
153
|
-
COUCHDB_USER=admin \
|
|
154
139
|
COUCHDB_PASSWORD=$(openssl rand -hex 16) \
|
|
155
|
-
COUCHDB_DATABASE=obsidian \
|
|
156
140
|
VAULT_NAME=MyVault \
|
|
157
141
|
MCP_AUTH_TOKEN=$(openssl rand -hex 16)
|
|
142
|
+
fly ips allocate-v4 --shared
|
|
143
|
+
fly ips allocate-v6
|
|
158
144
|
fly volumes create couchdb_data --size 1
|
|
159
145
|
fly deploy
|
|
160
146
|
```
|
|
@@ -163,10 +149,12 @@ fly deploy
|
|
|
163
149
|
|
|
164
150
|
1. In Obsidian, install [Self-hosted LiveSync](https://github.com/vrtmrz/obsidian-livesync) and configure it:
|
|
165
151
|
- Server URL: `https://your-app.fly.dev:5984`
|
|
166
|
-
- Username / password:
|
|
152
|
+
- Username / password: from setup
|
|
167
153
|
- Database: `obsidian`
|
|
168
154
|
2. Your MCP endpoint is `https://your-app.fly.dev/mcp`
|
|
169
|
-
3. The `MCP_AUTH_TOKEN` is the password you
|
|
155
|
+
3. The `MCP_AUTH_TOKEN` is the password you enter when an agent connects
|
|
156
|
+
|
|
157
|
+
If you enable E2E encryption in LiveSync, also set: `fly secrets set COUCHDB_PASSPHRASE=your-passphrase`
|
|
170
158
|
|
|
171
159
|
```
|
|
172
160
|
Fly.io (always on)
|
|
@@ -188,42 +176,25 @@ Comparable to Obsidian Sync ($4/month) and you own the data.
|
|
|
188
176
|
|
|
189
177
|
---
|
|
190
178
|
|
|
191
|
-
##
|
|
179
|
+
## Docker Compose (local dev)
|
|
192
180
|
|
|
193
|
-
|
|
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
|
|
181
|
+
CouchDB and the MCP server run side by side in Docker.
|
|
199
182
|
|
|
200
|
-
|
|
183
|
+
```bash
|
|
184
|
+
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
185
|
+
cd obsidian-sync-mcp
|
|
201
186
|
|
|
202
|
-
|
|
187
|
+
cat > .env <<EOF
|
|
188
|
+
COUCHDB_PASSWORD=changeme
|
|
189
|
+
VAULT_NAME=MyVault
|
|
190
|
+
EOF
|
|
203
191
|
|
|
204
|
-
|
|
192
|
+
docker compose up -d
|
|
193
|
+
```
|
|
205
194
|
|
|
206
|
-
|
|
195
|
+
Then set up LiveSync in Obsidian: server `http://localhost:5984`, database `obsidian`.
|
|
207
196
|
|
|
208
|
-
|
|
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
|
-
| `DATA_DIR` | Optional | `~/.obsidian-mcp` | Directory for persisted data (search index, auth tokens). On Fly.io, automatically set to the persistent volume. |
|
|
224
|
-
| `HOST` | Optional | `0.0.0.0` | Bind address for the HTTP server. Set to `127.0.0.1` to restrict to localhost only. |
|
|
225
|
-
|
|
226
|
-
Set `VAULT_PATH` for local mode or `COUCHDB_URL` for remote mode. If neither is set, the server exits with an error.
|
|
197
|
+
Your MCP server is at `http://localhost:8787/mcp`.
|
|
227
198
|
|
|
228
199
|
---
|
|
229
200
|
|
|
@@ -234,79 +205,72 @@ Set `VAULT_PATH` for local mode or `COUCHDB_URL` for remote mode. If neither is
|
|
|
234
205
|
| `read_note` | Read a note's markdown content by path |
|
|
235
206
|
| `write_note` | Create or overwrite a note (preserves creation time on updates) |
|
|
236
207
|
| `list_notes` | List all `.md` files, optionally filtered by folder |
|
|
237
|
-
| `search_vault` |
|
|
208
|
+
| `search_vault` | Sub-millisecond full-text search across all notes (capped at 50 results) |
|
|
238
209
|
| `delete_note` | Delete a note |
|
|
239
210
|
| `move_note` | Move or rename a note — works across folders, creates destination folders automatically |
|
|
240
211
|
| `get_note_metadata` | Get frontmatter, tags, links, size, and timestamps without reading the full content |
|
|
241
212
|
|
|
242
213
|
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.
|
|
243
214
|
|
|
215
|
+
> "List all my notes in the projects/ folder, then read the one about the MCP server."
|
|
216
|
+
|
|
244
217
|
---
|
|
245
218
|
|
|
246
219
|
## Authentication
|
|
247
220
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
Set `MCP_AUTH_TOKEN` to a password:
|
|
221
|
+
Set `MCP_AUTH_TOKEN` to a password to enable authentication:
|
|
251
222
|
|
|
252
223
|
```bash
|
|
253
|
-
MCP_AUTH_TOKEN=mysecretpassword
|
|
224
|
+
MCP_AUTH_TOKEN=mysecretpassword npx obsidian-sync-mcp
|
|
254
225
|
```
|
|
255
226
|
|
|
256
|
-
|
|
227
|
+
The server includes a self-contained OAuth 2.1 provider. When an agent connects:
|
|
228
|
+
|
|
229
|
+
1. A browser window opens with a password page
|
|
230
|
+
2. Enter the `MCP_AUTH_TOKEN` password
|
|
231
|
+
3. The agent gets an access token and refreshes it transparently
|
|
257
232
|
|
|
258
|
-
|
|
259
|
-
2. A browser window opens showing a password page
|
|
260
|
-
3. The user enters the `MCP_AUTH_TOKEN` password
|
|
261
|
-
4. The agent gets an access token and refreshes it transparently
|
|
233
|
+
The session is shared across all your Claude interfaces (Desktop, Web, Mobile) and persists across server restarts. You'll need to re-enter the password after 14 days of inactivity (configurable via `MCP_REFRESH_DAYS`).
|
|
262
234
|
|
|
263
|
-
|
|
235
|
+
For non-OAuth clients (curl, MCP Inspector, custom agents), you can also pass the token directly as `Authorization: Bearer <MCP_AUTH_TOKEN>`.
|
|
264
236
|
|
|
265
237
|
Without `MCP_AUTH_TOKEN`, the server runs without authentication — suitable for local testing or use behind a private tunnel.
|
|
266
238
|
|
|
267
239
|
---
|
|
268
240
|
|
|
269
|
-
##
|
|
270
|
-
|
|
271
|
-
Test the server interactively using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
272
|
-
|
|
273
|
-
```bash
|
|
274
|
-
# Start the server
|
|
275
|
-
VAULT_PATH=~/Documents/MyVault node dist/main.js
|
|
241
|
+
## Environment variables
|
|
276
242
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
243
|
+
| Variable | Required | Default | Description |
|
|
244
|
+
|---|---|---|---|
|
|
245
|
+
| `VAULT_PATH` | Local mode | — | Path to your Obsidian vault directory |
|
|
246
|
+
| `COUCHDB_URL` | Remote mode | — | CouchDB server URL |
|
|
247
|
+
| `COUCHDB_USER` | Remote mode | `admin` | CouchDB username |
|
|
248
|
+
| `COUCHDB_PASSWORD` | Remote mode | `password` | CouchDB password |
|
|
249
|
+
| `COUCHDB_DATABASE` | Remote mode | `obsidian` | CouchDB database name |
|
|
250
|
+
| `COUCHDB_PASSPHRASE` | Remote mode | — | LiveSync E2E encryption passphrase (must match plugin setting) |
|
|
251
|
+
| `VAULT_NAME` | Both | `MyVault` | Vault name for Obsidian deep links |
|
|
252
|
+
| `MCP_AUTH_TOKEN` | Optional | — | Password for authentication |
|
|
253
|
+
| `BASE_URL` | Optional | `http://localhost:PORT` | Public URL (for OAuth callbacks when using a tunnel) |
|
|
254
|
+
| `PORT` | Optional | `8787` | HTTP port |
|
|
255
|
+
| `HOST` | Optional | `0.0.0.0` | Bind address (`127.0.0.1` to restrict to localhost) |
|
|
256
|
+
| `DATA_DIR` | Optional | `~/.obsidian-mcp` | Directory for persisted data (search index, auth tokens) |
|
|
257
|
+
| `MCP_REFRESH_DAYS` | Optional | `14` | Days before auth session expires |
|
|
280
258
|
|
|
281
|
-
|
|
259
|
+
Set `VAULT_PATH` for local mode or `COUCHDB_URL` for remote mode.
|
|
282
260
|
|
|
283
261
|
---
|
|
284
262
|
|
|
285
|
-
##
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
289
|
-
cd obsidian-sync-mcp
|
|
290
|
-
npm install
|
|
291
|
-
npm run build
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
The `--recursive` flag is important — it pulls the `livesync-commonlib` submodule needed for remote mode.
|
|
295
|
-
|
|
296
|
-
### Build
|
|
297
|
-
|
|
298
|
-
[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.
|
|
263
|
+
## Try without an agent
|
|
299
264
|
|
|
300
|
-
|
|
265
|
+
Test the server interactively using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
301
266
|
|
|
302
267
|
```bash
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
# Build the combined CouchDB + MCP image (for Fly.io)
|
|
307
|
-
docker build -f deploy/Dockerfile.fly -t obsidian-sync-mcp-fly .
|
|
268
|
+
VAULT_PATH=~/Documents/MyVault npx obsidian-sync-mcp &
|
|
269
|
+
npx @modelcontextprotocol/inspector
|
|
308
270
|
```
|
|
309
271
|
|
|
272
|
+
Set transport to **Streamable HTTP**, enter `http://localhost:8787/mcp`, and connect.
|
|
273
|
+
|
|
310
274
|
---
|
|
311
275
|
|
|
312
276
|
## Updating
|
|
@@ -314,46 +278,52 @@ docker build -f deploy/Dockerfile.fly -t obsidian-sync-mcp-fly .
|
|
|
314
278
|
| How you run it | How to update |
|
|
315
279
|
|---|---|
|
|
316
280
|
| `npx obsidian-sync-mcp` | Automatic — npx pulls latest |
|
|
317
|
-
|
|
|
318
|
-
| Fly.io | `fly deploy`
|
|
281
|
+
| Fly.io (MCP only) | `fly deploy --image ghcr.io/es617/obsidian-sync-mcp:latest` |
|
|
282
|
+
| Fly.io (full deploy) | Clone the repo, `fly deploy` from the repo root |
|
|
319
283
|
| Docker Compose | `docker compose pull && docker compose up -d` |
|
|
320
284
|
|
|
321
|
-
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:
|
|
322
|
-
|
|
323
|
-
```bash
|
|
324
|
-
fly deploy --build-arg MCP_IMAGE=ghcr.io/es617/obsidian-sync-mcp:v1.0.0
|
|
325
|
-
```
|
|
326
|
-
|
|
327
285
|
---
|
|
328
286
|
|
|
329
287
|
## Known limitations
|
|
330
288
|
|
|
331
|
-
- **
|
|
332
|
-
- **
|
|
333
|
-
- **
|
|
334
|
-
- **
|
|
289
|
+
- **Single vault per instance.** Each server connects to one vault. For multiple vaults, run multiple instances on different ports.
|
|
290
|
+
- **Search rebuilds on cold start.** The FlexSearch index persists to disk and rebuilds in ~200ms for 2000 notes. External edits are picked up automatically.
|
|
291
|
+
- **No conflict resolution.** If an agent and Obsidian edit the same note simultaneously, last write wins.
|
|
292
|
+
- **Text only.** Binary attachments are not exposed through MCP tools.
|
|
293
|
+
- **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.
|
|
294
|
+
- **Node 22+ required.**
|
|
335
295
|
|
|
336
296
|
---
|
|
337
297
|
|
|
338
298
|
## Safety
|
|
339
299
|
|
|
340
|
-
This server gives an AI agent read/write access to your Obsidian vault.
|
|
300
|
+
This server gives an AI agent read/write access to your Obsidian vault.
|
|
341
301
|
|
|
342
|
-
**Agents can modify and delete notes.**
|
|
302
|
+
**Agents can modify and delete notes.** Keep backups. Use tool approval deliberately.
|
|
343
303
|
|
|
344
|
-
**
|
|
304
|
+
**Authentication is optional.** Always set `MCP_AUTH_TOKEN` when exposing to the internet.
|
|
345
305
|
|
|
346
|
-
**
|
|
306
|
+
**Use HTTPS in production.** Use a tunnel or deploy behind a reverse proxy.
|
|
347
307
|
|
|
348
|
-
|
|
308
|
+
This software is provided as-is under the [MIT license](https://github.com/es617/obsidian-sync-mcp/blob/main/LICENSE). You are responsible for what agents do with your vault.
|
|
309
|
+
|
|
310
|
+
---
|
|
349
311
|
|
|
350
|
-
|
|
312
|
+
## Development
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
git clone --recursive https://github.com/es617/obsidian-sync-mcp.git
|
|
316
|
+
cd obsidian-sync-mcp
|
|
317
|
+
npm install && npm run build
|
|
318
|
+
npm test # 79 unit tests
|
|
319
|
+
npm run test:e2e # integration tests
|
|
320
|
+
```
|
|
351
321
|
|
|
352
322
|
---
|
|
353
323
|
|
|
354
324
|
## License
|
|
355
325
|
|
|
356
|
-
|
|
326
|
+
MIT — see [LICENSE](https://github.com/es617/obsidian-sync-mcp/blob/main/LICENSE).
|
|
357
327
|
|
|
358
328
|
## Acknowledgements
|
|
359
329
|
|
|
@@ -363,4 +333,3 @@ This project is licensed under the MIT License — see [LICENSE](LICENSE) for de
|
|
|
363
333
|
- [FlexSearch](https://github.com/nextapps-de/flexsearch) — full-text search engine
|
|
364
334
|
- [CouchDB](https://couchdb.apache.org/) — document database
|
|
365
335
|
- [Fly.io](https://fly.io/) — deployment platform
|
|
366
|
-
- [tsup](https://github.com/egoist/tsup) — TypeScript bundler
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Node polyfills for livesync-commonlib browser globals
|
|
3
|
+
if(!("navigator" in globalThis)){globalThis.navigator={language:"en"};}
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
+
|
|
18
|
+
// src/parse.ts
|
|
19
|
+
function parseFrontmatterAndLinks(content) {
|
|
20
|
+
const frontmatter = {};
|
|
21
|
+
const tags = /* @__PURE__ */ new Set();
|
|
22
|
+
const links = [];
|
|
23
|
+
if (content.startsWith("---\n")) {
|
|
24
|
+
const end = content.indexOf("\n---", 4);
|
|
25
|
+
if (end !== -1) {
|
|
26
|
+
const yaml = content.slice(4, end);
|
|
27
|
+
let inTagsList = false;
|
|
28
|
+
for (const line of yaml.split("\n")) {
|
|
29
|
+
if (inTagsList) {
|
|
30
|
+
const listItem = line.match(/^\s+-\s+(.+)/);
|
|
31
|
+
if (listItem) {
|
|
32
|
+
const trimmed = listItem[1].trim();
|
|
33
|
+
if (trimmed) tags.add(trimmed);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
inTagsList = false;
|
|
37
|
+
}
|
|
38
|
+
const match = line.match(/^(\w[\w-]*)\s*:\s*(.+)/);
|
|
39
|
+
if (match) {
|
|
40
|
+
frontmatter[match[1]] = match[2].trim();
|
|
41
|
+
}
|
|
42
|
+
if (/^tags\s*:/.test(line)) {
|
|
43
|
+
const value = line.replace(/^tags\s*:\s*/, "").trim();
|
|
44
|
+
if (value) {
|
|
45
|
+
const tagValues = value.replace(/[[\]]/g, "");
|
|
46
|
+
for (const t of tagValues.split(",")) {
|
|
47
|
+
const trimmed = t.trim();
|
|
48
|
+
if (trimmed) tags.add(trimmed);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
inTagsList = true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
for (const match of content.matchAll(/(^|\s)#([\w/-]+)/g)) {
|
|
58
|
+
tags.add(match[2]);
|
|
59
|
+
}
|
|
60
|
+
for (const match of content.matchAll(/\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g)) {
|
|
61
|
+
links.push(match[1]);
|
|
62
|
+
}
|
|
63
|
+
for (const match of content.matchAll(/\[([^\]]+)\]\(([^)]+\.md)\)/g)) {
|
|
64
|
+
links.push(match[2]);
|
|
65
|
+
}
|
|
66
|
+
return { frontmatter, tags: [...tags], links: [...new Set(links)] };
|
|
67
|
+
}
|
|
68
|
+
function extractSnippet(content, query, context = 80) {
|
|
69
|
+
const idx = content.toLowerCase().indexOf(query.toLowerCase());
|
|
70
|
+
if (idx === -1) {
|
|
71
|
+
return content.slice(0, 160) + (content.length > 160 ? "..." : "");
|
|
72
|
+
}
|
|
73
|
+
const start = Math.max(0, idx - context);
|
|
74
|
+
const end = Math.min(content.length, idx + query.length + context);
|
|
75
|
+
return (start > 0 ? "..." : "") + content.slice(start, end) + (end < content.length ? "..." : "");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
__reExport,
|
|
80
|
+
parseFrontmatterAndLinks,
|
|
81
|
+
extractSnippet
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=chunk-TFJDIQK4.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 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":[]}
|