context-vault 2.0.1 → 2.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/README.md +158 -146
- package/bin/cli.js +78 -19
- package/package.json +1 -1
- package/smithery.yaml +1 -1
- package/src/index/embed.js +2 -1
package/README.md
CHANGED
|
@@ -1,128 +1,32 @@
|
|
|
1
1
|
# context-mcp
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/context-vault)
|
|
4
|
+
[](https://www.npmjs.com/package/context-vault)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Persistent memory for AI agents — saves and searches knowledge across sessions.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
<p align="center">
|
|
11
|
+
<img src="assets/demo.gif" alt="context-vault demo — Claude Code and Cursor using the knowledge vault" width="800">
|
|
12
|
+
</p>
|
|
11
13
|
|
|
12
|
-
##
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
YOUR FILES (source of truth) SEARCH INDEX (derived)
|
|
16
|
-
~/vault/ ~/.context-mcp/vault.db
|
|
17
|
-
├── insights/ ┌───────────────────────────────┐
|
|
18
|
-
│ ├── react-query-caching.md │ vault table │
|
|
19
|
-
│ ├── sqlite-fts5-gotchas.md │ kind: insight │
|
|
20
|
-
│ └── react/ │ meta.folder: null (flat) │
|
|
21
|
-
│ └── hooks/ │ meta.folder: "react/hooks" │
|
|
22
|
-
│ └── use-query-gotcha.md │ kind: decision │
|
|
23
|
-
├── decisions/ │ kind: pattern │
|
|
24
|
-
│ └── use-sqlite-over-pg.md │ kind: <any custom> │
|
|
25
|
-
├── patterns/ │ + FTS5 full-text │
|
|
26
|
-
│ └── api-error-handler.md │ + vec0 embeddings │
|
|
27
|
-
└── references/ (custom kind) └───────────────────────────────┘
|
|
28
|
-
└── react-19-notes.md
|
|
29
|
-
Human-editable, git-versioned Fast hybrid search, RAG-ready
|
|
30
|
-
You own these files Rebuilt from files anytime
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
The SQLite database is stored at `~/.context-mcp/vault.db` by default (configurable via `--db-path`, `CONTEXT_MCP_DB_PATH`, or `config.json`). It contains FTS5 full-text indexes and sqlite-vec embeddings (384-dim float32, all-MiniLM-L6-v2). The database is a derived index — delete it and the server rebuilds it automatically on next session.
|
|
34
|
-
|
|
35
|
-
Requires **Node.js 20** or later.
|
|
36
|
-
|
|
37
|
-
## Install
|
|
38
|
-
|
|
39
|
-
### Quick Start
|
|
14
|
+
## Quick Start
|
|
40
15
|
|
|
41
16
|
```bash
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### npm (Recommended)
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm install -g @fellanh/context-mcp
|
|
17
|
+
npm install -g context-vault
|
|
49
18
|
context-mcp setup
|
|
50
19
|
```
|
|
51
20
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
### Local Development
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
git clone https://github.com/fellanH/context-mcp.git
|
|
58
|
-
cd context-mcp
|
|
59
|
-
npm install
|
|
60
|
-
|
|
61
|
-
# Interactive setup — detects your tools and configures them
|
|
62
|
-
node bin/cli.js setup
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
For non-interactive environments (CI, scripts):
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
context-mcp setup --yes
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Manual Configuration
|
|
72
|
-
|
|
73
|
-
If you prefer manual setup, add to your tool's MCP config. Pass `--vault-dir` to point at your vault folder (omit it to use the default `~/vault/`).
|
|
74
|
-
|
|
75
|
-
**npm install** (portable — survives upgrades):
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"mcpServers": {
|
|
80
|
-
"context-mcp": {
|
|
81
|
-
"command": "context-mcp",
|
|
82
|
-
"args": ["serve", "--vault-dir", "/path/to/vault"]
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Local dev clone** (absolute path to source):
|
|
89
|
-
|
|
90
|
-
```json
|
|
91
|
-
{
|
|
92
|
-
"mcpServers": {
|
|
93
|
-
"context-mcp": {
|
|
94
|
-
"command": "node",
|
|
95
|
-
"args": ["/path/to/context-mcp/src/server/index.js", "--vault-dir", "/path/to/vault"]
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
You can also pass config via environment variables in the MCP config block:
|
|
21
|
+
Setup auto-detects your tools (Claude Code, Claude Desktop, Cursor, Windsurf, Cline), downloads the embedding model, seeds your vault with a starter entry, and verifies everything works. Then open your AI tool and try:
|
|
102
22
|
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
"mcpServers": {
|
|
106
|
-
"context-mcp": {
|
|
107
|
-
"command": "context-mcp",
|
|
108
|
-
"args": ["serve"],
|
|
109
|
-
"env": {
|
|
110
|
-
"CONTEXT_MCP_VAULT_DIR": "/path/to/vault"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
```
|
|
23
|
+
> "Search my vault for getting started"
|
|
116
24
|
|
|
117
|
-
|
|
25
|
+
## What It Does
|
|
118
26
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
- **No daemon, no port, no background service.** The server only runs while your AI client is active.
|
|
123
|
-
- **Multiple sessions** can run separate server instances concurrently — SQLite WAL mode handles concurrent access safely.
|
|
124
|
-
- **First launch** downloads the embedding model (~22MB, all-MiniLM-L6-v2) and creates the database. Subsequent starts are fast.
|
|
125
|
-
- **Auto-reindex** on first tool call per session ensures the search index is always in sync with your files on disk. No manual reindex needed.
|
|
27
|
+
- **Save** insights, decisions, patterns, and any custom knowledge kind from AI sessions
|
|
28
|
+
- **Search** with hybrid full-text + semantic similarity, ranked by relevance and recency
|
|
29
|
+
- **Own your data** — plain markdown files in folders you control, git-versioned, human-editable
|
|
126
30
|
|
|
127
31
|
## Tools
|
|
128
32
|
|
|
@@ -159,7 +63,7 @@ save_context({
|
|
|
159
63
|
folder: "react/hooks", // Optional: subfolder organization
|
|
160
64
|
source: "debugging-session" // Optional: provenance
|
|
161
65
|
})
|
|
162
|
-
// → ~/vault/insights/react/hooks/staletime-gotcha.md
|
|
66
|
+
// → ~/vault/knowledge/insights/react/hooks/staletime-gotcha.md
|
|
163
67
|
```
|
|
164
68
|
|
|
165
69
|
The `kind` field accepts any string — `"insight"`, `"decision"`, `"pattern"`, `"reference"`, or any custom kind. The folder is auto-created from the pluralized kind name.
|
|
@@ -175,19 +79,19 @@ Shows vault path, database size, file counts per kind, embedding coverage, and a
|
|
|
175
79
|
Each top-level subdirectory in the vault maps to a `kind` value. The directory name is depluralized:
|
|
176
80
|
|
|
177
81
|
```
|
|
178
|
-
insights/ → kind: "insight"
|
|
179
|
-
decisions/ → kind: "decision"
|
|
180
|
-
patterns/ → kind: "pattern"
|
|
181
|
-
references/ → kind: "reference"
|
|
82
|
+
knowledge/insights/ → kind: "insight"
|
|
83
|
+
knowledge/decisions/ → kind: "decision"
|
|
84
|
+
knowledge/patterns/ → kind: "pattern"
|
|
85
|
+
knowledge/references/ → kind: "reference"
|
|
182
86
|
```
|
|
183
87
|
|
|
184
88
|
Within each kind directory, nested subfolders provide human-browsable organization. The subfolder path is stored in `meta.folder`:
|
|
185
89
|
|
|
186
90
|
```
|
|
187
91
|
ON DISK IN DB (vault table)
|
|
188
|
-
insights/
|
|
92
|
+
knowledge/insights/ kind: "insight", meta.folder: null
|
|
189
93
|
flat-file.md
|
|
190
|
-
insights/react/hooks/
|
|
94
|
+
knowledge/insights/react/hooks/ kind: "insight", meta.folder: "react/hooks"
|
|
191
95
|
use-query-gotcha.md
|
|
192
96
|
```
|
|
193
97
|
|
|
@@ -213,7 +117,7 @@ Standard keys: `id`, `tags`, `source`, `created`. Any extra frontmatter keys (`t
|
|
|
213
117
|
|
|
214
118
|
No code changes required:
|
|
215
119
|
|
|
216
|
-
1. `mkdir ~/vault/references/`
|
|
120
|
+
1. `mkdir ~/vault/knowledge/references/`
|
|
217
121
|
2. Add `.md` files with YAML frontmatter
|
|
218
122
|
3. The next session auto-indexes them
|
|
219
123
|
|
|
@@ -281,62 +185,125 @@ context-mcp <command> [options]
|
|
|
281
185
|
|
|
282
186
|
If running from source without a global install, use `node bin/cli.js` instead of `context-mcp`.
|
|
283
187
|
|
|
284
|
-
##
|
|
188
|
+
## Install
|
|
285
189
|
|
|
286
|
-
|
|
190
|
+
### npm (Recommended)
|
|
287
191
|
|
|
288
192
|
```bash
|
|
289
|
-
|
|
193
|
+
npm install -g context-vault
|
|
194
|
+
context-mcp setup
|
|
290
195
|
```
|
|
291
196
|
|
|
292
|
-
The
|
|
197
|
+
The `setup` command auto-detects installed tools (Claude Code, Claude Desktop, Cursor, Windsurf, Cline), lets you pick which to configure, and writes the correct MCP config for each. Existing configs are preserved — only the `context-mcp` entry is added or updated.
|
|
293
198
|
|
|
294
|
-
|
|
199
|
+
### Local Development
|
|
295
200
|
|
|
296
|
-
|
|
201
|
+
```bash
|
|
202
|
+
git clone https://github.com/fellanH/context-mcp.git
|
|
203
|
+
cd context-mcp
|
|
204
|
+
npm install
|
|
297
205
|
|
|
298
|
-
|
|
206
|
+
# Interactive setup — detects your tools and configures them
|
|
207
|
+
node bin/cli.js setup
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
For non-interactive environments (CI, scripts):
|
|
299
211
|
|
|
300
212
|
```bash
|
|
301
|
-
|
|
213
|
+
context-mcp setup --yes
|
|
302
214
|
```
|
|
303
215
|
|
|
304
|
-
|
|
216
|
+
### Manual Configuration
|
|
305
217
|
|
|
306
|
-
|
|
218
|
+
If you prefer manual setup, add to your tool's MCP config. Pass `--vault-dir` to point at your vault folder (omit it to use the default `~/vault/`).
|
|
307
219
|
|
|
308
|
-
|
|
220
|
+
**npm install** (portable — survives upgrades):
|
|
309
221
|
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"mcpServers": {
|
|
225
|
+
"context-mcp": {
|
|
226
|
+
"command": "context-mcp",
|
|
227
|
+
"args": ["serve", "--vault-dir", "/path/to/vault"]
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
313
231
|
```
|
|
314
232
|
|
|
315
|
-
|
|
233
|
+
**Local dev clone** (absolute path to source):
|
|
316
234
|
|
|
317
|
-
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"mcpServers": {
|
|
238
|
+
"context-mcp": {
|
|
239
|
+
"command": "node",
|
|
240
|
+
"args": ["/path/to/context-mcp/src/server/index.js", "--vault-dir", "/path/to/vault"]
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
318
245
|
|
|
319
|
-
|
|
246
|
+
You can also pass config via environment variables in the MCP config block:
|
|
320
247
|
|
|
321
|
-
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"mcpServers": {
|
|
251
|
+
"context-mcp": {
|
|
252
|
+
"command": "context-mcp",
|
|
253
|
+
"args": ["serve"],
|
|
254
|
+
"env": {
|
|
255
|
+
"CONTEXT_MCP_VAULT_DIR": "/path/to/vault"
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
```
|
|
322
261
|
|
|
323
|
-
|
|
262
|
+
### How the Server Runs
|
|
263
|
+
|
|
264
|
+
The server is an MCP (Model Context Protocol) process — you don't start or stop it manually. Your AI client (Claude Code, Cursor, Cline, etc.) spawns it automatically as a child process when a session begins, based on the `mcpServers` config above. The server communicates over stdio and lives for the duration of the session. When the session ends, the client terminates the process and SQLite cleans up its WAL files.
|
|
265
|
+
|
|
266
|
+
This means:
|
|
267
|
+
- **No daemon, no port, no background service.** The server only runs while your AI client is active.
|
|
268
|
+
- **Multiple sessions** can run separate server instances concurrently — SQLite WAL mode handles concurrent access safely.
|
|
269
|
+
- **Embedding model** is downloaded during `setup` (~22MB, all-MiniLM-L6-v2). If setup was skipped, it downloads on first use.
|
|
270
|
+
- **Auto-reindex** on first tool call per session ensures the search index is always in sync with your files on disk. No manual reindex needed.
|
|
271
|
+
|
|
272
|
+
## Desktop App (macOS)
|
|
273
|
+
|
|
274
|
+
A macOS dock application that starts the UI server and opens the dashboard in your browser.
|
|
324
275
|
|
|
325
276
|
```bash
|
|
326
|
-
|
|
277
|
+
osacompile -o "/Applications/Context.app" ui/Context.applescript
|
|
327
278
|
```
|
|
328
279
|
|
|
329
|
-
|
|
280
|
+
The app checks if port 3141 is already in use, starts the server if not, and opens `http://localhost:3141`. Server logs are written to `/tmp/context-mcp.log`.
|
|
330
281
|
|
|
331
|
-
|
|
282
|
+
## How It Works
|
|
332
283
|
|
|
333
|
-
```
|
|
334
|
-
|
|
284
|
+
```
|
|
285
|
+
YOUR FILES (source of truth) SEARCH INDEX (derived)
|
|
286
|
+
~/vault/ ~/.context-mcp/vault.db
|
|
287
|
+
├── knowledge/ ┌───────────────────────────────┐
|
|
288
|
+
│ ├── insights/ │ vault table │
|
|
289
|
+
│ │ ├── react-query-caching.md │ kind: insight │
|
|
290
|
+
│ │ └── react/hooks/ │ meta.folder: "react/hooks" │
|
|
291
|
+
│ │ └── use-query-gotcha.md │ kind: decision │
|
|
292
|
+
│ ├── decisions/ │ kind: pattern │
|
|
293
|
+
│ │ └── use-sqlite-over-pg.md │ kind: <any custom> │
|
|
294
|
+
│ └── patterns/ │ + FTS5 full-text │
|
|
295
|
+
│ └── api-error-handler.md │ + vec0 embeddings │
|
|
296
|
+
├── entities/ └───────────────────────────────┘
|
|
297
|
+
└── events/
|
|
298
|
+
Human-editable, git-versioned Fast hybrid search, RAG-ready
|
|
299
|
+
You own these files Rebuilt from files anytime
|
|
335
300
|
```
|
|
336
301
|
|
|
337
|
-
|
|
302
|
+
The SQLite database is stored at `~/.context-mcp/vault.db` by default (configurable via `--db-path`, `CONTEXT_MCP_DB_PATH`, or `config.json`). It contains FTS5 full-text indexes and sqlite-vec embeddings (384-dim float32, all-MiniLM-L6-v2). The database is a derived index — delete it and the server rebuilds it automatically on next session.
|
|
338
303
|
|
|
339
|
-
|
|
304
|
+
Requires **Node.js 20** or later.
|
|
305
|
+
|
|
306
|
+
### Architecture
|
|
340
307
|
|
|
341
308
|
```
|
|
342
309
|
src/
|
|
@@ -369,6 +336,51 @@ index/embed.js ← retrieve/ ← ui/serve.js
|
|
|
369
336
|
index/db.js ←────────────────── (all consumers)
|
|
370
337
|
```
|
|
371
338
|
|
|
339
|
+
## Troubleshooting
|
|
340
|
+
|
|
341
|
+
### Native module build failures
|
|
342
|
+
|
|
343
|
+
`better-sqlite3` and `sqlite-vec` include native C code compiled for your platform. If install fails:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
npm rebuild better-sqlite3 sqlite-vec
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
On Apple Silicon Macs, ensure you're running a native ARM Node.js (not Rosetta). Check with `node -p process.arch` — it should say `arm64`.
|
|
350
|
+
|
|
351
|
+
### Vault directory not found
|
|
352
|
+
|
|
353
|
+
If `context_status` or `get_context` reports the vault directory doesn't exist:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
context-mcp status # Shows resolved paths
|
|
357
|
+
mkdir -p ~/vault # Create the default vault directory
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
Or re-run `context-mcp setup` to reconfigure.
|
|
361
|
+
|
|
362
|
+
### Embedding model download
|
|
363
|
+
|
|
364
|
+
The embedding model (all-MiniLM-L6-v2, ~22MB) is normally downloaded during `context-mcp setup`. If setup was skipped or the cache was cleared, it downloads automatically on first use. If it hangs, check your network or proxy settings.
|
|
365
|
+
|
|
366
|
+
### Stale search index
|
|
367
|
+
|
|
368
|
+
If search results seem outdated or missing:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
context-mcp reindex
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
This rebuilds the entire index from your vault files. Auto-reindex runs on every session start, but manual reindex can help diagnose issues.
|
|
375
|
+
|
|
376
|
+
### Config path debugging
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
context-mcp status
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Shows all resolved paths (vault dir, data dir, DB path, config file) and where each was resolved from (defaults, config file, env, or CLI args).
|
|
383
|
+
|
|
372
384
|
## Dependencies
|
|
373
385
|
|
|
374
386
|
| Package | Purpose |
|
package/bin/cli.js
CHANGED
|
@@ -156,7 +156,7 @@ const TOOLS = [
|
|
|
156
156
|
|
|
157
157
|
function showHelp() {
|
|
158
158
|
console.log(`
|
|
159
|
-
${bold("context-mcp")} v${VERSION} —
|
|
159
|
+
${bold("context-mcp")} v${VERSION} — Persistent memory for AI agents
|
|
160
160
|
|
|
161
161
|
${bold("Usage:")}
|
|
162
162
|
context-mcp <command> [options]
|
|
@@ -181,7 +181,9 @@ async function runSetup() {
|
|
|
181
181
|
// Banner
|
|
182
182
|
console.log();
|
|
183
183
|
console.log(bold(" context-mcp") + dim(` v${VERSION}`));
|
|
184
|
-
console.log(dim("
|
|
184
|
+
console.log(dim(" Persistent memory for AI agents — saves and searches knowledge across sessions"));
|
|
185
|
+
console.log();
|
|
186
|
+
console.log(dim(" Setup will: detect tools, configure MCP, download embeddings, and verify."));
|
|
185
187
|
console.log();
|
|
186
188
|
|
|
187
189
|
// Detect tools
|
|
@@ -230,11 +232,13 @@ async function runSetup() {
|
|
|
230
232
|
if (isNonInteractive) {
|
|
231
233
|
selected = detected;
|
|
232
234
|
} else {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
.
|
|
235
|
+
console.log(bold(" Which tools should context-mcp connect to?\n"));
|
|
236
|
+
for (let i = 0; i < detected.length; i++) {
|
|
237
|
+
console.log(` ${i + 1}) ${detected[i].name}`);
|
|
238
|
+
}
|
|
239
|
+
console.log();
|
|
236
240
|
const answer = await prompt(
|
|
237
|
-
`
|
|
241
|
+
` Select (${dim("1,2,3")} or ${dim('"all"')}):`,
|
|
238
242
|
"all"
|
|
239
243
|
);
|
|
240
244
|
if (answer === "all" || answer === "") {
|
|
@@ -294,6 +298,17 @@ async function runSetup() {
|
|
|
294
298
|
writeFileSync(configPath, JSON.stringify(vaultConfig, null, 2) + "\n");
|
|
295
299
|
console.log(`\n ${green("+")} Wrote ${configPath}`);
|
|
296
300
|
|
|
301
|
+
// Pre-download embedding model
|
|
302
|
+
console.log(`\n${bold(" Downloading embedding model...")}`);
|
|
303
|
+
console.log(dim(" all-MiniLM-L6-v2 (~22MB, one-time download)\n"));
|
|
304
|
+
try {
|
|
305
|
+
const { embed } = await import("../src/index/embed.js");
|
|
306
|
+
await embed("warmup");
|
|
307
|
+
console.log(` ${green("+")} Embedding model ready`);
|
|
308
|
+
} catch (e) {
|
|
309
|
+
console.log(` ${yellow("!")} Model download failed — will retry on first use`);
|
|
310
|
+
}
|
|
311
|
+
|
|
297
312
|
// Clean up legacy project-root config.json if it exists
|
|
298
313
|
const legacyConfigPath = join(ROOT, "config.json");
|
|
299
314
|
if (existsSync(legacyConfigPath)) {
|
|
@@ -324,6 +339,12 @@ async function runSetup() {
|
|
|
324
339
|
}
|
|
325
340
|
}
|
|
326
341
|
|
|
342
|
+
// Seed entry
|
|
343
|
+
const seeded = createSeedEntry(resolvedVaultDir);
|
|
344
|
+
if (seeded) {
|
|
345
|
+
console.log(`\n ${green("+")} Created starter entry in vault`);
|
|
346
|
+
}
|
|
347
|
+
|
|
327
348
|
// Offer to launch UI
|
|
328
349
|
console.log();
|
|
329
350
|
if (!isNonInteractive) {
|
|
@@ -338,21 +359,27 @@ async function runSetup() {
|
|
|
338
359
|
}
|
|
339
360
|
}
|
|
340
361
|
|
|
341
|
-
//
|
|
342
|
-
console.log(bold("\n Setup complete!\n"));
|
|
362
|
+
// Health check
|
|
343
363
|
const ok = results.filter((r) => r.ok);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
364
|
+
const checks = [
|
|
365
|
+
{ label: "Vault directory exists", pass: existsSync(resolvedVaultDir) },
|
|
366
|
+
{ label: "Config file written", pass: existsSync(configPath) },
|
|
367
|
+
{ label: "At least one tool configured", pass: ok.length > 0 },
|
|
368
|
+
];
|
|
369
|
+
const passed = checks.filter((c) => c.pass).length;
|
|
370
|
+
console.log(bold(`\n Health check: ${passed}/${checks.length} passed\n`));
|
|
371
|
+
for (const c of checks) {
|
|
372
|
+
console.log(` ${c.pass ? green("+") : red("x")} ${c.label}`);
|
|
351
373
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
console.log(
|
|
374
|
+
|
|
375
|
+
// First-use guidance
|
|
376
|
+
const toolName = ok.length ? ok[0].tool.name : "your AI tool";
|
|
377
|
+
console.log(bold("\n What to do next:\n"));
|
|
378
|
+
console.log(` 1. Open ${toolName}`);
|
|
379
|
+
console.log(` 2. Try: ${cyan('"Search my vault for getting started"')}`);
|
|
380
|
+
console.log(` 3. Try: ${cyan('"Save an insight: JavaScript Date objects are mutable"')}`);
|
|
381
|
+
console.log(`\n Vault: ${resolvedVaultDir}`);
|
|
382
|
+
console.log(` Dashboard: ${cyan("context-mcp ui")}`);
|
|
356
383
|
console.log();
|
|
357
384
|
}
|
|
358
385
|
|
|
@@ -431,6 +458,38 @@ function configureJsonTool(tool, vaultDir) {
|
|
|
431
458
|
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
432
459
|
}
|
|
433
460
|
|
|
461
|
+
// ─── Seed Entry ─────────────────────────────────────────────────────────────
|
|
462
|
+
|
|
463
|
+
function createSeedEntry(vaultDir) {
|
|
464
|
+
const seedDir = join(vaultDir, "knowledge", "insights");
|
|
465
|
+
const seedPath = join(seedDir, "getting-started.md");
|
|
466
|
+
if (existsSync(seedPath)) return false;
|
|
467
|
+
mkdirSync(seedDir, { recursive: true });
|
|
468
|
+
const id = Date.now().toString(36).toUpperCase().padStart(10, "0");
|
|
469
|
+
const now = new Date().toISOString();
|
|
470
|
+
const content = `---
|
|
471
|
+
id: ${id}
|
|
472
|
+
tags: ["getting-started"]
|
|
473
|
+
source: context-mcp-setup
|
|
474
|
+
created: ${now}
|
|
475
|
+
---
|
|
476
|
+
Welcome to your context vault! This is a seed entry created during setup.
|
|
477
|
+
|
|
478
|
+
Your vault stores knowledge as plain markdown files with YAML frontmatter.
|
|
479
|
+
AI agents search it using hybrid full-text + semantic search.
|
|
480
|
+
|
|
481
|
+
Try these commands in your AI tool:
|
|
482
|
+
- "Search my vault for getting started"
|
|
483
|
+
- "Save an insight: JavaScript Date objects are mutable"
|
|
484
|
+
- "Show my vault status"
|
|
485
|
+
|
|
486
|
+
You can edit or delete this file anytime — it lives at:
|
|
487
|
+
${seedPath}
|
|
488
|
+
`;
|
|
489
|
+
writeFileSync(seedPath, content);
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
|
|
434
493
|
// ─── UI Command ──────────────────────────────────────────────────────────────
|
|
435
494
|
|
|
436
495
|
function runUi() {
|
package/package.json
CHANGED
package/smithery.yaml
CHANGED
|
@@ -7,4 +7,4 @@ startCommand:
|
|
|
7
7
|
type: string
|
|
8
8
|
description: "Path to the vault directory containing your knowledge files. Defaults to ~/vault/"
|
|
9
9
|
commandFunction: |-
|
|
10
|
-
(config) => ({ command: 'npx', args: ['-y', '
|
|
10
|
+
(config) => ({ command: 'npx', args: ['-y', 'context-vault', 'serve', ...(config.vaultDir ? ['--vault-dir', config.vaultDir] : [])] })
|
package/src/index/embed.js
CHANGED
|
@@ -9,10 +9,11 @@ let extractor = null;
|
|
|
9
9
|
async function ensurePipeline() {
|
|
10
10
|
if (!extractor) {
|
|
11
11
|
try {
|
|
12
|
+
console.error("[context-mcp] Loading embedding model (first run may download ~22MB)...");
|
|
12
13
|
extractor = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2");
|
|
13
14
|
} catch (e) {
|
|
14
15
|
console.error(`[context-mcp] Failed to load embedding model: ${e.message}`);
|
|
15
|
-
console.error(`[context-mcp] The model (~
|
|
16
|
+
console.error(`[context-mcp] The model (~22MB) is downloaded on first run.`);
|
|
16
17
|
console.error(`[context-mcp] Check: network connectivity, disk space, Node.js >=20`);
|
|
17
18
|
throw e;
|
|
18
19
|
}
|