context-mode 0.5.11 → 0.5.13
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +3 -3
- package/.mcp.json +2 -2
- package/README.md +92 -327
- package/build/server.js +1 -1
- package/build/store.js +1 -1
- package/package.json +1 -1
- package/skills/context-mode/SKILL.md +9 -0
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"name": "context-mode",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 10 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
16
|
-
"version": "0.5.
|
|
16
|
+
"version": "0.5.13",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "Mert Koseoğlu"
|
|
19
19
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 10 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mert Koseoğlu",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"mcpServers": {
|
|
23
23
|
"context-mode": {
|
|
24
|
-
"command": "
|
|
25
|
-
"args": ["
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": ["-y", "context-mode"]
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"skills": "./skills/"
|
package/.mcp.json
CHANGED
package/README.md
CHANGED
|
@@ -1,410 +1,175 @@
|
|
|
1
1
|
# Context Mode
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Stop losing context to large outputs.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/context-mode) [](LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Run tests without burning 5K tokens. Query docs without loading raw HTML. Debug logs without reading 45KB of noise. Only summaries reach Claude — everything else stays in the sandbox.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| **Context7** | `query-docs` | 4K-10K tokens | ~65 tokens | **98%** | [upstash/context7](https://github.com/upstash/context7) |
|
|
17
|
-
| **GitHub** | `list_commits` (30) | 29K-64K tokens | ~180 tokens | **99%** | [github-mcp-server#142](https://github.com/github/github-mcp-server/issues/142) |
|
|
18
|
-
| **Sentry** | issue analysis | 5K-30K tokens | ~85 tokens | **99%** | [getsentry/sentry-mcp](https://github.com/getsentry/sentry-mcp) |
|
|
19
|
-
| **Supabase** | schema queries | 2K-30K tokens | ~80 tokens | **99%** | [supabase-community/supabase-mcp](https://github.com/supabase-community/supabase-mcp) |
|
|
20
|
-
| **Firecrawl** | `scrape` / `crawl` | 5K-50K+ tokens | ~65 tokens | **99%** | [firecrawl](https://github.com/mendableai/firecrawl) |
|
|
21
|
-
| **Chrome DevTools** | DOM / network | 5K-50K+ tokens | ~75 tokens | **99%** | Community benchmark |
|
|
22
|
-
| **Fetch** | `fetch` | 5K-50K tokens | ~65 tokens | **99%** | Official reference server |
|
|
23
|
-
|
|
24
|
-
**Real measurement** ([Scott Spence, 2025](https://scottspence.com/posts/optimising-mcp-server-context-usage-in-claude-code)): With 81+ MCP tools enabled across multiple servers, **143K of 200K tokens (72%) consumed** — 82K tokens just for MCP tool definitions. Only 28% left for actual work.
|
|
25
|
-
|
|
26
|
-
**Vercel's finding** ([December 2025](https://www.anthropic.com/engineering/advanced-tool-use)): Removing 80% of tools resulted in 3.5x faster execution, 37% fewer tokens, and 100% success rate (up from 80%).
|
|
9
|
+
```
|
|
10
|
+
Without Context Mode With Context Mode
|
|
11
|
+
───────────────────── ────────────────────
|
|
12
|
+
Playwright snapshot → 56 KB into context → 299 B summary
|
|
13
|
+
GitHub issues (20) → 59 KB into context → 1.1 KB summary
|
|
14
|
+
Access log (500) → 45 KB into context → 155 B summary
|
|
15
|
+
Context7 docs → 6 KB into context → 261 B summary
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
Total: 166 KB = 42K tokens gone Total: 1.8 KB = ~450 tokens
|
|
18
|
+
```
|
|
29
19
|
|
|
30
|
-
|
|
31
|
-
|---|---|---|---|
|
|
32
|
-
| Playwright `browser_snapshot` | 56 KB into context | 299 B summary | **99%** |
|
|
33
|
-
| Context7 `query-docs` (React) | 5.9 KB raw docs | 261 B summary | **96%** |
|
|
34
|
-
| GitHub issues (20) | 59 KB JSON response | 1.1 KB summary | **98%** |
|
|
35
|
-
| Read `access.log` (500 req) | 45 KB raw log | 155 B status breakdown | **100%** |
|
|
36
|
-
| `vitest` (30 suites) | 6 KB raw output | 337 B pass/fail | **95%** |
|
|
37
|
-
| Git log (153 commits) | 12 KB raw log | 107 B summary | **99%** |
|
|
38
|
-
| Analytics CSV (500 rows) | 86 KB raw data | 222 B summary | **100%** |
|
|
20
|
+
## Install
|
|
39
21
|
|
|
40
|
-
|
|
22
|
+
```bash
|
|
23
|
+
claude mcp add context-mode -- npx -y context-mode
|
|
24
|
+
```
|
|
41
25
|
|
|
42
|
-
|
|
26
|
+
Restart Claude Code. Done. You now have 5 tools that intercept large outputs and return only what matters.
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
<details>
|
|
29
|
+
<summary><strong>Plugin install</strong> (includes auto-routing skill)</summary>
|
|
45
30
|
|
|
46
31
|
```bash
|
|
47
32
|
/plugin marketplace add mksglu/claude-context-mode
|
|
48
33
|
/plugin install context-mode@claude-context-mode
|
|
49
34
|
```
|
|
50
35
|
|
|
51
|
-
Installs
|
|
52
|
-
|
|
53
|
-
### Option 2: MCP Server Only
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
claude mcp add context-mode -- npx -y context-mode
|
|
57
|
-
```
|
|
36
|
+
Installs the MCP server + a skill that automatically guides Claude to route large outputs through Context Mode. No prompting needed.
|
|
58
37
|
|
|
59
|
-
|
|
38
|
+
</details>
|
|
60
39
|
|
|
61
|
-
|
|
40
|
+
<details>
|
|
41
|
+
<summary><strong>Local development</strong></summary>
|
|
62
42
|
|
|
63
43
|
```bash
|
|
64
44
|
claude --plugin-dir ./path/to/context-mode
|
|
65
45
|
```
|
|
66
46
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
### `execute` — Run Code in Sandbox
|
|
70
|
-
|
|
71
|
-
Execute code in 10 languages: JavaScript, TypeScript, Python, Shell, Ruby, Go, Rust, PHP, Perl, R. Only stdout enters context — raw data stays in the subprocess.
|
|
47
|
+
</details>
|
|
72
48
|
|
|
73
|
-
|
|
74
|
-
Claude calls: execute({ language: "shell", code: "gh pr list --json title,state | jq length" })
|
|
75
|
-
Returns: "3" ← 2 bytes instead of 8KB JSON
|
|
76
|
-
```
|
|
49
|
+
## What It Does
|
|
77
50
|
|
|
78
|
-
|
|
51
|
+
Every MCP tool call dumps raw data into your 200K context window. With [81+ tools active, 143K tokens (72%) get consumed before your first message](https://scottspence.com/posts/optimising-mcp-server-context-usage-in-claude-code). Context Mode intercepts these operations, processes data in isolated subprocesses, and returns only what you need.
|
|
79
52
|
|
|
80
|
-
|
|
81
|
-
Claude calls: execute({
|
|
82
|
-
language: "shell",
|
|
83
|
-
code: "cat /var/log/app.log",
|
|
84
|
-
intent: "connection refused database error"
|
|
85
|
-
})
|
|
86
|
-
Returns: section titles + searchable terms (500B) ← instead of 100KB raw log
|
|
87
|
-
```
|
|
53
|
+
**Result:** 315 KB raw data becomes 5.4 KB of context across 14 real scenarios — **98% savings**.
|
|
88
54
|
|
|
89
|
-
|
|
90
|
-
|
|
55
|
+
| Metric | Without | With |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| Context consumed per session | 315 KB | 5.4 KB |
|
|
58
|
+
| Time before slowdown | ~30 min | ~3 hours |
|
|
59
|
+
| Context remaining after 45 min | 60% | 99% |
|
|
91
60
|
|
|
92
|
-
|
|
61
|
+
## Tools
|
|
93
62
|
|
|
94
|
-
### `
|
|
63
|
+
### `execute` — Run code in sandbox
|
|
95
64
|
|
|
96
|
-
|
|
65
|
+
Execute code in 10 languages (JS, TS, Python, Shell, Ruby, Go, Rust, PHP, Perl, R). Only stdout enters context.
|
|
97
66
|
|
|
98
67
|
```
|
|
99
|
-
|
|
100
|
-
|
|
68
|
+
execute({ language: "shell", code: "gh pr list --json title,state | jq length" })
|
|
69
|
+
→ "3" ← 2 bytes instead of 8KB
|
|
101
70
|
```
|
|
102
71
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Chunks markdown by headings, keeps code blocks intact, stores in ephemeral FTS5 database with BM25 ranking.
|
|
72
|
+
Add `intent` for large outputs — Context Mode filters to relevant sections automatically:
|
|
106
73
|
|
|
107
74
|
```
|
|
108
|
-
|
|
109
|
-
|
|
75
|
+
execute({ language: "shell", code: "cat app.log", intent: "database connection error" })
|
|
76
|
+
→ matching sections + searchable terms ← 500B instead of 100KB
|
|
110
77
|
```
|
|
111
78
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
BM25 full-text search with Porter stemming. Returns exact code blocks — not summaries.
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
Claude calls: search({ query: "useEffect cleanup function" })
|
|
118
|
-
Returns: exact code example with heading context ← 500 bytes instead of 60KB
|
|
119
|
-
```
|
|
79
|
+
Authenticated CLIs work out of the box — `gh`, `aws`, `gcloud`, `kubectl`, `docker` credentials pass through. Bun auto-detected for 3-5x faster JS/TS.
|
|
120
80
|
|
|
121
|
-
### `
|
|
81
|
+
### `execute_file` — Process files without loading
|
|
122
82
|
|
|
123
|
-
|
|
83
|
+
File contents stay in the sandbox as `FILE_CONTENT`. Your code summarizes. Only the summary enters context.
|
|
124
84
|
|
|
125
85
|
```
|
|
126
|
-
|
|
127
|
-
|
|
86
|
+
execute_file({ path: "access.log", language: "python", code: "..." })
|
|
87
|
+
→ "200: 312 | 404: 89 | 500: 14" ← 30 bytes instead of 45KB
|
|
128
88
|
```
|
|
129
89
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
## How It Works
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
┌──────────────────────────────────────────────────────────────────┐
|
|
136
|
-
│ Without Context Mode │
|
|
137
|
-
│ │
|
|
138
|
-
│ Claude Code → Playwright snapshot → 56KB into context │
|
|
139
|
-
│ Claude Code → Context7 docs → 6KB into context │
|
|
140
|
-
│ Claude Code → gh pr list → 6KB into context │
|
|
141
|
-
│ Claude Code → cat access.log → 45KB into context │
|
|
142
|
-
│ │
|
|
143
|
-
│ Total: 113KB consumed = ~29,000 tokens = 14% of context gone │
|
|
144
|
-
└──────────────────────────────────────────────────────────────────┘
|
|
145
|
-
|
|
146
|
-
┌──────────────────────────────────────────────────────────────────┐
|
|
147
|
-
│ With Context Mode │
|
|
148
|
-
│ │
|
|
149
|
-
│ Claude Code → fetch_and_index(url) → "Indexed 8 sections" (50B)│
|
|
150
|
-
│ Claude Code → search("snapshot") → exact element (500B) │
|
|
151
|
-
│ Claude Code → execute("gh pr list") → "5 PRs, +59 -0" (719B)│
|
|
152
|
-
│ Claude Code → execute_file(log) → "500:13, 404:13" (155B)│
|
|
153
|
-
│ │
|
|
154
|
-
│ Total: 1.4KB consumed = ~350 tokens = 0.18% of context │
|
|
155
|
-
└──────────────────────────────────────────────────────────────────┘
|
|
156
|
-
```
|
|
90
|
+
### `index` + `search` — Searchable knowledge base
|
|
157
91
|
|
|
158
|
-
|
|
92
|
+
Index documentation into FTS5 with BM25 ranking. Search returns exact code blocks — not summaries.
|
|
159
93
|
|
|
160
94
|
```
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
│ Claude Code │ tool calls/results │ │
|
|
164
|
-
│ │ │ ┌────────────────────────┐ │
|
|
165
|
-
└─────────────┘ │ │ PolyglotExecutor │ │
|
|
166
|
-
│ │ • 10 language runtimes │ │
|
|
167
|
-
│ │ • Sandboxed subprocess │ │
|
|
168
|
-
│ │ • Auth passthrough │ │
|
|
169
|
-
│ │ • Intent-driven search │ │
|
|
170
|
-
│ └────────────────────────┘ │
|
|
171
|
-
│ │
|
|
172
|
-
│ ┌────────────────────────┐ │
|
|
173
|
-
│ │ ContentStore │ │
|
|
174
|
-
│ │ • SQLite FTS5 │ │
|
|
175
|
-
│ │ • BM25 ranking │ │
|
|
176
|
-
│ │ • Porter stemming │ │
|
|
177
|
-
│ │ • Heading-aware chunks │ │
|
|
178
|
-
│ │ • Vocabulary hints │ │
|
|
179
|
-
│ └────────────────────────┘ │
|
|
180
|
-
└──────────────────────────────┘
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Sandbox Isolation
|
|
95
|
+
index({ content: <60KB React docs>, source: "React useEffect" })
|
|
96
|
+
→ "Indexed 33 sections (15 with code)" ← 40 bytes
|
|
184
97
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
- **Isolated temp directory** per execution — scripts can't access each other
|
|
188
|
-
- **Real HOME** — so `gh`, `aws`, `gcloud` find their auth configs
|
|
189
|
-
- **Auth passthrough** — GH_TOKEN, AWS credentials, KUBECONFIG, Docker, npm tokens, XDG paths
|
|
190
|
-
- **Clean environment** — PATH, LANG, NO_COLOR, Python unbuffered mode
|
|
191
|
-
|
|
192
|
-
### FTS5 Knowledge Base
|
|
193
|
-
|
|
194
|
-
The `index` and `search` tools use SQLite FTS5 with BM25 ranking:
|
|
195
|
-
|
|
196
|
-
```sql
|
|
197
|
-
CREATE VIRTUAL TABLE chunks USING fts5(
|
|
198
|
-
title, -- heading hierarchy, weighted 2x
|
|
199
|
-
content, -- section text + code blocks
|
|
200
|
-
source_id UNINDEXED,
|
|
201
|
-
content_type UNINDEXED, -- "code" or "prose"
|
|
202
|
-
tokenize='porter unicode61' -- stemming + unicode support
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
SELECT title, content, bm25(chunks, 2.0, 1.0) AS rank
|
|
206
|
-
FROM chunks
|
|
207
|
-
WHERE chunks MATCH ?
|
|
208
|
-
ORDER BY rank LIMIT 3;
|
|
98
|
+
search({ query: "useEffect cleanup function" })
|
|
99
|
+
→ exact code example with heading context ← 500 bytes instead of 60KB
|
|
209
100
|
```
|
|
210
101
|
|
|
211
|
-
|
|
212
|
-
- Splits on H1-H4 headings and `---` separators
|
|
213
|
-
- Tracks heading hierarchy: `"React > Hooks > useEffect > Cleanup"`
|
|
214
|
-
- Keeps code blocks intact — never splits mid-block
|
|
215
|
-
- Marks chunks as `code` or `prose` for content-type filtering
|
|
216
|
-
- Porter stemming: "connecting" matches "connect", "connection", "connected"
|
|
217
|
-
|
|
218
|
-
**Lazy singleton:** Database created only when `index` or `search` is first called — zero overhead for sessions that don't use it.
|
|
102
|
+
### `fetch_and_index` — Fetch URLs into knowledge base
|
|
219
103
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
When `execute` or `execute_file` is called with an `intent` parameter and output exceeds 5KB, Context Mode uses score-based BM25 search to return only the relevant sections:
|
|
223
|
-
|
|
224
|
-
- **Score-based search**: Searches ALL intent words independently, ranks chunks by match count
|
|
225
|
-
- **Searchable terms**: Distinctive vocabulary hints extracted via IDF scoring, helping you craft precise follow-up `search()` calls
|
|
226
|
-
- **Smarter chunk titles**: Uses the first content line of each chunk instead of generic "Section N" labels
|
|
104
|
+
Fetches, converts HTML to markdown, indexes. Raw content never enters context. Use instead of WebFetch or Context7 when you need to reference docs multiple times.
|
|
227
105
|
|
|
228
106
|
```
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
With intent:
|
|
233
|
-
stdout (100KB) → chunk by lines → in-memory FTS5 → score all intent words → top chunks + searchable terms
|
|
234
|
-
Result: only what you need enters context, plus vocabulary for targeted follow-ups
|
|
107
|
+
fetch_and_index({ url: "https://react.dev/reference/react/useEffect" })
|
|
108
|
+
→ "Indexed 33 sections (15 with code)" ← 40 bytes instead of 60KB
|
|
235
109
|
```
|
|
236
110
|
|
|
237
|
-
**31% to 100% recall on real-world CHANGELOG test** — the score-based approach finds every relevant section, not just those matching a single query string.
|
|
238
|
-
|
|
239
|
-
Tested across 5 real-world scenarios:
|
|
240
|
-
|
|
241
|
-
| Scenario | Without Intent | With Intent | Size Reduction |
|
|
242
|
-
|---|---|---|---|
|
|
243
|
-
| Server log error (line 347/500) | error lost in output | **found** | 1.5 KB vs 5.0 KB |
|
|
244
|
-
| 3 test failures among 200 tests | only 2/3 visible | **all 3 found** | 2.4 KB vs 5.0 KB |
|
|
245
|
-
| 2 build warnings among 300 lines | both lost in output | **both found** | 2.1 KB vs 5.0 KB |
|
|
246
|
-
| API auth error (line 743/1000) | error lost in output | **found** | 1.2 KB vs 4.9 KB |
|
|
247
|
-
| Semantic gap (CHANGELOG search) | 31% recall | **100% recall** | Full coverage |
|
|
248
|
-
|
|
249
|
-
Intent search finds the target every time while using 50-75% fewer bytes.
|
|
250
|
-
|
|
251
|
-
### HTML to Markdown Conversion
|
|
252
|
-
|
|
253
|
-
`fetch_and_index` converts HTML in a subprocess (raw HTML never enters context):
|
|
254
|
-
|
|
255
|
-
1. Strip `<script>`, `<style>`, `<nav>`, `<header>`, `<footer>`
|
|
256
|
-
2. Convert `<h1>`-`<h4>` to `#`-`####` markdown headings
|
|
257
|
-
3. Convert `<pre><code>` to fenced code blocks with language detection
|
|
258
|
-
4. Convert `<a>`, `<li>`, `<p>`, `<br>`, `<hr>` to markdown
|
|
259
|
-
5. Decode HTML entities (`&`, `<`, ` `, etc.)
|
|
260
|
-
6. Collapse excessive whitespace
|
|
261
|
-
|
|
262
|
-
## Benchmarks
|
|
263
|
-
|
|
264
|
-
### Real MCP Ecosystem Comparison
|
|
265
|
-
|
|
266
|
-
Tested with tools from popular MCP servers and Claude Code workflows:
|
|
267
|
-
|
|
268
|
-
| Scenario | Tool | Raw | Context | Savings |
|
|
269
|
-
|---|---|---|---|---|
|
|
270
|
-
| Playwright page snapshot | `execute` | 56.2 KB | 299 B | **99%** |
|
|
271
|
-
| Context7 React docs | `execute` | 5.9 KB | 261 B | **96%** |
|
|
272
|
-
| Context7 Next.js docs | `execute` | 6.5 KB | 249 B | **96%** |
|
|
273
|
-
| Context7 Tailwind docs | `execute` | 4.0 KB | 186 B | **95%** |
|
|
274
|
-
| GitHub Issues (20) | `execute` | 58.9 KB | 1.1 KB | **98%** |
|
|
275
|
-
| GitHub PR list (5) | `execute` | 6.4 KB | 719 B | **89%** |
|
|
276
|
-
| Access log (500 req) | `execute_file` | 45.1 KB | 155 B | **100%** |
|
|
277
|
-
| Analytics CSV (500 rows) | `execute_file` | 85.5 KB | 222 B | **100%** |
|
|
278
|
-
| MCP tools manifest (40 tools) | `execute_file` | 17.0 KB | 742 B | **96%** |
|
|
279
|
-
| Test output (30 suites) | `execute` | 6.0 KB | 337 B | **95%** |
|
|
280
|
-
| Git log (153 commits) | `execute` | 11.6 KB | 107 B | **99%** |
|
|
281
|
-
|
|
282
|
-
### Session Impact
|
|
283
|
-
|
|
284
|
-
Typical 45-minute debugging session:
|
|
285
|
-
|
|
286
|
-
| Metric | Without | With | Delta |
|
|
287
|
-
|---|---|---|---|
|
|
288
|
-
| Context consumed | 315 KB | 5.4 KB | **-98%** |
|
|
289
|
-
| Tokens used | ~80,600 | ~1,400 | **-98%** |
|
|
290
|
-
| Context remaining | 60% | 99% | **+39pp** |
|
|
291
|
-
| Time before slowdown | ~30 min | ~3 hours | **+6x** |
|
|
292
|
-
|
|
293
|
-
## Tool Decision Matrix
|
|
294
|
-
|
|
295
|
-
| Data Type | Best Tool | Why |
|
|
296
|
-
|---|---|---|
|
|
297
|
-
| Web documentation | `fetch_and_index` → `search` | Index once, search many times |
|
|
298
|
-
| MCP tool output (large) | `index` → `search` | Keep raw output out of context |
|
|
299
|
-
| Log files | `execute_file` | Aggregate stats |
|
|
300
|
-
| Test output | `execute_file` | Pass/fail summary |
|
|
301
|
-
| CSV / JSON data | `execute_file` | Computed metrics |
|
|
302
|
-
| Git / GitHub operations | `execute` | `gh`, `git` commands with auth |
|
|
303
|
-
| Cloud CLI | `execute` | `aws`, `gcloud`, `kubectl` with auth |
|
|
304
|
-
| Build output | `execute` | Error counts and warnings |
|
|
305
|
-
| Source code to edit | Plain `Read` tool | Need full content for edits |
|
|
306
|
-
| Small files (<20 lines) | Plain `Read` tool | Minimal overhead |
|
|
307
|
-
|
|
308
111
|
## Example Prompts
|
|
309
112
|
|
|
310
|
-
Just ask naturally — Claude
|
|
311
|
-
|
|
312
|
-
### Git & GitHub
|
|
113
|
+
Just ask naturally — Claude routes through Context Mode automatically when it saves tokens.
|
|
313
114
|
|
|
314
115
|
```
|
|
315
116
|
"Analyze the last 50 commits and find the most frequently changed files"
|
|
316
|
-
"List all open PRs on this repo and summarize their status"
|
|
317
|
-
"Show contributors ranked by commit count this month"
|
|
318
|
-
"Find all commits that touched the auth module in the last 30 days"
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### Code Analysis
|
|
322
|
-
|
|
323
|
-
```
|
|
324
|
-
"Analyze all TypeScript files in src/ and report function counts per file"
|
|
325
|
-
"Find all TODO and FIXME comments across the codebase"
|
|
326
|
-
"Count lines of code per language in this project"
|
|
327
|
-
"List all exported functions from src/utils/ and their parameter signatures"
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
### Logs & Debugging
|
|
331
|
-
|
|
332
|
-
```
|
|
333
117
|
"Read the access log and break down requests by HTTP status code"
|
|
334
|
-
"Find the top 10 slowest API endpoints from the request log"
|
|
335
|
-
"Parse the error log and group exceptions by type with frequency"
|
|
336
|
-
"Analyze the build output and list all warnings with file locations"
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
### Test & CI
|
|
340
|
-
|
|
341
|
-
```
|
|
342
118
|
"Run the test suite and give me a pass/fail summary"
|
|
343
|
-
"
|
|
344
|
-
"
|
|
119
|
+
"Fetch the React useEffect docs and find the cleanup pattern"
|
|
120
|
+
"List all Docker containers with their memory usage"
|
|
121
|
+
"Find all TODO comments across the codebase"
|
|
122
|
+
"Analyze package-lock.json and find the 10 largest dependencies"
|
|
123
|
+
"Show running Kubernetes pods and their restart counts"
|
|
345
124
|
```
|
|
346
125
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
```
|
|
350
|
-
"Analyze package-lock.json and find the 10 largest dependencies by size"
|
|
351
|
-
"Parse the CSV export and compute average response time per endpoint"
|
|
352
|
-
"Read the Kubernetes manifests and summarize resource limits per pod"
|
|
353
|
-
"Compare tsconfig.json across packages in this monorepo"
|
|
354
|
-
```
|
|
126
|
+
## Real-World Benchmarks
|
|
355
127
|
|
|
356
|
-
|
|
128
|
+
| Operation | Raw | Context | Savings |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| Playwright `browser_snapshot` | 56.2 KB | 299 B | **99%** |
|
|
131
|
+
| GitHub Issues (20) | 58.9 KB | 1.1 KB | **98%** |
|
|
132
|
+
| Access log (500 requests) | 45.1 KB | 155 B | **100%** |
|
|
133
|
+
| Context7 React docs | 5.9 KB | 261 B | **96%** |
|
|
134
|
+
| Analytics CSV (500 rows) | 85.5 KB | 222 B | **100%** |
|
|
135
|
+
| Git log (153 commits) | 11.6 KB | 107 B | **99%** |
|
|
136
|
+
| Test output (30 suites) | 6.0 KB | 337 B | **95%** |
|
|
357
137
|
|
|
358
|
-
|
|
359
|
-
"Fetch the React useEffect docs and find the cleanup pattern"
|
|
360
|
-
"Index the Next.js App Router documentation and search for loading states"
|
|
361
|
-
"Look up the Zod docs and find string validation examples"
|
|
362
|
-
"Fetch the Tailwind docs and search for responsive breakpoint utilities"
|
|
363
|
-
```
|
|
138
|
+
[Full benchmark data with 21 scenarios →](BENCHMARK.md)
|
|
364
139
|
|
|
365
|
-
|
|
140
|
+
## How It Works
|
|
366
141
|
|
|
367
142
|
```
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
143
|
+
┌─────────────┐ stdio / JSON-RPC ┌─────────────────────────────────┐
|
|
144
|
+
│ Claude Code │ ◄─────────────────────► │ Context Mode MCP Server │
|
|
145
|
+
│ │ tool calls/results │ │
|
|
146
|
+
└─────────────┘ │ Sandboxed subprocesses │
|
|
147
|
+
│ • 10 language runtimes │
|
|
148
|
+
│ • Auth passthrough (gh, aws…) │
|
|
149
|
+
│ • Intent-driven search │
|
|
150
|
+
│ │
|
|
151
|
+
│ SQLite FTS5 knowledge base │
|
|
152
|
+
│ • BM25 ranking │
|
|
153
|
+
│ • Porter stemming │
|
|
154
|
+
│ • Heading-aware chunking │
|
|
155
|
+
└─────────────────────────────────┘
|
|
372
156
|
```
|
|
373
157
|
|
|
158
|
+
Each `execute` call spawns an isolated subprocess — scripts can't access each other, but authenticated CLIs (`gh`, `aws`, `gcloud`) find their configs through secure credential passthrough.
|
|
159
|
+
|
|
374
160
|
## Requirements
|
|
375
161
|
|
|
376
162
|
- **Node.js 18+**
|
|
377
163
|
- **Claude Code** with MCP support
|
|
378
|
-
|
|
379
|
-
### Auto-Detected Runtimes
|
|
380
|
-
|
|
381
|
-
| Runtime | Used For | Speed |
|
|
382
|
-
|---|---|---|
|
|
383
|
-
| Bun (optional) | JS/TS execution | 3-5x faster than Node |
|
|
384
|
-
| Python 3 | Python code | Standard |
|
|
385
|
-
| Ruby, Go, Rust, PHP, Perl, R | Respective languages | Standard |
|
|
386
|
-
|
|
387
|
-
## Test Suite
|
|
388
|
-
|
|
389
|
-
100+ tests across 4 suites:
|
|
390
|
-
|
|
391
|
-
| Suite | Tests | Coverage |
|
|
392
|
-
|---|---|---|
|
|
393
|
-
| Executor | 55 | 10 languages, sandbox, output handling, concurrency, timeouts |
|
|
394
|
-
| ContentStore | 40 | FTS5 schema, BM25 ranking, chunking, stemming, plain text indexing |
|
|
395
|
-
| Intent Search | 5 | Intent-driven search across 5 real-world scenarios (incl. semantic gap) |
|
|
396
|
-
| MCP Integration | 24 | JSON-RPC protocol, all 5 tools, fetch_and_index, errors |
|
|
164
|
+
- Optional: Bun (auto-detected, 3-5x faster JS/TS)
|
|
397
165
|
|
|
398
166
|
## Development
|
|
399
167
|
|
|
400
168
|
```bash
|
|
401
169
|
git clone https://github.com/mksglu/claude-context-mode.git
|
|
402
|
-
cd claude-context-mode
|
|
403
|
-
npm
|
|
404
|
-
npm run
|
|
405
|
-
npm test # executor (55 tests)
|
|
406
|
-
npm run test:store # FTS5/BM25 (40 tests)
|
|
407
|
-
npm run test:all # all suites (100+ tests)
|
|
170
|
+
cd claude-context-mode && npm install
|
|
171
|
+
npm test # 100+ tests across 4 suites
|
|
172
|
+
npm run test:all # full suite
|
|
408
173
|
```
|
|
409
174
|
|
|
410
175
|
## License
|
package/build/server.js
CHANGED
|
@@ -5,7 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
import { PolyglotExecutor } from "./executor.js";
|
|
6
6
|
import { ContentStore } from "./store.js";
|
|
7
7
|
import { detectRuntimes, getRuntimeSummary, getAvailableLanguages, hasBunRuntime, } from "./runtime.js";
|
|
8
|
-
const VERSION = "0.5.
|
|
8
|
+
const VERSION = "0.5.13";
|
|
9
9
|
const runtimes = detectRuntimes();
|
|
10
10
|
const available = getAvailableLanguages(runtimes);
|
|
11
11
|
const server = new McpServer({
|
package/build/store.js
CHANGED
|
@@ -49,7 +49,7 @@ export class ContentStore {
|
|
|
49
49
|
#db;
|
|
50
50
|
constructor(dbPath) {
|
|
51
51
|
const path = dbPath ?? join(tmpdir(), `context-mode-${process.pid}.db`);
|
|
52
|
-
this.#db = new Database(path);
|
|
52
|
+
this.#db = new Database(path, { timeout: 5000 });
|
|
53
53
|
this.#db.pragma("journal_mode = WAL");
|
|
54
54
|
this.#db.pragma("synchronous = NORMAL");
|
|
55
55
|
this.#initSchema();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "context-mode",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution, FTS5 knowledge base, and intent-driven search.",
|
|
6
6
|
"author": "Mert Koseoğlu",
|
|
@@ -51,6 +51,15 @@ About to run a command / read a file / call an API?
|
|
|
51
51
|
│ browser_network_requests(filename) → execute_file(path)
|
|
52
52
|
│ ⚠ browser_navigate returns a snapshot automatically — ignore it,
|
|
53
53
|
│ use browser_snapshot(filename) for any inspection.
|
|
54
|
+
│ ⚠ Playwright MCP uses a SINGLE browser instance — NOT parallel-safe.
|
|
55
|
+
│ For parallel browser ops, use agent-browser via execute instead.
|
|
56
|
+
│
|
|
57
|
+
├── Using agent-browser (parallel-safe browser automation)?
|
|
58
|
+
│ └── Run via execute (shell) — each call gets its own subprocess:
|
|
59
|
+
│ execute("agent-browser open example.com && agent-browser snapshot -i -c")
|
|
60
|
+
│ ✓ Supports sessions for isolated browser instances
|
|
61
|
+
│ ✓ Safe for parallel subagent execution
|
|
62
|
+
│ ✓ Lightweight accessibility tree with ref-based interaction
|
|
54
63
|
│
|
|
55
64
|
├── Processing output from another MCP tool (Context7, GitHub API, etc.)?
|
|
56
65
|
│ ├── Output already in context from a previous tool call?
|