sdl-mcp 0.9.2 → 0.9.3

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 CHANGED
@@ -1,588 +1,588 @@
1
- <div align="center">
2
- <img src="https://github.com/GlitterKill/sdl-mcp/blob/main/docs/Symbol_Delta_Ledger_MCP.jpg" alt="Symbol Delta Ledger MCP">
3
-
4
- <br/>
5
-
6
- # SDL-MCP
7
-
8
- ### **Cards-first code context for AI coding agents**
9
-
10
- *Stop feeding entire files into the context window.<br/>Start giving agents exactly the code intelligence they need.*
11
-
12
- <br/>
13
-
14
- ![npm version](https://img.shields.io/npm/v/sdl-mcp.svg?style=for-the-badge)
15
- ![npm downloads](https://img.shields.io/npm/dm/sdl-mcp.svg?style=for-the-badge)
16
- ![GitHub commit activity](https://img.shields.io/github/commit-activity/w/GlitterKill/sdl-mcp?style=for-the-badge)
17
-
18
- </div>
19
-
20
- ---
21
-
22
- <br/>
23
-
24
- ## What's the problem?
25
-
26
- Every time an AI coding agent reads a file to answer a question, it consumes thousands of tokens. Most of those tokens are irrelevant to the task. The agent doesn't need 500 lines of a file to know that `validateToken` takes a `string` and returns a `Promise<User>` — but it reads them anyway, because that's all it has.
27
-
28
- **Multiply that across a debugging session touching 20 files and you've burned 40,000+ tokens on context gathering alone.**
29
-
30
- SDL-MCP fixes this. It indexes your codebase into a searchable **symbol graph** and serves precisely the right amount of context through a controlled escalation path. An agent that uses SDL-MCP understands your code better while consuming a fraction of the tokens.
31
-
32
- <br/>
33
-
34
- ---
35
-
36
- <br/>
37
-
38
- ## How it works — in 30 seconds
39
-
40
- ```
41
- Your Codebase
42
-
43
- ┌──────┴──────┐
44
- │ Indexer │ Native Rust (fast) or Tree-sitter (universal)
45
- │ 12 langs │ TS · JS · Python · Go · Java · C# · C · C++ · PHP · Rust · Kotlin · Shell
46
- └──────┬──────┘
47
-
48
-
49
- ┌───────────────────────┐
50
- │ Symbol Graph (DB) │ Functions, classes, interfaces, types, edges, metrics
51
- │ LadybugDB (graph) │ Persisted. Incremental. Versioned.
52
- └───────────┬───────────┘
53
-
54
- ┌──────────┼──────────┐
55
- │ │ │
56
- ▼ ▼ ▼
57
- 29 MCP 10 CLI HTTP API
58
- Tools Commands + Graph UI
59
-
60
-
61
- AI Coding Agent
62
- (Claude Code, Claude Desktop, Cursor, Windsurf, any MCP client)
63
- ```
64
-
65
- 1. **Index once** — SDL-MCP parses every symbol in your repo and stores it as a compact metadata record (a "Symbol Card") in a graph database
66
- 2. **Query efficiently** — Agents use MCP tools to search, slice, and retrieve exactly the context they need
67
- 3. **Escalate only when necessary** — A four-rung ladder controls how much code the agent sees, from a 100-token card to full source (with justification required)
68
-
69
- <br/>
70
-
71
- ---
72
-
73
- <br/>
74
-
75
- ## Quick Start
76
-
77
- ```bash
78
- # Install
79
- npm install -g sdl-mcp
80
-
81
- # Initialize, auto-detect languages, index your repo, and run health checks
82
- sdl-mcp init -y --auto-index
83
-
84
- # Start the MCP server for your coding agent
85
- sdl-mcp serve --stdio
86
- ```
87
-
88
- Point your MCP client at the server and the agent gains access to all SDL-MCP tools. That's it.
89
-
90
- > **npx users:** Replace `sdl-mcp` with `npx --yes sdl-mcp@latest` in all commands above.
91
-
92
- [Full Getting Started Guide →](./docs/getting-started.md)
93
-
94
- <br/>
95
-
96
- ---
97
-
98
- <br/>
99
-
100
- ## The Iris Gate Ladder
101
-
102
- The core innovation. Named after the adjustable aperture that controls light flow in optics, the Iris Gate Ladder lets agents dial their context "aperture" from a pinhole to wide-open.
103
-
104
- ```
105
- Token Cost What the Agent Sees
106
- ────────────────────────────────────────────────
107
- ~100 RUNG 1 ▸ Symbol Card
108
- Name, signature, summary, dependencies, metrics
109
- "What does this function do and what does it call?"
110
-
111
- ~300 RUNG 2 ▸ Skeleton IR
112
- Signatures + control flow, bodies replaced with /* ... */
113
- "What's the shape of this class?"
114
-
115
- ~600 RUNG 3 ▸ Hot-Path Excerpt
116
- Only lines matching specific identifiers + context
117
- "Where exactly is `this.cache` initialized?"
118
-
119
- ~2,000 RUNG 4 ▸ Raw Code Window Policy-gated
120
- Full source code, requires justification
121
- "I need to rewrite this error handler"
122
- ```
123
-
124
- > **Most questions are answered at Rungs 1-2** without ever reading raw code. That's where the token savings come from.
125
-
126
- | Scenario | Reading the file | Using the Ladder | Savings |
127
- |:---------|:----------------:|:----------------:|:-------:|
128
- | "What does `parseConfig` accept?" | ~2,000 tok | ~100 tok | **20x** |
129
- | "Show me the shape of `AuthService`" | ~4,000 tok | ~300 tok | **13x** |
130
- | "Where is `this.cache` set?" | ~2,000 tok | ~500 tok | **4x** |
131
-
132
- **Why it matters:**
133
- - **4–20x token savings** on typical code understanding queries
134
- - Most questions answered at Rungs 1–2 without ever reading raw code
135
- - Controlled escalation prevents agents from over-consuming context
136
- - Policy-gated raw access ensures agents prove they need full source
137
-
138
- [Iris Gate Ladder Deep Dive →](./docs/feature-deep-dives/iris-gate-ladder.md)
139
-
140
- <br/>
141
-
142
- ---
143
-
144
- <br/>
145
-
146
- ## Feature Tour
147
-
148
- ### Symbol Cards — The Atoms of Understanding
149
-
150
- Every function, class, interface, type, and variable becomes a **Symbol Card**: a compact metadata record (~100 tokens) containing everything an agent needs to *understand* a symbol without reading its code.
151
-
152
- ```
153
- ┌─────────────────────────────────────────────────────────┐
154
- │ Symbol Card: validateToken │
155
- │─────────────────────────────────────────────────────────│
156
- │ Kind: function (exported) │
157
- │ File: src/auth/jwt.ts:42-67 │
158
- │ Signature: (token: string, opts?: ValidateOpts) │
159
- │ → Promise<DecodedToken> │
160
- │ Summary: Validates JWT signature and expiration, │
161
- │ returns decoded payload or throws │
162
- │ Invariants: ["throws on expired token"] │
163
- │ Side FX: ["logs to audit trail"] │
164
- │ Deps: calls: [verifySignature, checkExpiry] │
165
- │ imports: [jsonwebtoken, AuditLogger] │
166
- │ Metrics: fan-in: 12 │ fan-out: 4 │ churn: 3/30d │
167
- │ Cluster: auth-module (8 members) │
168
- │ Process: request-pipeline (intermediate, depth 1) │
169
- │ Test: auth.test.ts (distance: 1, proximity: 0.9)│
170
- │ ETag: a7f3c2... (for conditional requests) │
171
- └─────────────────────────────────────────────────────────┘
172
- ```
173
-
174
- Cards include **confidence-scored call resolution** (the pass-2 resolver traces imports, aliases, barrel re-exports, and tagged templates to produce accurate dependency edges), **community detection** (cluster membership), and **call-chain tracing** (process participation with entry/intermediate/exit roles).
175
-
176
- **Why it matters:**
177
- - **~100 tokens per symbol** vs. ~2,000 tokens to read the full file
178
- - Confidence-scored dependency edges trace real call relationships across files
179
- - Community detection and call-chain tracing reveal architectural structure
180
- - ETag-based conditional requests avoid re-fetching unchanged symbols
181
-
182
- [Indexing & Language Support Deep Dive →](./docs/feature-deep-dives/indexing-languages.md)
183
-
184
- ---
185
-
186
- ### Graph Slicing — The Right Context for Every Task
187
-
188
- Instead of reading files in the same directory, SDL-MCP follows the *dependency graph*. Starting from symbols relevant to your task, it traverses weighted edges (call: 1.0, config: 0.8, import: 0.6), scores each symbol by relevance, and returns the N most important within a token budget.
189
-
190
- ```
191
- "Fix the auth middleware" → slice.build
192
-
193
- BFS over graph
194
-
195
- ┌──────────────────┼──────────────────┐
196
- ▼ ▼ ▼
197
- authenticate validateToken JwtConfig
198
- │ │ │
199
- ▼ ▼ ▼
200
- hashPassword getUserById envLoader
201
-
202
- ◆ frontier
203
- (outside budget)
204
-
205
- 8 cards returned · ~800 tokens
206
- vs. reading 8 files · ~16,000 tokens
207
- ```
208
-
209
- Slices have handles, leases, refresh (delta-only updates), and spillover (paged overflow). You can also skip the symbol search entirely — pass a `taskText` string and SDL-MCP auto-discovers the relevant entry symbols.
210
-
211
- **Why it matters:**
212
- - Follows the **dependency graph**, not directory boundaries, for cross-cutting context
213
- - Weighted edge scoring (call > config > import) prioritizes the most relevant symbols
214
- - Token-budgeted: returns only what fits within your budget (~800 tokens vs. ~16,000 for raw files)
215
- - Natural-language task-text auto-discovers entry symbols — no symbol IDs needed
216
-
217
- [Graph Slicing Deep Dive →](./docs/feature-deep-dives/graph-slicing.md)
218
-
219
- ---
220
-
221
- ### Delta Packs & Blast Radius — Semantic Change Intelligence
222
-
223
- `git diff` tells you what lines changed. SDL-MCP tells you what that change *means* and who's affected.
224
-
225
- ```
226
- Modified: validateToken() signature
227
-
228
- ├── signatureDiff: added `options?: object` parameter
229
- ├── invariantDiff: added "throws on expired"
230
- └── sideEffectDiff: added "logs to audit trail"
231
-
232
-
233
- Blast Radius (ranked):
234
- 1. authenticate() ← direct caller, distance 1
235
- 2. refreshSession() ← direct caller, distance 1
236
- 3. AuthMiddleware ← calls authenticate, distance 2
237
- 4. auth.test.ts ← test coverage, flagged for re-run
238
- ```
239
-
240
- **PR risk analysis** (`sdl.pr.risk.analyze`) wraps this into a scored assessment with findings, evidence, and test recommendations. **Fan-in trend analysis** detects "amplifier" symbols whose growing dependency count means changes ripple further over time.
241
-
242
- **Why it matters:**
243
- - Semantic diffs show what a change **means**, not just what lines moved
244
- - Ranked blast radius identifies which dependent symbols are most at risk
245
- - Fan-in trend analysis detects "amplifier" symbols whose changes ripple further over time
246
- - PR risk scoring produces actionable findings with test re-run recommendations
247
-
248
- [Delta & Blast Radius Deep Dive →](./docs/feature-deep-dives/delta-blast-radius.md)
249
-
250
- ---
251
-
252
- ### Live Indexing — Real-Time Code Intelligence
253
-
254
- SDL-MCP doesn't wait for you to save. As you type in your editor, buffer updates are pushed to an in-memory overlay store, parsed in the background, and merged with the durable database. Search, cards, and slices reflect your *current* code, not your last save.
255
-
256
- ```
257
- Editor keystrokes → sdl.buffer.push → Overlay Store → merged reads
258
-
259
- on save / idle
260
-
261
-
262
- LadybugDB (durable)
263
- ```
264
-
265
- **Why it matters:**
266
- - Search, cards, and slices reflect **unsaved editor changes** in real time
267
- - No manual re-index needed during active development
268
- - Background AST parsing with in-memory overlay keeps queries fast
269
-
270
- [Live Indexing Deep Dive →](./docs/feature-deep-dives/live-indexing.md)
271
-
272
- ---
273
-
274
- ### Governance & Policy — Controlled Access
275
-
276
- Raw code access (Rung 4) is **policy-gated**. Agents must provide:
277
- - A **reason** explaining why they need raw code
278
- - **Identifiers** they expect to find in the code
279
- - An **expected line count** within configured limits
280
-
281
- Requests that don't meet policy are denied with actionable guidance ("try `getHotPath` with these identifiers instead"). Every access is audit-logged.
282
-
283
- The sandboxed runtime execution tool (`sdl.runtime.execute`) has its own governance layer: disabled by default, executable allowlisting, CWD jailing, environment scrubbing, concurrency limits, and timeout enforcement.
284
-
285
- **Why it matters:**
286
- - Proof-of-need gating prevents agents from wastefully reading raw code
287
- - Denied requests include **actionable next-best-action** guidance
288
- - Full audit logging of every code access decision
289
- - Sandboxed runtime with executable allowlisting, CWD jailing, and environment scrubbing
290
-
291
- [Governance & Policy Deep Dive →](./docs/feature-deep-dives/governance-policy.md)
292
-
293
- ---
294
-
295
- ### Agent Orchestration — Autopilot Mode
296
-
297
- `sdl.agent.orchestrate` is an autonomous task engine. Give it a task type (`debug`, `review`, `implement`, `explain`), a description, and a budget — it plans the optimal Iris Gate path, executes it, collects evidence, and returns a synthesized answer.
298
-
299
- The feedback loop (`sdl.agent.feedback`) records which symbols were useful and which were missing, improving future slice quality.
300
-
301
- `sdl.context.summary` generates portable, token-bounded context briefings in markdown, JSON, or clipboard format for use outside MCP environments.
302
-
303
- **Why it matters:**
304
- - Autonomous task execution plans the **optimal Iris Gate path** within a token budget
305
- - Feedback loop records what was useful/missing, improving future slice quality
306
- - Portable context summaries export findings for use outside MCP environments
307
-
308
- [Agent Orchestration Deep Dive →](./docs/feature-deep-dives/agent-orchestration.md)
309
-
310
- ---
311
-
312
- ### Sandboxed Runtime Execution
313
-
314
- Run tests, linters, and scripts through SDL-MCP's governance layer instead of uncontrolled shell access. Three runtimes (Node.js, Python, Shell), code-mode or args-mode, smart output summarization with keyword-matched excerpts, and gzip artifact persistence.
315
-
316
- **Why it matters:**
317
- - Run tests, linters, and scripts **under governance** instead of uncontrolled shell access
318
- - 16 runtimes supported (Node, Python, Go, Java, Rust, Shell, and more)
319
- - Executable allowlisting, CWD jailing, timeout enforcement, and environment scrubbing
320
- - Smart output summarization with keyword-matched excerpts and gzip artifact persistence
321
-
322
- [Runtime Execution Deep Dive →](./docs/feature-deep-dives/runtime-execution.md)
323
-
324
- ---
325
-
326
- ### Development Memories — Cross-Session Knowledge Persistence
327
-
328
- Agents forget everything between sessions. SDL-MCP fixes this with a **graph-backed memory system** that lets agents store decisions, bugfix context, and task notes linked directly to the symbols and files they relate to. Memories are stored both in the graph database (for fast querying) and as checked-in markdown files (for version control and team sharing).
329
-
330
- ```
331
- Agent Session 1 Agent Session 2
332
- ───────────── ─────────────
333
- "Fixed race condition in sdl.memory.surface
334
- authenticate() — added mutex" │
335
- │ ┌────┴─────┐
336
- ▼ │ Relevant │
337
- sdl.memory.store │ memories │
338
- │ │ surfaced │
339
- ├──▶ Graph DB (Memory node) └────┬─────┘
340
- │ ├── MEMORY_OF ──▶ authenticate() │
341
- │ └── HAS_MEMORY ◀── Repo ▼
342
- │ "Previous fix: race condition
343
- └──▶ .sdl-memory/bugfixes/a1b2c3.md in authenticate() — mutex added"
344
- (YAML frontmatter + markdown)
345
- ```
346
-
347
- Memories are **automatically surfaced** inside graph slices — when an agent builds a slice touching symbols with linked memories, those memories appear alongside the cards. During re-indexing, memories linked to changed symbols are **flagged as stale**, prompting agents to review and update them. Four MCP tools (`store`, `query`, `remove`, `surface`) provide full CRUD plus intelligent ranking by confidence, recency, and symbol overlap.
348
-
349
- **Why it matters:**
350
- - Structured knowledge **persists across sessions**, linked directly to symbols and files
351
- - Automatically surfaced inside graph slices when touching related symbols
352
- - Stale memories flagged when linked symbols change during re-indexing
353
- - Dual storage: graph DB for fast querying + markdown files for version control and team sharing
354
-
355
- [Development Memories Deep Dive →](./docs/feature-deep-dives/development-memories.md)
356
-
357
- ---
358
-
359
- ### CLI Tool Access — No MCP Server Required
360
-
361
- Access all 29 tool actions directly from the command line with `sdl-mcp tool`. No MCP server, transport, or SDK — just your terminal.
362
-
363
- ```bash
364
- # Search for symbols
365
- sdl-mcp tool symbol.search --query "handleAuth" --output-format pretty
366
-
367
- # Build a task-scoped slice
368
- sdl-mcp tool slice.build --task-text "debug auth flow" --max-cards 50
369
-
370
- # Pipe JSON args, chain commands
371
- echo '{"repoId":"my-repo"}' | sdl-mcp tool symbol.search --query "auth"
372
- ```
373
-
374
- Features include typed argument coercion (string, number, boolean, string[], json), budget flag merging, stdin JSON piping with CLI-flags-win precedence, auto-resolved `repoId` from cwd, four output formats (json, json-compact, pretty, table), typo suggestions, and per-action `--help`. The CLI dispatches through the same gateway router and Zod schemas as the MCP server — identical code paths, identical validation.
375
-
376
- **Why it matters:**
377
- - All MCP tool actions accessible from **any terminal** — no server, transport, or SDK required
378
- - Same code paths and Zod validation as the MCP server — identical behavior
379
- - Four output formats (json, json-compact, pretty, table) for scripting and CI pipelines
380
- - Auto-resolves repoId from cwd, supports stdin JSON piping and per-action `--help`
381
-
382
- [CLI Tool Access Deep Dive →](./docs/feature-deep-dives/cli-tool-access.md)
383
-
384
- ---
385
-
386
- ### Tool Gateway — 81% Token Reduction
387
-
388
- The tool gateway consolidates all 29 MCP tools into **4 namespace-scoped tools** (`sdl.query`, `sdl.code`, `sdl.repo`, `sdl.agent`), reducing `tools/list` overhead from **~3,742 tokens to ~713 tokens** — an **81% reduction**.
389
-
390
- ```
391
- Before: 29 tools × full JSON Schema = ~3,742 tokens at conversation start
392
- After: 4 tools × thin schema = ~713 tokens at conversation start
393
- ─────────────
394
- ~3,029 tokens saved per conversation
395
- ```
396
-
397
- Each gateway tool accepts an `action` discriminator field (e.g., `{ action: "symbol.search", repoId: "x", query: "auth" }`) and routes to the same handlers with double Zod validation. Thin wire schemas in `tools/list` keep the registration compact while full validation happens server-side. Legacy flat tool names are optionally emitted alongside for backward compatibility.
398
-
399
- **Why it matters:**
400
- - **81% token reduction** in `tools/list` overhead (~3,742 → ~713 tokens per conversation)
401
- - 29 tools consolidated into 4 namespace-scoped tools for simpler agent selection
402
- - Fewer tool choices means faster and more accurate tool dispatch by the agent
403
- - Backward-compatible: legacy flat tool names optionally emitted alongside
404
-
405
- [Tool Gateway Deep Dive →](./docs/feature-deep-dives/tool-gateway.md)
406
-
407
- <br/>
408
-
409
- ---
410
-
411
- <br/>
412
-
413
- ## All 29 MCP Tools at a Glance
414
-
415
- <table>
416
- <tr><th>Category</th><th>Tool</th><th>One-Line Description</th></tr>
417
- <tr><td rowspan="4"><strong>Repository</strong></td>
418
- <td><code>sdl.repo.register</code></td><td>Register a codebase for indexing</td></tr>
419
- <tr><td><code>sdl.repo.status</code></td><td>Health, versions, watcher, prefetch, live-index stats</td></tr>
420
- <tr><td><code>sdl.repo.overview</code></td><td>Codebase summary: stats, directories, hotspots, clusters</td></tr>
421
- <tr><td><code>sdl.index.refresh</code></td><td>Trigger full or incremental re-indexing</td></tr>
422
-
423
- <tr><td rowspan="3"><strong>Live Buffer</strong></td>
424
- <td><code>sdl.buffer.push</code></td><td>Push unsaved editor content for real-time indexing</td></tr>
425
- <tr><td><code>sdl.buffer.checkpoint</code></td><td>Force-write pending buffers to the durable database</td></tr>
426
- <tr><td><code>sdl.buffer.status</code></td><td>Live indexing diagnostics and queue depth</td></tr>
427
-
428
- <tr><td rowspan="3"><strong>Symbols</strong></td>
429
- <td><code>sdl.symbol.search</code></td><td>Search symbols by name (with optional semantic reranking)</td></tr>
430
- <tr><td><code>sdl.symbol.getCard</code></td><td>Get a symbol card with ETag-based conditional support</td></tr>
431
- <tr><td><code>sdl.symbol.getCards</code></td><td>Batch-fetch up to 100 cards in one round trip</td></tr>
432
-
433
- <tr><td rowspan="3"><strong>Slices</strong></td>
434
- <td><code>sdl.slice.build</code></td><td>Build a task-scoped dependency subgraph</td></tr>
435
- <tr><td><code>sdl.slice.refresh</code></td><td>Delta-only update of an existing slice</td></tr>
436
- <tr><td><code>sdl.slice.spillover.get</code></td><td>Page through overflow symbols beyond the budget</td></tr>
437
-
438
- <tr><td rowspan="3"><strong>Code Access</strong></td>
439
- <td><code>sdl.code.getSkeleton</code></td><td>Signatures + control flow, bodies elided</td></tr>
440
- <tr><td><code>sdl.code.getHotPath</code></td><td>Lines matching specific identifiers + context</td></tr>
441
- <tr><td><code>sdl.code.needWindow</code></td><td>Full source code (policy-gated, requires justification)</td></tr>
442
-
443
- <tr><td><strong>Deltas</strong></td>
444
- <td><code>sdl.delta.get</code></td><td>Semantic diff + blast radius between versions</td></tr>
445
-
446
- <tr><td rowspan="2"><strong>Policy</strong></td>
447
- <td><code>sdl.policy.get</code></td><td>Read current gating policy</td></tr>
448
- <tr><td><code>sdl.policy.set</code></td><td>Update line/token limits and identifier requirements</td></tr>
449
-
450
- <tr><td><strong>Risk</strong></td>
451
- <td><code>sdl.pr.risk.analyze</code></td><td>Scored PR risk with findings and test recommendations</td></tr>
452
-
453
- <tr><td><strong>Context</strong></td>
454
- <td><code>sdl.context.summary</code></td><td>Token-bounded portable briefing (markdown/JSON/clipboard)</td></tr>
455
-
456
- <tr><td rowspan="3"><strong>Agent</strong></td>
457
- <td><code>sdl.agent.orchestrate</code></td><td>Autonomous task execution with budget control</td></tr>
458
- <tr><td><code>sdl.agent.feedback</code></td><td>Record which symbols were useful or missing</td></tr>
459
- <tr><td><code>sdl.agent.feedback.query</code></td><td>Query aggregated feedback statistics</td></tr>
460
-
461
- <tr><td><strong>Runtime</strong></td>
462
- <td><code>sdl.runtime.execute</code></td><td>Sandboxed subprocess execution (Node/Python/Shell)</td></tr>
463
-
464
- <tr><td rowspan="4"><strong>Memory</strong></td>
465
- <td><code>sdl.memory.store</code></td><td>Store or update a development memory with symbol/file links</td></tr>
466
- <tr><td><code>sdl.memory.query</code></td><td>Search memories by text, type, tags, or linked symbols</td></tr>
467
- <tr><td><code>sdl.memory.remove</code></td><td>Soft-delete a memory from graph and optionally from disk</td></tr>
468
- <tr><td><code>sdl.memory.surface</code></td><td>Auto-surface relevant memories for a task context</td></tr>
469
- </table>
470
-
471
- [Complete MCP Tools Reference (detailed parameters & responses) →](./docs/mcp-tools-detailed.md)
472
-
473
- <br/>
474
-
475
- ---
476
-
477
- <br/>
478
-
479
- ## CLI Commands
480
-
481
- | Command | Description |
482
- |:--------|:------------|
483
- | `sdl-mcp init` | Bootstrap config, detect repo/languages, optionally auto-index |
484
- | `sdl-mcp doctor` | Validate runtime, config, DB, grammars, repo access |
485
- | `sdl-mcp index` | Index repositories (with optional `--watch` mode) |
486
- | `sdl-mcp serve` | Start MCP server (`--stdio` or `--http`) |
487
- | `sdl-mcp tool` | Access all 25 MCP tool actions directly ([docs](./docs/feature-deep-dives/cli-tool-access.md)) |
488
- | `sdl-mcp summary` | Generate copy/paste context summaries from the CLI |
489
- | `sdl-mcp health` | Compute composite health score with badge/JSON output |
490
- | `sdl-mcp export` | Export sync artifact |
491
- | `sdl-mcp import` | Import sync artifact |
492
- | `sdl-mcp pull` | Pull by version/commit with fallback |
493
- | `sdl-mcp version` | Show version and environment info |
494
-
495
- [CLI Reference →](./docs/cli-reference.md) · [Configuration Reference →](./docs/configuration-reference.md)
496
-
497
- <br/>
498
-
499
- ---
500
-
501
- <br/>
502
-
503
- ## Compatible With
504
-
505
- SDL-MCP works with any MCP-compatible client:
506
-
507
- | Client | Transport | Setup |
508
- |:-------|:----------|:------|
509
- | **Claude Code** | stdio | `sdl-mcp init --client claude-code` |
510
- | **Claude Desktop** | stdio | `sdl-mcp init --client claude-code` |
511
- | **Cursor** | stdio | Standard MCP server config |
512
- | **Windsurf** | stdio | Standard MCP server config |
513
- | **Codex CLI** | stdio | `sdl-mcp init --client codex` |
514
- | **Gemini CLI** | stdio | `sdl-mcp init --client gemini` |
515
- | **OpenCode** | stdio | `sdl-mcp init --client opencode` |
516
- | **Any MCP client** | stdio / http | `sdl-mcp serve --stdio` or `--http` |
517
-
518
- A **VSCode extension** (`sdl-mcp-vscode/`) provides live buffer integration for real-time indexing of unsaved edits.
519
-
520
- <br/>
521
-
522
- ---
523
-
524
- <br/>
525
-
526
- ## Tech Stack
527
-
528
- | Component | Technology |
529
- |:----------|:-----------|
530
- | Runtime | Node.js 20+ / TypeScript 5.9+ (strict ESM) |
531
- | Graph Database | LadybugDB (embedded, single-file) |
532
- | Indexer (default) | Rust via napi-rs (multi-threaded) |
533
- | Indexer (fallback) | tree-sitter + tree-sitter-typescript |
534
- | MCP SDK | @modelcontextprotocol/sdk |
535
- | Validation | Zod schemas for all payloads |
536
- | Transports | stdio (agents) · HTTP (dev/network) |
537
-
538
- <br/>
539
-
540
- ---
541
-
542
- <br/>
543
-
544
- ## Documentation
545
-
546
- | Document | Description |
547
- |:---------|:------------|
548
- | [Getting Started](./docs/getting-started.md) | Installation, 5-minute setup, MCP client config |
549
- | [MCP Tools Reference](./docs/mcp-tools-detailed.md) | Detailed docs for all 29 tools (parameters, responses, examples) |
550
- | [CLI Reference](./docs/cli-reference.md) | All CLI commands and options |
551
- | [Configuration Reference](./docs/configuration-reference.md) | Every config option with defaults and guidance |
552
- | [Agent Workflows](./docs/agent-workflows.md) | Workflow instructions for CLAUDE.md / AGENTS.md |
553
- | [Architecture](./docs/ARCHITECTURE.md) | Tech stack, data flow, component diagram |
554
- | [Iris Gate Ladder](./docs/IRIS_GATE_LADDER.md) | Context escalation methodology |
555
- | [Troubleshooting](./docs/troubleshooting.md) | Common issues and fixes |
556
-
557
- ### Feature Deep Dives
558
-
559
- | Topic | What You'll Learn |
560
- |:------|:------------------|
561
- | [Iris Gate Ladder](./docs/feature-deep-dives/iris-gate-ladder.md) | Four-rung context escalation with token savings analysis |
562
- | [Graph Slicing](./docs/feature-deep-dives/graph-slicing.md) | BFS/beam search, edge weights, wire formats, auto-discovery |
563
- | [Delta & Blast Radius](./docs/feature-deep-dives/delta-blast-radius.md) | Semantic diffs, ranked impact analysis, PR risk scoring |
564
- | [Live Indexing](./docs/feature-deep-dives/live-indexing.md) | Real-time editor buffer integration and overlay architecture |
565
- | [Governance & Policy](./docs/feature-deep-dives/governance-policy.md) | Proof-of-need gating, audit logging, runtime sandboxing |
566
- | [Agent Orchestration](./docs/feature-deep-dives/agent-orchestration.md) | Autopilot mode, feedback loops, portable context summaries |
567
- | [Indexing & Languages](./docs/feature-deep-dives/indexing-languages.md) | Rust/TS engines, two-pass architecture, 12-language support |
568
- | [Runtime Execution](./docs/feature-deep-dives/runtime-execution.md) | Sandboxed subprocess execution with governance |
569
- | [CLI Tool Access](./docs/feature-deep-dives/cli-tool-access.md) | Direct CLI access to all 29 actions, output formats, stdin piping, scripting |
570
- | [Tool Gateway](./docs/feature-deep-dives/tool-gateway.md) | 29→4 tool consolidation, 81% token reduction, thin schemas, migration guide |
571
- | [Semantic Engine](./docs/feature-deep-dives/semantic-engine.md) | Pass-2 call resolution, embedding search, LLM summaries, confidence scoring |
572
- | [Semantic Embeddings Setup](./docs/feature-deep-dives/semantic-embeddings-setup.md) | Dependencies, model installation, provider configuration, tier-by-tier setup |
573
- | [Development Memories](./docs/feature-deep-dives/development-memories.md) | Graph-backed cross-session memory, file sync, staleness detection, auto-surfacing |
574
-
575
- <br/>
576
-
577
- ---
578
-
579
- <br/>
580
-
581
- ## License
582
-
583
- This project is **source-available**.
584
-
585
- - **Free Use (Community License):** You may use, run, and modify this software for any purpose, including **internal business use**, under the terms in [`LICENSE`](./LICENSE).
586
- - **Commercial Distribution / Embedding:** You must obtain a **commercial license** before you **sell, license, sublicense, bundle, embed, or distribute** this software as part of a for-sale or monetized product. See [`COMMERCIAL_LICENSE.md`](./COMMERCIAL_LICENSE.md).
587
-
588
- Questions? Contact **gmullins.gkc@gmail.com**.
1
+ <div align="center">
2
+ <img src="https://github.com/GlitterKill/sdl-mcp/blob/main/docs/Symbol_Delta_Ledger_MCP.jpg" alt="Symbol Delta Ledger MCP">
3
+
4
+ <br/>
5
+
6
+ # SDL-MCP
7
+
8
+ ### **Cards-first code context for AI coding agents**
9
+
10
+ *Stop feeding entire files into the context window.<br/>Start giving agents exactly the code intelligence they need.*
11
+
12
+ <br/>
13
+
14
+ ![npm version](https://img.shields.io/npm/v/sdl-mcp.svg?style=for-the-badge)
15
+ ![npm downloads](https://img.shields.io/npm/dm/sdl-mcp.svg?style=for-the-badge)
16
+ ![GitHub commit activity](https://img.shields.io/github/commit-activity/w/GlitterKill/sdl-mcp?style=for-the-badge)
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ <br/>
23
+
24
+ ## What's the problem?
25
+
26
+ Every time an AI coding agent reads a file to answer a question, it consumes thousands of tokens. Most of those tokens are irrelevant to the task. The agent doesn't need 500 lines of a file to know that `validateToken` takes a `string` and returns a `Promise<User>` — but it reads them anyway, because that's all it has.
27
+
28
+ **Multiply that across a debugging session touching 20 files and you've burned 40,000+ tokens on context gathering alone.**
29
+
30
+ SDL-MCP fixes this. It indexes your codebase into a searchable **symbol graph** and serves precisely the right amount of context through a controlled escalation path. An agent that uses SDL-MCP understands your code better while consuming a fraction of the tokens.
31
+
32
+ <br/>
33
+
34
+ ---
35
+
36
+ <br/>
37
+
38
+ ## How it works — in 30 seconds
39
+
40
+ ```
41
+ Your Codebase
42
+
43
+ ┌──────┴──────┐
44
+ │ Indexer │ Native Rust (fast) or Tree-sitter (universal)
45
+ │ 12 langs │ TS · JS · Python · Go · Java · C# · C · C++ · PHP · Rust · Kotlin · Shell
46
+ └──────┬──────┘
47
+
48
+
49
+ ┌───────────────────────┐
50
+ │ Symbol Graph (DB) │ Functions, classes, interfaces, types, edges, metrics
51
+ │ LadybugDB (graph) │ Persisted. Incremental. Versioned.
52
+ └───────────┬───────────┘
53
+
54
+ ┌──────────┼──────────┐
55
+ │ │ │
56
+ ▼ ▼ ▼
57
+ 29 MCP 10 CLI HTTP API
58
+ Tools Commands + Graph UI
59
+
60
+
61
+ AI Coding Agent
62
+ (Claude Code, Claude Desktop, Cursor, Windsurf, any MCP client)
63
+ ```
64
+
65
+ 1. **Index once** — SDL-MCP parses every symbol in your repo and stores it as a compact metadata record (a "Symbol Card") in a graph database
66
+ 2. **Query efficiently** — Agents use MCP tools to search, slice, and retrieve exactly the context they need
67
+ 3. **Escalate only when necessary** — A four-rung ladder controls how much code the agent sees, from a 100-token card to full source (with justification required)
68
+
69
+ <br/>
70
+
71
+ ---
72
+
73
+ <br/>
74
+
75
+ ## Quick Start
76
+
77
+ ```bash
78
+ # Install
79
+ npm install -g sdl-mcp
80
+
81
+ # Initialize, auto-detect languages, index your repo, and run health checks
82
+ sdl-mcp init -y --auto-index
83
+
84
+ # Start the MCP server for your coding agent
85
+ sdl-mcp serve --stdio
86
+ ```
87
+
88
+ Point your MCP client at the server and the agent gains access to all SDL-MCP tools. That's it.
89
+
90
+ > **npx users:** Replace `sdl-mcp` with `npx --yes sdl-mcp@latest` in all commands above.
91
+
92
+ [Full Getting Started Guide →](./docs/getting-started.md)
93
+
94
+ <br/>
95
+
96
+ ---
97
+
98
+ <br/>
99
+
100
+ ## The Iris Gate Ladder
101
+
102
+ The core innovation. Named after the adjustable aperture that controls light flow in optics, the Iris Gate Ladder lets agents dial their context "aperture" from a pinhole to wide-open.
103
+
104
+ ```
105
+ Token Cost What the Agent Sees
106
+ ────────────────────────────────────────────────
107
+ ~100 RUNG 1 ▸ Symbol Card
108
+ Name, signature, summary, dependencies, metrics
109
+ "What does this function do and what does it call?"
110
+
111
+ ~300 RUNG 2 ▸ Skeleton IR
112
+ Signatures + control flow, bodies replaced with /* ... */
113
+ "What's the shape of this class?"
114
+
115
+ ~600 RUNG 3 ▸ Hot-Path Excerpt
116
+ Only lines matching specific identifiers + context
117
+ "Where exactly is `this.cache` initialized?"
118
+
119
+ ~2,000 RUNG 4 ▸ Raw Code Window Policy-gated
120
+ Full source code, requires justification
121
+ "I need to rewrite this error handler"
122
+ ```
123
+
124
+ > **Most questions are answered at Rungs 1-2** without ever reading raw code. That's where the token savings come from.
125
+
126
+ | Scenario | Reading the file | Using the Ladder | Savings |
127
+ |:---------|:----------------:|:----------------:|:-------:|
128
+ | "What does `parseConfig` accept?" | ~2,000 tok | ~100 tok | **20x** |
129
+ | "Show me the shape of `AuthService`" | ~4,000 tok | ~300 tok | **13x** |
130
+ | "Where is `this.cache` set?" | ~2,000 tok | ~500 tok | **4x** |
131
+
132
+ **Why it matters:**
133
+ - **4–20x token savings** on typical code understanding queries
134
+ - Most questions answered at Rungs 1–2 without ever reading raw code
135
+ - Controlled escalation prevents agents from over-consuming context
136
+ - Policy-gated raw access ensures agents prove they need full source
137
+
138
+ [Iris Gate Ladder Deep Dive →](./docs/feature-deep-dives/iris-gate-ladder.md)
139
+
140
+ <br/>
141
+
142
+ ---
143
+
144
+ <br/>
145
+
146
+ ## Feature Tour
147
+
148
+ ### Symbol Cards — The Atoms of Understanding
149
+
150
+ Every function, class, interface, type, and variable becomes a **Symbol Card**: a compact metadata record (~100 tokens) containing everything an agent needs to *understand* a symbol without reading its code.
151
+
152
+ ```
153
+ ┌─────────────────────────────────────────────────────────┐
154
+ │ Symbol Card: validateToken │
155
+ │─────────────────────────────────────────────────────────│
156
+ │ Kind: function (exported) │
157
+ │ File: src/auth/jwt.ts:42-67 │
158
+ │ Signature: (token: string, opts?: ValidateOpts) │
159
+ │ → Promise<DecodedToken> │
160
+ │ Summary: Validates JWT signature and expiration, │
161
+ │ returns decoded payload or throws │
162
+ │ Invariants: ["throws on expired token"] │
163
+ │ Side FX: ["logs to audit trail"] │
164
+ │ Deps: calls: [verifySignature, checkExpiry] │
165
+ │ imports: [jsonwebtoken, AuditLogger] │
166
+ │ Metrics: fan-in: 12 │ fan-out: 4 │ churn: 3/30d │
167
+ │ Cluster: auth-module (8 members) │
168
+ │ Process: request-pipeline (intermediate, depth 1) │
169
+ │ Test: auth.test.ts (distance: 1, proximity: 0.9)│
170
+ │ ETag: a7f3c2... (for conditional requests) │
171
+ └─────────────────────────────────────────────────────────┘
172
+ ```
173
+
174
+ Cards include **confidence-scored call resolution** (the pass-2 resolver traces imports, aliases, barrel re-exports, and tagged templates to produce accurate dependency edges), **community detection** (cluster membership), and **call-chain tracing** (process participation with entry/intermediate/exit roles).
175
+
176
+ **Why it matters:**
177
+ - **~100 tokens per symbol** vs. ~2,000 tokens to read the full file
178
+ - Confidence-scored dependency edges trace real call relationships across files
179
+ - Community detection and call-chain tracing reveal architectural structure
180
+ - ETag-based conditional requests avoid re-fetching unchanged symbols
181
+
182
+ [Indexing & Language Support Deep Dive →](./docs/feature-deep-dives/indexing-languages.md)
183
+
184
+ ---
185
+
186
+ ### Graph Slicing — The Right Context for Every Task
187
+
188
+ Instead of reading files in the same directory, SDL-MCP follows the *dependency graph*. Starting from symbols relevant to your task, it traverses weighted edges (call: 1.0, config: 0.8, import: 0.6), scores each symbol by relevance, and returns the N most important within a token budget.
189
+
190
+ ```
191
+ "Fix the auth middleware" → slice.build
192
+
193
+ BFS over graph
194
+
195
+ ┌──────────────────┼──────────────────┐
196
+ ▼ ▼ ▼
197
+ authenticate validateToken JwtConfig
198
+ │ │ │
199
+ ▼ ▼ ▼
200
+ hashPassword getUserById envLoader
201
+
202
+ ◆ frontier
203
+ (outside budget)
204
+
205
+ 8 cards returned · ~800 tokens
206
+ vs. reading 8 files · ~16,000 tokens
207
+ ```
208
+
209
+ Slices have handles, leases, refresh (delta-only updates), and spillover (paged overflow). You can also skip the symbol search entirely — pass a `taskText` string and SDL-MCP auto-discovers the relevant entry symbols.
210
+
211
+ **Why it matters:**
212
+ - Follows the **dependency graph**, not directory boundaries, for cross-cutting context
213
+ - Weighted edge scoring (call > config > import) prioritizes the most relevant symbols
214
+ - Token-budgeted: returns only what fits within your budget (~800 tokens vs. ~16,000 for raw files)
215
+ - Natural-language task-text auto-discovers entry symbols — no symbol IDs needed
216
+
217
+ [Graph Slicing Deep Dive →](./docs/feature-deep-dives/graph-slicing.md)
218
+
219
+ ---
220
+
221
+ ### Delta Packs & Blast Radius — Semantic Change Intelligence
222
+
223
+ `git diff` tells you what lines changed. SDL-MCP tells you what that change *means* and who's affected.
224
+
225
+ ```
226
+ Modified: validateToken() signature
227
+
228
+ ├── signatureDiff: added `options?: object` parameter
229
+ ├── invariantDiff: added "throws on expired"
230
+ └── sideEffectDiff: added "logs to audit trail"
231
+
232
+
233
+ Blast Radius (ranked):
234
+ 1. authenticate() ← direct caller, distance 1
235
+ 2. refreshSession() ← direct caller, distance 1
236
+ 3. AuthMiddleware ← calls authenticate, distance 2
237
+ 4. auth.test.ts ← test coverage, flagged for re-run
238
+ ```
239
+
240
+ **PR risk analysis** (`sdl.pr.risk.analyze`) wraps this into a scored assessment with findings, evidence, and test recommendations. **Fan-in trend analysis** detects "amplifier" symbols whose growing dependency count means changes ripple further over time.
241
+
242
+ **Why it matters:**
243
+ - Semantic diffs show what a change **means**, not just what lines moved
244
+ - Ranked blast radius identifies which dependent symbols are most at risk
245
+ - Fan-in trend analysis detects "amplifier" symbols whose changes ripple further over time
246
+ - PR risk scoring produces actionable findings with test re-run recommendations
247
+
248
+ [Delta & Blast Radius Deep Dive →](./docs/feature-deep-dives/delta-blast-radius.md)
249
+
250
+ ---
251
+
252
+ ### Live Indexing — Real-Time Code Intelligence
253
+
254
+ SDL-MCP doesn't wait for you to save. As you type in your editor, buffer updates are pushed to an in-memory overlay store, parsed in the background, and merged with the durable database. Search, cards, and slices reflect your *current* code, not your last save.
255
+
256
+ ```
257
+ Editor keystrokes → sdl.buffer.push → Overlay Store → merged reads
258
+
259
+ on save / idle
260
+
261
+
262
+ LadybugDB (durable)
263
+ ```
264
+
265
+ **Why it matters:**
266
+ - Search, cards, and slices reflect **unsaved editor changes** in real time
267
+ - No manual re-index needed during active development
268
+ - Background AST parsing with in-memory overlay keeps queries fast
269
+
270
+ [Live Indexing Deep Dive →](./docs/feature-deep-dives/live-indexing.md)
271
+
272
+ ---
273
+
274
+ ### Governance & Policy — Controlled Access
275
+
276
+ Raw code access (Rung 4) is **policy-gated**. Agents must provide:
277
+ - A **reason** explaining why they need raw code
278
+ - **Identifiers** they expect to find in the code
279
+ - An **expected line count** within configured limits
280
+
281
+ Requests that don't meet policy are denied with actionable guidance ("try `getHotPath` with these identifiers instead"). Every access is audit-logged.
282
+
283
+ The sandboxed runtime execution tool (`sdl.runtime.execute`) has its own governance layer: disabled by default, executable allowlisting, CWD jailing, environment scrubbing, concurrency limits, and timeout enforcement.
284
+
285
+ **Why it matters:**
286
+ - Proof-of-need gating prevents agents from wastefully reading raw code
287
+ - Denied requests include **actionable next-best-action** guidance
288
+ - Full audit logging of every code access decision
289
+ - Sandboxed runtime with executable allowlisting, CWD jailing, and environment scrubbing
290
+
291
+ [Governance & Policy Deep Dive →](./docs/feature-deep-dives/governance-policy.md)
292
+
293
+ ---
294
+
295
+ ### Agent Orchestration — Autopilot Mode
296
+
297
+ `sdl.agent.orchestrate` is an autonomous task engine. Give it a task type (`debug`, `review`, `implement`, `explain`), a description, and a budget — it plans the optimal Iris Gate path, executes it, collects evidence, and returns a synthesized answer.
298
+
299
+ The feedback loop (`sdl.agent.feedback`) records which symbols were useful and which were missing, improving future slice quality.
300
+
301
+ `sdl.context.summary` generates portable, token-bounded context briefings in markdown, JSON, or clipboard format for use outside MCP environments.
302
+
303
+ **Why it matters:**
304
+ - Autonomous task execution plans the **optimal Iris Gate path** within a token budget
305
+ - Feedback loop records what was useful/missing, improving future slice quality
306
+ - Portable context summaries export findings for use outside MCP environments
307
+
308
+ [Agent Orchestration Deep Dive →](./docs/feature-deep-dives/agent-orchestration.md)
309
+
310
+ ---
311
+
312
+ ### Sandboxed Runtime Execution
313
+
314
+ Run tests, linters, and scripts through SDL-MCP's governance layer instead of uncontrolled shell access. Three runtimes (Node.js, Python, Shell), code-mode or args-mode, smart output summarization with keyword-matched excerpts, and gzip artifact persistence.
315
+
316
+ **Why it matters:**
317
+ - Run tests, linters, and scripts **under governance** instead of uncontrolled shell access
318
+ - 16 runtimes supported (Node, Python, Go, Java, Rust, Shell, and more)
319
+ - Executable allowlisting, CWD jailing, timeout enforcement, and environment scrubbing
320
+ - Smart output summarization with keyword-matched excerpts and gzip artifact persistence
321
+
322
+ [Runtime Execution Deep Dive →](./docs/feature-deep-dives/runtime-execution.md)
323
+
324
+ ---
325
+
326
+ ### Development Memories — Cross-Session Knowledge Persistence
327
+
328
+ Agents forget everything between sessions. SDL-MCP fixes this with a **graph-backed memory system** that lets agents store decisions, bugfix context, and task notes linked directly to the symbols and files they relate to. Memories are stored both in the graph database (for fast querying) and as checked-in markdown files (for version control and team sharing).
329
+
330
+ ```
331
+ Agent Session 1 Agent Session 2
332
+ ───────────── ─────────────
333
+ "Fixed race condition in sdl.memory.surface
334
+ authenticate() — added mutex" │
335
+ │ ┌────┴─────┐
336
+ ▼ │ Relevant │
337
+ sdl.memory.store │ memories │
338
+ │ │ surfaced │
339
+ ├──▶ Graph DB (Memory node) └────┬─────┘
340
+ │ ├── MEMORY_OF ──▶ authenticate() │
341
+ │ └── HAS_MEMORY ◀── Repo ▼
342
+ │ "Previous fix: race condition
343
+ └──▶ .sdl-memory/bugfixes/a1b2c3.md in authenticate() — mutex added"
344
+ (YAML frontmatter + markdown)
345
+ ```
346
+
347
+ Memories are **automatically surfaced** inside graph slices — when an agent builds a slice touching symbols with linked memories, those memories appear alongside the cards. During re-indexing, memories linked to changed symbols are **flagged as stale**, prompting agents to review and update them. Four MCP tools (`store`, `query`, `remove`, `surface`) provide full CRUD plus intelligent ranking by confidence, recency, and symbol overlap.
348
+
349
+ **Why it matters:**
350
+ - Structured knowledge **persists across sessions**, linked directly to symbols and files
351
+ - Automatically surfaced inside graph slices when touching related symbols
352
+ - Stale memories flagged when linked symbols change during re-indexing
353
+ - Dual storage: graph DB for fast querying + markdown files for version control and team sharing
354
+
355
+ [Development Memories Deep Dive →](./docs/feature-deep-dives/development-memories.md)
356
+
357
+ ---
358
+
359
+ ### CLI Tool Access — No MCP Server Required
360
+
361
+ Access all 29 tool actions directly from the command line with `sdl-mcp tool`. No MCP server, transport, or SDK — just your terminal.
362
+
363
+ ```bash
364
+ # Search for symbols
365
+ sdl-mcp tool symbol.search --query "handleAuth" --output-format pretty
366
+
367
+ # Build a task-scoped slice
368
+ sdl-mcp tool slice.build --task-text "debug auth flow" --max-cards 50
369
+
370
+ # Pipe JSON args, chain commands
371
+ echo '{"repoId":"my-repo"}' | sdl-mcp tool symbol.search --query "auth"
372
+ ```
373
+
374
+ Features include typed argument coercion (string, number, boolean, string[], json), budget flag merging, stdin JSON piping with CLI-flags-win precedence, auto-resolved `repoId` from cwd, four output formats (json, json-compact, pretty, table), typo suggestions, and per-action `--help`. The CLI dispatches through the same gateway router and Zod schemas as the MCP server — identical code paths, identical validation.
375
+
376
+ **Why it matters:**
377
+ - All MCP tool actions accessible from **any terminal** — no server, transport, or SDK required
378
+ - Same code paths and Zod validation as the MCP server — identical behavior
379
+ - Four output formats (json, json-compact, pretty, table) for scripting and CI pipelines
380
+ - Auto-resolves repoId from cwd, supports stdin JSON piping and per-action `--help`
381
+
382
+ [CLI Tool Access Deep Dive →](./docs/feature-deep-dives/cli-tool-access.md)
383
+
384
+ ---
385
+
386
+ ### Tool Gateway — 81% Token Reduction
387
+
388
+ The tool gateway consolidates all 29 MCP tools into **4 namespace-scoped tools** (`sdl.query`, `sdl.code`, `sdl.repo`, `sdl.agent`), reducing `tools/list` overhead from **~3,742 tokens to ~713 tokens** — an **81% reduction**.
389
+
390
+ ```
391
+ Before: 29 tools × full JSON Schema = ~3,742 tokens at conversation start
392
+ After: 4 tools × thin schema = ~713 tokens at conversation start
393
+ ─────────────
394
+ ~3,029 tokens saved per conversation
395
+ ```
396
+
397
+ Each gateway tool accepts an `action` discriminator field (e.g., `{ action: "symbol.search", repoId: "x", query: "auth" }`) and routes to the same handlers with double Zod validation. Thin wire schemas in `tools/list` keep the registration compact while full validation happens server-side. Legacy flat tool names are optionally emitted alongside for backward compatibility.
398
+
399
+ **Why it matters:**
400
+ - **81% token reduction** in `tools/list` overhead (~3,742 → ~713 tokens per conversation)
401
+ - 29 tools consolidated into 4 namespace-scoped tools for simpler agent selection
402
+ - Fewer tool choices means faster and more accurate tool dispatch by the agent
403
+ - Backward-compatible: legacy flat tool names optionally emitted alongside
404
+
405
+ [Tool Gateway Deep Dive →](./docs/feature-deep-dives/tool-gateway.md)
406
+
407
+ <br/>
408
+
409
+ ---
410
+
411
+ <br/>
412
+
413
+ ## All 29 MCP Tools at a Glance
414
+
415
+ <table>
416
+ <tr><th>Category</th><th>Tool</th><th>One-Line Description</th></tr>
417
+ <tr><td rowspan="4"><strong>Repository</strong></td>
418
+ <td><code>sdl.repo.register</code></td><td>Register a codebase for indexing</td></tr>
419
+ <tr><td><code>sdl.repo.status</code></td><td>Health, versions, watcher, prefetch, live-index stats</td></tr>
420
+ <tr><td><code>sdl.repo.overview</code></td><td>Codebase summary: stats, directories, hotspots, clusters</td></tr>
421
+ <tr><td><code>sdl.index.refresh</code></td><td>Trigger full or incremental re-indexing</td></tr>
422
+
423
+ <tr><td rowspan="3"><strong>Live Buffer</strong></td>
424
+ <td><code>sdl.buffer.push</code></td><td>Push unsaved editor content for real-time indexing</td></tr>
425
+ <tr><td><code>sdl.buffer.checkpoint</code></td><td>Force-write pending buffers to the durable database</td></tr>
426
+ <tr><td><code>sdl.buffer.status</code></td><td>Live indexing diagnostics and queue depth</td></tr>
427
+
428
+ <tr><td rowspan="3"><strong>Symbols</strong></td>
429
+ <td><code>sdl.symbol.search</code></td><td>Search symbols by name (with optional semantic reranking)</td></tr>
430
+ <tr><td><code>sdl.symbol.getCard</code></td><td>Get a symbol card with ETag-based conditional support</td></tr>
431
+ <tr><td><code>sdl.symbol.getCards</code></td><td>Batch-fetch up to 100 cards in one round trip</td></tr>
432
+
433
+ <tr><td rowspan="3"><strong>Slices</strong></td>
434
+ <td><code>sdl.slice.build</code></td><td>Build a task-scoped dependency subgraph</td></tr>
435
+ <tr><td><code>sdl.slice.refresh</code></td><td>Delta-only update of an existing slice</td></tr>
436
+ <tr><td><code>sdl.slice.spillover.get</code></td><td>Page through overflow symbols beyond the budget</td></tr>
437
+
438
+ <tr><td rowspan="3"><strong>Code Access</strong></td>
439
+ <td><code>sdl.code.getSkeleton</code></td><td>Signatures + control flow, bodies elided</td></tr>
440
+ <tr><td><code>sdl.code.getHotPath</code></td><td>Lines matching specific identifiers + context</td></tr>
441
+ <tr><td><code>sdl.code.needWindow</code></td><td>Full source code (policy-gated, requires justification)</td></tr>
442
+
443
+ <tr><td><strong>Deltas</strong></td>
444
+ <td><code>sdl.delta.get</code></td><td>Semantic diff + blast radius between versions</td></tr>
445
+
446
+ <tr><td rowspan="2"><strong>Policy</strong></td>
447
+ <td><code>sdl.policy.get</code></td><td>Read current gating policy</td></tr>
448
+ <tr><td><code>sdl.policy.set</code></td><td>Update line/token limits and identifier requirements</td></tr>
449
+
450
+ <tr><td><strong>Risk</strong></td>
451
+ <td><code>sdl.pr.risk.analyze</code></td><td>Scored PR risk with findings and test recommendations</td></tr>
452
+
453
+ <tr><td><strong>Context</strong></td>
454
+ <td><code>sdl.context.summary</code></td><td>Token-bounded portable briefing (markdown/JSON/clipboard)</td></tr>
455
+
456
+ <tr><td rowspan="3"><strong>Agent</strong></td>
457
+ <td><code>sdl.agent.orchestrate</code></td><td>Autonomous task execution with budget control</td></tr>
458
+ <tr><td><code>sdl.agent.feedback</code></td><td>Record which symbols were useful or missing</td></tr>
459
+ <tr><td><code>sdl.agent.feedback.query</code></td><td>Query aggregated feedback statistics</td></tr>
460
+
461
+ <tr><td><strong>Runtime</strong></td>
462
+ <td><code>sdl.runtime.execute</code></td><td>Sandboxed subprocess execution (Node/Python/Shell)</td></tr>
463
+
464
+ <tr><td rowspan="4"><strong>Memory</strong></td>
465
+ <td><code>sdl.memory.store</code></td><td>Store or update a development memory with symbol/file links</td></tr>
466
+ <tr><td><code>sdl.memory.query</code></td><td>Search memories by text, type, tags, or linked symbols</td></tr>
467
+ <tr><td><code>sdl.memory.remove</code></td><td>Soft-delete a memory from graph and optionally from disk</td></tr>
468
+ <tr><td><code>sdl.memory.surface</code></td><td>Auto-surface relevant memories for a task context</td></tr>
469
+ </table>
470
+
471
+ [Complete MCP Tools Reference (detailed parameters & responses) →](./docs/mcp-tools-detailed.md)
472
+
473
+ <br/>
474
+
475
+ ---
476
+
477
+ <br/>
478
+
479
+ ## CLI Commands
480
+
481
+ | Command | Description |
482
+ |:--------|:------------|
483
+ | `sdl-mcp init` | Bootstrap config, detect repo/languages, optionally auto-index |
484
+ | `sdl-mcp doctor` | Validate runtime, config, DB, grammars, repo access |
485
+ | `sdl-mcp index` | Index repositories (with optional `--watch` mode) |
486
+ | `sdl-mcp serve` | Start MCP server (`--stdio` or `--http`) |
487
+ | `sdl-mcp tool` | Access all 25 MCP tool actions directly ([docs](./docs/feature-deep-dives/cli-tool-access.md)) |
488
+ | `sdl-mcp summary` | Generate copy/paste context summaries from the CLI |
489
+ | `sdl-mcp health` | Compute composite health score with badge/JSON output |
490
+ | `sdl-mcp export` | Export sync artifact |
491
+ | `sdl-mcp import` | Import sync artifact |
492
+ | `sdl-mcp pull` | Pull by version/commit with fallback |
493
+ | `sdl-mcp version` | Show version and environment info |
494
+
495
+ [CLI Reference →](./docs/cli-reference.md) · [Configuration Reference →](./docs/configuration-reference.md)
496
+
497
+ <br/>
498
+
499
+ ---
500
+
501
+ <br/>
502
+
503
+ ## Compatible With
504
+
505
+ SDL-MCP works with any MCP-compatible client:
506
+
507
+ | Client | Transport | Setup |
508
+ |:-------|:----------|:------|
509
+ | **Claude Code** | stdio | `sdl-mcp init --client claude-code` |
510
+ | **Claude Desktop** | stdio | `sdl-mcp init --client claude-code` |
511
+ | **Cursor** | stdio | Standard MCP server config |
512
+ | **Windsurf** | stdio | Standard MCP server config |
513
+ | **Codex CLI** | stdio | `sdl-mcp init --client codex` |
514
+ | **Gemini CLI** | stdio | `sdl-mcp init --client gemini` |
515
+ | **OpenCode** | stdio | `sdl-mcp init --client opencode` |
516
+ | **Any MCP client** | stdio / http | `sdl-mcp serve --stdio` or `--http` |
517
+
518
+ A **VSCode extension** (`sdl-mcp-vscode/`) provides live buffer integration for real-time indexing of unsaved edits.
519
+
520
+ <br/>
521
+
522
+ ---
523
+
524
+ <br/>
525
+
526
+ ## Tech Stack
527
+
528
+ | Component | Technology |
529
+ |:----------|:-----------|
530
+ | Runtime | Node.js 20+ / TypeScript 5.9+ (strict ESM) |
531
+ | Graph Database | LadybugDB (embedded, single-file) |
532
+ | Indexer (default) | Rust via napi-rs (multi-threaded) |
533
+ | Indexer (fallback) | tree-sitter + tree-sitter-typescript |
534
+ | MCP SDK | @modelcontextprotocol/sdk |
535
+ | Validation | Zod schemas for all payloads |
536
+ | Transports | stdio (agents) · HTTP (dev/network) |
537
+
538
+ <br/>
539
+
540
+ ---
541
+
542
+ <br/>
543
+
544
+ ## Documentation
545
+
546
+ | Document | Description |
547
+ |:---------|:------------|
548
+ | [Getting Started](./docs/getting-started.md) | Installation, 5-minute setup, MCP client config |
549
+ | [MCP Tools Reference](./docs/mcp-tools-detailed.md) | Detailed docs for all 29 tools (parameters, responses, examples) |
550
+ | [CLI Reference](./docs/cli-reference.md) | All CLI commands and options |
551
+ | [Configuration Reference](./docs/configuration-reference.md) | Every config option with defaults and guidance |
552
+ | [Agent Workflows](./docs/agent-workflows.md) | Workflow instructions for CLAUDE.md / AGENTS.md |
553
+ | [Architecture](./docs/ARCHITECTURE.md) | Tech stack, data flow, component diagram |
554
+ | [Iris Gate Ladder](./docs/IRIS_GATE_LADDER.md) | Context escalation methodology |
555
+ | [Troubleshooting](./docs/troubleshooting.md) | Common issues and fixes |
556
+
557
+ ### Feature Deep Dives
558
+
559
+ | Topic | What You'll Learn |
560
+ |:------|:------------------|
561
+ | [Iris Gate Ladder](./docs/feature-deep-dives/iris-gate-ladder.md) | Four-rung context escalation with token savings analysis |
562
+ | [Graph Slicing](./docs/feature-deep-dives/graph-slicing.md) | BFS/beam search, edge weights, wire formats, auto-discovery |
563
+ | [Delta & Blast Radius](./docs/feature-deep-dives/delta-blast-radius.md) | Semantic diffs, ranked impact analysis, PR risk scoring |
564
+ | [Live Indexing](./docs/feature-deep-dives/live-indexing.md) | Real-time editor buffer integration and overlay architecture |
565
+ | [Governance & Policy](./docs/feature-deep-dives/governance-policy.md) | Proof-of-need gating, audit logging, runtime sandboxing |
566
+ | [Agent Orchestration](./docs/feature-deep-dives/agent-orchestration.md) | Autopilot mode, feedback loops, portable context summaries |
567
+ | [Indexing & Languages](./docs/feature-deep-dives/indexing-languages.md) | Rust/TS engines, two-pass architecture, 12-language support |
568
+ | [Runtime Execution](./docs/feature-deep-dives/runtime-execution.md) | Sandboxed subprocess execution with governance |
569
+ | [CLI Tool Access](./docs/feature-deep-dives/cli-tool-access.md) | Direct CLI access to all 29 actions, output formats, stdin piping, scripting |
570
+ | [Tool Gateway](./docs/feature-deep-dives/tool-gateway.md) | 29→4 tool consolidation, 81% token reduction, thin schemas, migration guide |
571
+ | [Semantic Engine](./docs/feature-deep-dives/semantic-engine.md) | Pass-2 call resolution, embedding search, LLM summaries, confidence scoring |
572
+ | [Semantic Embeddings Setup](./docs/feature-deep-dives/semantic-embeddings-setup.md) | Dependencies, model installation, provider configuration, tier-by-tier setup |
573
+ | [Development Memories](./docs/feature-deep-dives/development-memories.md) | Graph-backed cross-session memory, file sync, staleness detection, auto-surfacing |
574
+
575
+ <br/>
576
+
577
+ ---
578
+
579
+ <br/>
580
+
581
+ ## License
582
+
583
+ This project is **source-available**.
584
+
585
+ - **Free Use (Community License):** You may use, run, and modify this software for any purpose, including **internal business use**, under the terms in [`LICENSE`](./LICENSE).
586
+ - **Commercial Distribution / Embedding:** You must obtain a **commercial license** before you **sell, license, sublicense, bundle, embed, or distribute** this software as part of a for-sale or monetized product. See [`COMMERCIAL_LICENSE.md`](./COMMERCIAL_LICENSE.md).
587
+
588
+ Questions? Contact **gmullins.gkc@gmail.com**.