neuronlayer 0.2.6 → 0.2.8

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.
@@ -0,0 +1,504 @@
1
+ # MemoryLayer + Claude Code Setup Guide
2
+
3
+ This guide explains how to configure MemoryLayer as an MCP server for [Claude Code](https://code.claude.com/) (Anthropic's CLI tool).
4
+
5
+ ---
6
+
7
+ ## Prerequisites
8
+
9
+ 1. **Node.js 18+** installed
10
+ 2. **Claude Code** installed (`npm install -g @anthropic-ai/claude-code`)
11
+ 3. **MemoryLayer** built (`npm run build`)
12
+
13
+ ---
14
+
15
+ ## Quick Setup (Recommended)
16
+
17
+ The easiest and most reliable way to configure MemoryLayer for Claude Code is using our automated initialization command.
18
+
19
+ ### Step 1: Initialize MemoryLayer
20
+
21
+ Run this command in the root of your project:
22
+
23
+ ```bash
24
+ npx neuronlayer init .
25
+ ```
26
+
27
+ This will automatically configure `.mcp.json` in your project with the exact absolute paths and platform-specific commands required for Claude Code to connect smoothly to MemoryLayer.
28
+
29
+ ### Step 2: Verify Connection
30
+
31
+ Start Claude Code and check your servers:
32
+
33
+ ```bash
34
+ # Inside Claude Code
35
+ /mcp
36
+ ```
37
+
38
+ You should see:
39
+ ```
40
+ MCP Servers
41
+ neuronlayer (stdio)
42
+ Status: connected
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Configuration Methods (Advanced)
48
+
49
+ If you prefer not to use the automated `npx neuronlayer init` command, Claude Code provides several ways to configure MCP servers manually.
50
+
51
+ ### Method 1: CLI Commands
52
+
53
+ Claude Code provides CLI commands to manage MCP servers:
54
+
55
+ ```bash
56
+ # Add a server
57
+ claude mcp add --transport stdio neuronlayer -- node /absolute/path/to/dist/index.js --project .
58
+
59
+ # List all servers
60
+ claude mcp list
61
+
62
+ # Get server details
63
+ claude mcp get neuronlayer
64
+
65
+ # Remove a server
66
+ claude mcp remove neuronlayer
67
+ ```
68
+
69
+ **Note:** On Windows natively, you MUST wrap the node execution with `cmd /c` to prevent stdin/stdout hanging issues:
70
+ ```bash
71
+ claude mcp add --transport stdio neuronlayer -- cmd /c node C:\absolute\path\to\dist\index.js --project .
72
+ ```
73
+
74
+ ### Method 2: Project Configuration (`.mcp.json`)
75
+
76
+ If you want to create `.mcp.json` in your project root manually:
77
+
78
+ ```json
79
+ {
80
+ "mcpServers": {
81
+ "neuronlayer": {
82
+ "type": "stdio",
83
+ "command": "node",
84
+ "args": ["/absolute/path/to/memorylayer/dist/index.js", "--project", "."],
85
+ "env": {}
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ *For Windows, use `["cmd", "/c", "node", "C:\\absolute\\path\\to\\dist\\index.js", "--project", "."]` in the command and args fields as appropriate depending on your node integration.*
92
+
93
+ ---
94
+
95
+ ## Configuration Scopes
96
+
97
+ | Scope | Storage Location | Use Case |
98
+ |-------|------------------|----------|
99
+ | `local` (default) | `~/.claude.json` | Personal, current project only |
100
+ | `project` | `.mcp.json` | Shared with team via version control |
101
+ | `user` | `~/.claude.json` | Personal, available across all projects |
102
+
103
+ ```bash
104
+ # The automated init command uses Project scope by default
105
+ npx neuronlayer init .
106
+ ```
107
+
108
+ ---
109
+
110
+ ## Platform-Specific Setup
111
+
112
+ ### Windows (Native)
113
+
114
+ On native Windows (not WSL), use the `cmd /c` wrapper for proper execution:
115
+
116
+ ```bash
117
+ # Using CLI
118
+ claude mcp add --transport stdio memorylayer -- cmd /c node C:\path\to\memorylayer\dist\index.js --project .
119
+ ```
120
+
121
+ **In `.mcp.json`:**
122
+
123
+ ```json
124
+ {
125
+ "mcpServers": {
126
+ "memorylayer": {
127
+ "type": "stdio",
128
+ "command": "cmd",
129
+ "args": ["/c", "node", "C:\\path\\to\\memorylayer\\dist\\index.js", "--project", "."],
130
+ "env": {}
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ ### Windows (WSL)
137
+
138
+ WSL works like Linux:
139
+
140
+ ```bash
141
+ claude mcp add --transport stdio memorylayer -- node /path/to/memorylayer/dist/index.js --project .
142
+ ```
143
+
144
+ ### macOS / Linux
145
+
146
+ ```bash
147
+ claude mcp add --transport stdio memorylayer -- node /path/to/memorylayer/dist/index.js --project .
148
+ ```
149
+
150
+ **In `.mcp.json`:**
151
+
152
+ ```json
153
+ {
154
+ "mcpServers": {
155
+ "memorylayer": {
156
+ "type": "stdio",
157
+ "command": "node",
158
+ "args": ["/Users/you/memorylayer/dist/index.js", "--project", "."],
159
+ "env": {}
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ ---
166
+
167
+ ## After npm Publish
168
+
169
+ Once MemoryLayer is published to npm, setup becomes simpler:
170
+
171
+ ### CLI Command
172
+
173
+ ```bash
174
+ # Install globally
175
+ npm install -g memorylayer
176
+
177
+ # Add to Claude Code
178
+ claude mcp add --transport stdio memorylayer -- memorylayer --project .
179
+ ```
180
+
181
+ ### Using npx
182
+
183
+ ```bash
184
+ # Without installation
185
+ claude mcp add --transport stdio memorylayer -- npx -y memorylayer --project .
186
+ ```
187
+
188
+ **Windows (with npx):**
189
+
190
+ ```bash
191
+ claude mcp add --transport stdio memorylayer -- cmd /c npx -y memorylayer --project .
192
+ ```
193
+
194
+ ### Project `.mcp.json`
195
+
196
+ ```json
197
+ {
198
+ "mcpServers": {
199
+ "memorylayer": {
200
+ "type": "stdio",
201
+ "command": "npx",
202
+ "args": ["-y", "memorylayer", "--project", "."],
203
+ "env": {}
204
+ }
205
+ }
206
+ }
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Environment Variables
212
+
213
+ ### MemoryLayer Configuration
214
+
215
+ | Variable | Default | Description |
216
+ |----------|---------|-------------|
217
+ | `MEMORYLAYER_MAX_TOKENS` | 6000 | Maximum tokens for context assembly |
218
+ | `MEMORYLAYER_DEBUG` | false | Enable debug logging |
219
+
220
+ ```bash
221
+ claude mcp add --transport stdio \
222
+ --env MEMORYLAYER_MAX_TOKENS=8000 \
223
+ --env MEMORYLAYER_DEBUG=true \
224
+ memorylayer -- node dist/index.js --project .
225
+ ```
226
+
227
+ ### Claude Code MCP Settings
228
+
229
+ | Variable | Default | Description |
230
+ |----------|---------|-------------|
231
+ | `MCP_TIMEOUT` | 60000 | Server startup timeout (ms) |
232
+ | `MAX_MCP_OUTPUT_TOKENS` | 25000 | Max tokens from MCP tools |
233
+
234
+ ```bash
235
+ # Start Claude Code with custom MCP settings
236
+ MCP_TIMEOUT=120000 MAX_MCP_OUTPUT_TOKENS=50000 claude
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Available MCP Tools
242
+
243
+ Once connected, Claude Code can use these MemoryLayer tools:
244
+
245
+ ### Core Tools
246
+
247
+ | Tool | Description |
248
+ |------|-------------|
249
+ | `get_context` | Get relevant codebase context for a query |
250
+ | `search_codebase` | Semantic search across all files |
251
+ | `record_decision` | Save an architectural decision |
252
+ | `get_file_context` | Get content of a specific file |
253
+ | `get_project_summary` | Overview of project structure |
254
+
255
+ ### Symbol & Dependency Tools
256
+
257
+ | Tool | Description |
258
+ |------|-------------|
259
+ | `get_symbol` | Find functions, classes, types by name |
260
+ | `get_dependencies` | See imports/exports for a file |
261
+ | `get_file_summary` | Get compressed file summary (10x smaller) |
262
+
263
+ ### Living Documentation Tools
264
+
265
+ | Tool | Description |
266
+ |------|-------------|
267
+ | `generate_docs` | Generate documentation for a file or architecture |
268
+ | `get_architecture` | Get project architecture overview |
269
+ | `get_component_doc` | Get detailed documentation for a component |
270
+ | `get_changelog` | Get changelog of recent changes |
271
+ | `validate_docs` | Check for outdated docs |
272
+ | `what_happened` | Query recent project activity |
273
+
274
+ ### Context Health Tools
275
+
276
+ | Tool | Description |
277
+ |------|-------------|
278
+ | `get_context_health` | Check context health and drift score |
279
+ | `trigger_compaction` | Manually trigger context compaction |
280
+ | `mark_critical` | Mark content as critical (never compress) |
281
+
282
+ ### Confidence & Intelligence Tools
283
+
284
+ | Tool | Description |
285
+ |------|-------------|
286
+ | `get_confidence` | Get confidence score for code suggestion |
287
+ | `check_conflicts` | Check if code conflicts with past decisions |
288
+ | `what_changed` | Query what changed in the codebase |
289
+ | `why_broke` | Diagnose why something broke |
290
+ | `suggest_fix` | Get fix suggestions for an error |
291
+
292
+ ### Architecture Tools
293
+
294
+ | Tool | Description |
295
+ |------|-------------|
296
+ | `validate_pattern` | Validate code against established patterns |
297
+ | `suggest_existing` | Find existing functions that match intent |
298
+ | `learn_pattern` | Teach a new pattern to the system |
299
+ | `list_patterns` | List all learned patterns |
300
+
301
+ ### Test Awareness Tools
302
+
303
+ | Tool | Description |
304
+ |------|-------------|
305
+ | `get_related_tests` | Get tests related to a file or function |
306
+ | `check_tests` | Check if a code change would break tests |
307
+ | `suggest_test_update` | Get suggested test updates for a change |
308
+ | `get_test_coverage` | Get test coverage for a file |
309
+
310
+ ---
311
+
312
+ ## Example Usage
313
+
314
+ Once configured, try these prompts in Claude Code:
315
+
316
+ ```
317
+ > Search for authentication code in this project
318
+
319
+ > What architectural decisions have been made?
320
+
321
+ > Show me the project summary
322
+
323
+ > Find the function that handles user login
324
+
325
+ > What files import the database module?
326
+
327
+ > What changed in the last 24 hours?
328
+
329
+ > Why might the login test be failing?
330
+
331
+ > Record a decision: We chose SQLite for local storage because it's embedded and requires no separate server
332
+
333
+ > Get the architecture overview of this project
334
+
335
+ > Check if this code follows our patterns: async function fetchUser(id) { ... }
336
+ ```
337
+
338
+ ---
339
+
340
+ ## Troubleshooting
341
+
342
+ ### "Connection closed" on Windows
343
+
344
+ Ensure you're using the `cmd /c` wrapper:
345
+
346
+ ```bash
347
+ # Wrong
348
+ claude mcp add --transport stdio memorylayer -- node dist/index.js --project .
349
+
350
+ # Correct
351
+ claude mcp add --transport stdio memorylayer -- cmd /c node dist/index.js --project .
352
+ ```
353
+
354
+ ### "Server not found" or "ENOENT"
355
+
356
+ 1. Verify the path to `dist/index.js` is correct and absolute
357
+ 2. Ensure MemoryLayer is built: `npm run build`
358
+ 3. Check Node.js is in your PATH
359
+
360
+ ### "MCP server not connected"
361
+
362
+ 1. Run `claude mcp list` to check configuration
363
+ 2. Run `/mcp` inside Claude Code to see status
364
+ 3. Check for errors in the server output
365
+
366
+ ### "Configuration is invalid"
367
+
368
+ Ensure your JSON is valid and `command` is a string (not array):
369
+
370
+ ```json
371
+ // Correct
372
+ {
373
+ "type": "stdio",
374
+ "command": "node",
375
+ "args": ["dist/index.js", "--project", "."]
376
+ }
377
+
378
+ // Wrong
379
+ {
380
+ "type": "stdio",
381
+ "command": ["node", "dist/index.js"]
382
+ }
383
+ ```
384
+
385
+ ### Server Takes Too Long to Start
386
+
387
+ Increase the MCP timeout:
388
+
389
+ ```bash
390
+ MCP_TIMEOUT=120000 claude
391
+ ```
392
+
393
+ Or set in `.mcp.json`:
394
+
395
+ ```json
396
+ {
397
+ "mcpServers": {
398
+ "memorylayer": {
399
+ "type": "stdio",
400
+ "command": "node",
401
+ "args": ["dist/index.js", "--project", "."],
402
+ "env": {},
403
+ "timeout": 120000
404
+ }
405
+ }
406
+ }
407
+ ```
408
+
409
+ ### View Debug Logs
410
+
411
+ ```bash
412
+ # Run Claude Code with debug logging
413
+ claude --log-level DEBUG
414
+ ```
415
+
416
+ ---
417
+
418
+ ## Importing from Claude Desktop
419
+
420
+ If you already have MemoryLayer configured in Claude Desktop:
421
+
422
+ ```bash
423
+ # Import all servers from Claude Desktop
424
+ claude mcp add-from-claude-desktop
425
+
426
+ # Select memorylayer from the list
427
+
428
+ # Verify import
429
+ claude mcp list
430
+ ```
431
+
432
+ ---
433
+
434
+ ## Data Storage
435
+
436
+ MemoryLayer stores data locally:
437
+
438
+ ```
439
+ ~/.memorylayer/
440
+ ├── registry.json # Project registry
441
+ └── projects/
442
+ └── {project-name}-{hash}/
443
+ ├── memorylayer.db # SQLite database
444
+ └── tier1.json # Working context
445
+ ```
446
+
447
+ ---
448
+
449
+ ## Comparison: Claude Desktop vs Claude Code
450
+
451
+ | Feature | Claude Desktop | Claude Code |
452
+ |---------|----------------|-------------|
453
+ | Config Location | `~/.claude/claude_desktop_config.json` | `~/.claude.json` or `.mcp.json` |
454
+ | Add Server | Manual JSON edit | CLI commands or JSON |
455
+ | Project Scope | No | Yes (`.mcp.json`) |
456
+ | User Scope | Yes | Yes |
457
+ | Local Scope | N/A | Yes (default) |
458
+ | Env Var Expansion | No | Yes (`${VAR}` syntax) |
459
+
460
+ ---
461
+
462
+ ## Links
463
+
464
+ - [Claude Code Documentation](https://code.claude.com/docs/)
465
+ - [Claude Code MCP Guide](https://code.claude.com/docs/en/mcp)
466
+ - [Claude Code Settings](https://code.claude.com/docs/en/settings)
467
+ - [MCP Protocol Specification](https://modelcontextprotocol.io/)
468
+ - [MemoryLayer Documentation](./INDEX.md)
469
+
470
+ ---
471
+
472
+ ## Quick Reference
473
+
474
+ ### Minimum Setup
475
+
476
+ ```bash
477
+ # One-liner setup
478
+ claude mcp add --transport stdio memorylayer -- node /path/to/memorylayer/dist/index.js --project .
479
+ ```
480
+
481
+ ### Full `.mcp.json` Example
482
+
483
+ ```json
484
+ {
485
+ "mcpServers": {
486
+ "memorylayer": {
487
+ "type": "stdio",
488
+ "command": "node",
489
+ "args": [
490
+ "/path/to/memorylayer/dist/index.js",
491
+ "--project",
492
+ "."
493
+ ],
494
+ "env": {
495
+ "MEMORYLAYER_MAX_TOKENS": "8000"
496
+ }
497
+ }
498
+ }
499
+ }
500
+ ```
501
+
502
+ ---
503
+
504
+ *Last updated: February 2026*