kontexta-mcp 2.0.4 → 2.0.5
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 +180 -2
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/kontexta-mcp)
|
|
4
4
|
[](LICENSE)
|
|
5
5
|
|
|
6
|
-
MCP server for [Kontexta](https://
|
|
6
|
+
MCP server for [Kontexta](https://kontexta.dev) — **53 tools** that let AI coding agents search, read, edit (section-level), tag, version, clip web content, and run sandboxed commands through a local SQLite-backed knowledge base. Designed for context-window economy: every file-returning response is annotated with `est_tokens` and `size_bytes`.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -25,15 +25,28 @@ The server is launched on demand by your AI client; no global install needed.
|
|
|
25
25
|
|
|
26
26
|
`KONTEXTA_DATA_DIR` **must** be an absolute path. The directory is created on first run and holds your SQLite DB plus the markdown files the agent indexes.
|
|
27
27
|
|
|
28
|
+
### Bin aliases
|
|
29
|
+
|
|
30
|
+
The package exposes two CLI entry points:
|
|
31
|
+
|
|
32
|
+
| Command | Description |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `kontexta-mcp` | Standard MCP server entry |
|
|
35
|
+
| `kxta` | Shorthand alias (same binary) |
|
|
36
|
+
|
|
37
|
+
Both invoke the same `dist/index.js` — use whichever your client's config format prefers.
|
|
38
|
+
|
|
28
39
|
## Client config locations
|
|
29
40
|
|
|
30
41
|
| Client | Path |
|
|
31
42
|
|---|---|
|
|
43
|
+
| Claude Code | `claude mcp add kontexta -s user -e KONTEXTA_DATA_DIR=/path -- node /path/to/apps/mcp/dist/index.js` |
|
|
32
44
|
| Claude Desktop (macOS) | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
33
45
|
| Claude Desktop (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
34
46
|
| Cursor | Settings → Features → MCP |
|
|
35
47
|
| Continue | `~/.continue/config.json` |
|
|
36
48
|
| Codex | `.codex/mcp_servers.json` |
|
|
49
|
+
| GitHub Copilot | File-based (`.github/copilot-instructions.md`) — no MCP config needed |
|
|
37
50
|
| Gemini / Antigravity | `~/.gemini/antigravity/mcp_servers.json` |
|
|
38
51
|
|
|
39
52
|
## Web UI (optional)
|
|
@@ -46,6 +59,171 @@ docker run -d -p 3000:3000 -v /absolute/path/to/your/data:/app/data safiyu/konte
|
|
|
46
59
|
|
|
47
60
|
Open `http://localhost:3000`.
|
|
48
61
|
|
|
62
|
+
## Tool categories
|
|
63
|
+
|
|
64
|
+
The 53 tools are organized into these groups:
|
|
65
|
+
|
|
66
|
+
### Find
|
|
67
|
+
|
|
68
|
+
| Tool | Purpose |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `search` | Natural-language keyword search across the knowledge base (FTS5) |
|
|
71
|
+
| `regex_search` | Substring/regex search across all indexed files |
|
|
72
|
+
| `grep_in_file` | Substring/regex search within a single known file |
|
|
73
|
+
| `bundle_search` | Search hits + file bodies in a single token-budgeted call |
|
|
74
|
+
| `find_related` | Discover sibling files via tag overlap |
|
|
75
|
+
| `suggest_tags` | Propose tags for an existing file |
|
|
76
|
+
|
|
77
|
+
### Read
|
|
78
|
+
|
|
79
|
+
| Tool | Purpose |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `read_file` | Read one file's full body and metadata by ID |
|
|
82
|
+
| `read_files` | Batch read up to 200 files by ID in one call |
|
|
83
|
+
| `read_file_by_path` | Read a file by absolute path (no ID needed) |
|
|
84
|
+
| `read_file_lines` | Read a specific line range from a file |
|
|
85
|
+
| `read_section` | Read a section by heading within a file |
|
|
86
|
+
| `read_file_outline` | Get a compact outline of a file's structure |
|
|
87
|
+
| `describe_file` | Metadata-only inspection (tags, size, history, related) — no body tokens |
|
|
88
|
+
|
|
89
|
+
### Write
|
|
90
|
+
|
|
91
|
+
| Tool | Purpose |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `create_file` | Create a new markdown or mermaid file in the KB or project |
|
|
94
|
+
| `create_files` | Create multiple new files in one call |
|
|
95
|
+
| `update_file` | Replace the entire body of a file |
|
|
96
|
+
| `update_file_section` | Surgical edit at a known heading |
|
|
97
|
+
| `delete_file` | Delete a single file |
|
|
98
|
+
| `delete_files` | Delete multiple files in one call |
|
|
99
|
+
| `move_file` | Rename or relocate a file |
|
|
100
|
+
|
|
101
|
+
### Organize
|
|
102
|
+
|
|
103
|
+
| Tool | Purpose |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `add_tags` | Add tags to an existing file |
|
|
106
|
+
| `remove_tags` | Remove tags from a file |
|
|
107
|
+
| `list_tags` | Enumerate all tags in the vault |
|
|
108
|
+
| `set_favorite` | Pin / unpin a file |
|
|
109
|
+
| `tag_search_results` | Bulk-tag every hit from a search |
|
|
110
|
+
| `list_folders` | Enumerate folders in a project |
|
|
111
|
+
| `create_folder` | Create a new (possibly nested) folder |
|
|
112
|
+
| `delete_folder` | Remove an empty folder |
|
|
113
|
+
| `list_files` | List files in a project (filterable) |
|
|
114
|
+
|
|
115
|
+
### History & Recovery
|
|
116
|
+
|
|
117
|
+
| Tool | Purpose |
|
|
118
|
+
|---|---|
|
|
119
|
+
| `get_history` | List a file's revisions |
|
|
120
|
+
| `get_diff` | Compare two specific revisions |
|
|
121
|
+
| `restore_file` | Roll back a KB file to an earlier revision |
|
|
122
|
+
| `diff_against_disk` | Detect drift after out-of-band filesystem edits |
|
|
123
|
+
| `refresh_index` | Rescan the vault after external changes |
|
|
124
|
+
|
|
125
|
+
### Discover
|
|
126
|
+
|
|
127
|
+
| Tool | Purpose |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `list_projects` | Enumerate registered projects |
|
|
130
|
+
| `register_project` | Register a new project root with kontexta |
|
|
131
|
+
| `project_map` | Compact folder/file tree with titles and tags |
|
|
132
|
+
| `stats` | Counts and health metrics for a project |
|
|
133
|
+
| `whats_new` | Files added/changed since a cutoff timestamp |
|
|
134
|
+
|
|
135
|
+
### Journaling
|
|
136
|
+
|
|
137
|
+
| Tool | Purpose |
|
|
138
|
+
|---|---|
|
|
139
|
+
| `journal_note` | Record a free-form decision/abandonment/observation note |
|
|
140
|
+
| `journal_intent` | Record a topic/intent pivot |
|
|
141
|
+
| `journal_status` | Report journal backlog and high-water mark |
|
|
142
|
+
| `distill_journal` | Run the distillation pipeline (raw events → markdown summaries) |
|
|
143
|
+
| `distill_journal_commit_upgrades` | Mark mechanical entries as upgraded after subagent dispatch |
|
|
144
|
+
| `housekeep_journal` | Run journal retention/archival (prune old raw files, archive cold tasks) |
|
|
145
|
+
|
|
146
|
+
### Hands (sandboxed commands)
|
|
147
|
+
|
|
148
|
+
| Tool | Purpose |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `list_hands` | List every Hands command tool currently registered |
|
|
151
|
+
| `reload_hands` | Re-scan projects and rebuild the Hands tool registry |
|
|
152
|
+
| `confirm_hand` | Approve a pending Hands invocation by its approval token |
|
|
153
|
+
| `describe_hands_schema` | Return the complete `kontexta.json` authoring reference |
|
|
154
|
+
|
|
155
|
+
### Onboarding
|
|
156
|
+
|
|
157
|
+
| Tool | Purpose |
|
|
158
|
+
|---|---|
|
|
159
|
+
| `onboard_agent` | Write/update kontexta workflow rules in agent context files |
|
|
160
|
+
| `clip_url` | Clip a web URL into the knowledge base |
|
|
161
|
+
| `commit_backup` | Push KB changes to the project's remote git |
|
|
162
|
+
|
|
163
|
+
## MCP Resources
|
|
164
|
+
|
|
165
|
+
The server also exposes two MCP resources for URI-based access:
|
|
166
|
+
|
|
167
|
+
| URI | Description |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `kontexta://projects` | JSON list of all registered projects with agent-rules status |
|
|
170
|
+
| `kontexta://files/{id}` | Markdown content of a specific file by ID |
|
|
171
|
+
|
|
172
|
+
## Journaling modes
|
|
173
|
+
|
|
174
|
+
Kontexta's journaling subsystem has three modes, configurable per project in `kontexta.json`:
|
|
175
|
+
|
|
176
|
+
| Mode | Behavior |
|
|
177
|
+
|---|---|
|
|
178
|
+
| `lenient` (default) | Never blocks; injects a `journal` envelope on tool responses when backlog exists; auto-distills at 500 events or 7 days |
|
|
179
|
+
| `strict` | Blocks read tools (`search`, `read_*`, `list_*`, `describe_*`) with a `JOURNAL_BACKLOG` error when undistilled events exist. Override with `journal_bypass: true` |
|
|
180
|
+
| `mechanical-only` | Disables LLM-upgrade tier guidance; mechanical distillation runs every N tool calls in-process |
|
|
181
|
+
|
|
182
|
+
## Hands — sandboxed command orchestration
|
|
183
|
+
|
|
184
|
+
Hands lets you declare project-specific commands in `kontexta.json` that agents can run safely:
|
|
185
|
+
|
|
186
|
+
- **Strict sandbox**: realpath-verified CWD, stripped `PATH`, clean environment, ring-buffer output cap, hard timeouts, process-group kill on timeout, no shell.
|
|
187
|
+
- **Cryptographic confirm tokens** (CSPRNG, single-use, 60s expiry) for high-risk commands.
|
|
188
|
+
- **ReDoS-proof parameter validation** via `re2`; default `^[^-].*` mitigates argv injection.
|
|
189
|
+
- **Human-in-the-loop**: Optional approval flow per command.
|
|
190
|
+
|
|
191
|
+
## Token-aware responses
|
|
192
|
+
|
|
193
|
+
Every file-returning tool annotates its response with:
|
|
194
|
+
|
|
195
|
+
- `size_bytes` — exact byte size of the content
|
|
196
|
+
- `est_tokens` — estimated token count (≈1 token per 4 ASCII chars)
|
|
197
|
+
|
|
198
|
+
This lets agents budget their context window before deciding to fetch more files. A token budget warning is emitted when a project's content exceeds the soft cap (default 100,000 tokens).
|
|
199
|
+
|
|
200
|
+
## Agent rules
|
|
201
|
+
|
|
202
|
+
Kontexta injects a version-stamped workflow rules block into agent context files (`CLAUDE.md`, `AGENTS.md`, `.cursor/rules/*.mdc`, `.github/copilot-instructions.md`, etc.) via `onboard_agent`. The server checks for outdated rules on every tool call and surfaces a warning when a newer `rulesVersion` is available.
|
|
203
|
+
|
|
204
|
+
Supported agents: Claude Code, Cursor, Cline, GitHub Copilot, Gemini, Antigravity, Continue, Cline.
|
|
205
|
+
|
|
206
|
+
## Graceful shutdown
|
|
207
|
+
|
|
208
|
+
The MCP server drains in-flight work on `SIGINT`/`SIGTERM`:
|
|
209
|
+
|
|
210
|
+
1. Kills detached Hands children
|
|
211
|
+
2. Flushes the journal capture
|
|
212
|
+
3. Awaits in-flight database operations (up to 10s hard ceiling)
|
|
213
|
+
4. Closes the database cleanly
|
|
214
|
+
|
|
215
|
+
## Environment variables
|
|
216
|
+
|
|
217
|
+
| Variable | Default | Description |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| `KONTEXTA_DATA_DIR` | `~/.local/share/kontexta` (Linux) | Vault directory (SQLite DB + markdown files) |
|
|
220
|
+
| `KONTEXTA_DB_PATH` | `$KONTEXTA_DATA_DIR/kontexta.db` | Override the database file path |
|
|
221
|
+
| `KONTEXTA_DEFAULT_PROJECT_SLUG` | `"default"` | Default project for journal capture |
|
|
222
|
+
| `KONTEXTA_AGENT` | `"unknown"` | Agent identifier for journal events |
|
|
223
|
+
| `KONTEXTA_PROJECT_PATH` | `process.cwd()` | Project path for git polling |
|
|
224
|
+
| `KONTEXTA_PROJECT_TOKEN_WARN` | `100000` | Token budget soft cap warning threshold |
|
|
225
|
+
| `KONTEXTA_PROJECTS` | — | Colon-separated list of project directories to auto-register |
|
|
226
|
+
|
|
49
227
|
## Requirements
|
|
50
228
|
|
|
51
229
|
- Node ≥ 20 (the package is published as ESM, target node20).
|
|
@@ -53,7 +231,7 @@ Open `http://localhost:3000`.
|
|
|
53
231
|
|
|
54
232
|
## Documentation
|
|
55
233
|
|
|
56
|
-
Full docs, the
|
|
234
|
+
Full docs, the complete tool reference with routing matrices, and the web UI live in the [main repository](https://github.com/safiyu/kontexta). See [`CHANGELOG.md`](https://github.com/safiyu/kontexta/blob/main/CHANGELOG.md) for what's new and [`docs/MCP.md`](https://github.com/safiyu/kontexta/blob/main/docs/MCP.md) for the detailed MCP integration guide.
|
|
57
235
|
|
|
58
236
|
## License
|
|
59
237
|
|
package/dist/index.js
CHANGED
|
@@ -277,9 +277,13 @@ import { join as join2, dirname } from "path";
|
|
|
277
277
|
import { fileURLToPath } from "url";
|
|
278
278
|
function resolveMigrationsDir() {
|
|
279
279
|
const candidates = [
|
|
280
|
+
// Docker: WORKDIR=/app, migrations explicitly copied to /app/packages/core/src/db/migrations
|
|
281
|
+
join2(process.cwd(), "packages", "core", "src", "db", "migrations"),
|
|
282
|
+
// tsc build: dist/db/migrations (sibling of this file's dist location)
|
|
280
283
|
join2(__dirname2, "migrations"),
|
|
284
|
+
// Next.js standalone: __dirname resolves relative to the traced module
|
|
281
285
|
join2(__dirname2, "..", "..", "src", "db", "migrations"),
|
|
282
|
-
|
|
286
|
+
// Fallback: dist copy
|
|
283
287
|
join2(process.cwd(), "packages", "core", "dist", "db", "migrations"),
|
|
284
288
|
join2(process.cwd(), "..", "..", "packages", "core", "src", "db", "migrations"),
|
|
285
289
|
join2(process.cwd(), "..", "..", "packages", "core", "dist", "db", "migrations")
|