@grec0/memory-bank-mcp 0.1.7 โ 0.1.9
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 +1019 -1019
- package/dist/common/indexManager.js +20 -1
- package/dist/common/projectKnowledgeService.js +121 -63
- package/dist/index.js +21 -21
- package/dist/tools/generateProjectDocs.js +3 -2
- package/dist/tools/getProjectDocs.js +13 -12
- package/dist/tools/initializeMemoryBank.js +244 -244
- package/dist/tools/recordDecision.js +48 -48
- package/dist/tools/trackProgress.js +43 -43
- package/dist/tools/updateContext.js +37 -37
- package/package.json +1 -1
- package/dist/common/errors.js +0 -71
- package/dist/common/setup.js +0 -49
- package/dist/common/types.js +0 -115
- package/dist/common/utils.js +0 -215
- package/dist/operations/boardMemberships.js +0 -186
- package/dist/operations/boards.js +0 -268
- package/dist/operations/cards.js +0 -426
- package/dist/operations/comments.js +0 -249
- package/dist/operations/labels.js +0 -258
- package/dist/operations/lists.js +0 -157
- package/dist/operations/projects.js +0 -102
- package/dist/operations/tasks.js +0 -238
- package/dist/tools/board-summary.js +0 -151
- package/dist/tools/card-details.js +0 -106
- package/dist/tools/create-card-with-tasks.js +0 -81
- package/dist/tools/workflow-actions.js +0 -145
package/README.md
CHANGED
|
@@ -1,1019 +1,1019 @@
|
|
|
1
|
-
# Memory Bank MCP - Semantic Code Indexing
|
|
2
|
-
|
|
3
|
-
MCP (Model Context Protocol) server for semantic code indexing. Enables AI agents like Claude, Copilot, Cursor, and others to maintain a "persistent memory" of entire codebases through vector embeddings and semantic search.
|
|
4
|
-
|
|
5
|
-
## ๐ง What is Memory Bank?
|
|
6
|
-
|
|
7
|
-
**Memory Bank** is an external memory system for code agents that solves the fundamental problem of context loss in AIs. It works as the project's "external brain":
|
|
8
|
-
|
|
9
|
-
- **Indexes** all your code using OpenAI embeddings
|
|
10
|
-
- **Chunks** intelligently using AST parsing (functions, classes, methods)
|
|
11
|
-
- **Stores** vectors in LanceDB for ultra-fast searches
|
|
12
|
-
- **Searches** semantically: ask in natural language, get relevant code
|
|
13
|
-
- **Updates** incrementally: only reindexes modified files
|
|
14
|
-
- **Multi-project**: query code from any indexed project from any workspace
|
|
15
|
-
|
|
16
|
-
### Why do you need it?
|
|
17
|
-
|
|
18
|
-
Without Memory Bank, AIs:
|
|
19
|
-
- โ Forget everything between sessions
|
|
20
|
-
- โ Only see small code snippets
|
|
21
|
-
- โ Hallucinate non-existent implementations
|
|
22
|
-
- โ Give generic answers without context
|
|
23
|
-
|
|
24
|
-
With Memory Bank, AIs:
|
|
25
|
-
- โ
Remember the entire codebase
|
|
26
|
-
- โ
Understand architecture and patterns
|
|
27
|
-
- โ
Respond with real project code
|
|
28
|
-
- โ
Generate code consistent with your style
|
|
29
|
-
- โ
**Query multiple indexed projects** simultaneously
|
|
30
|
-
|
|
31
|
-
## ๐ Features
|
|
32
|
-
|
|
33
|
-
### Core Memory Bank (Precise Search)
|
|
34
|
-
- **๐ Semantic Search**: Ask "how does authentication work?" and get relevant code
|
|
35
|
-
- **๐งฉ Intelligent Chunking**: AST parsing for TS/JS/Python with token limits (8192 max)
|
|
36
|
-
- **โก Incremental Updates**: Only reindexes modified files (hash-based detection)
|
|
37
|
-
- **๐พ Embedding Cache**: Avoids regenerating embeddings unnecessarily
|
|
38
|
-
- **๐ฏ Advanced Filters**: By file, language, chunk type
|
|
39
|
-
- **๐ Detailed Statistics**: Know the state of your index at all times
|
|
40
|
-
- **๐ Privacy**: Local vector store, respects .gitignore and .memoryignore
|
|
41
|
-
- **๐ Multi-Project**: Query any indexed project using its `projectId`
|
|
42
|
-
|
|
43
|
-
### Project Knowledge Layer (Global Knowledge)
|
|
44
|
-
- **๐ Automatic Documentation**: Generates 6 structured markdown documents about the project
|
|
45
|
-
- **๐ง AI with Reasoning**: Uses OpenAI Responses API with reasoning models (gpt-5-mini)
|
|
46
|
-
- **๐ Smart Updates**: Only regenerates documents affected by changes
|
|
47
|
-
- **๐ Global Context**: Complements precise search with high-level vision
|
|
48
|
-
|
|
49
|
-
### Context Management (Session Management) ๐
|
|
50
|
-
- **๐ Quick Initialization**: Creates Memory Bank structure with initial templates (no AI)
|
|
51
|
-
- **๐ Session Tracking**: Records active context, recent changes, and next steps
|
|
52
|
-
- **๐ Decision Log**: Documents technical decisions with rationale and alternatives
|
|
53
|
-
- **๐ Progress Tracking**: Manages tasks, milestones, and blockers
|
|
54
|
-
- **๐ก MCP Resources**: Direct read-only access to documents via URIs
|
|
55
|
-
|
|
56
|
-
## ๐ Requirements
|
|
57
|
-
|
|
58
|
-
- **Node.js** >= 18.0.0
|
|
59
|
-
- **OpenAI API Key**: [Get one here](https://platform.openai.com/api-keys)
|
|
60
|
-
- **Disk space**: ~10MB per 10,000 files (embeddings + metadata)
|
|
61
|
-
|
|
62
|
-
## ๐ ๏ธ Installation
|
|
63
|
-
|
|
64
|
-
### Option 1: NPX (Recommended)
|
|
65
|
-
|
|
66
|
-
The easiest way to use Memory Bank MCP without local installation:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
npx @grec0/memory-bank-mcp@latest
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Option 2: Local Installation
|
|
73
|
-
|
|
74
|
-
For development or contribution:
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# Clone repository
|
|
78
|
-
git clone https://github.com/gcorroto/memory-bank-mcp.git
|
|
79
|
-
cd memory-bank-mcp
|
|
80
|
-
|
|
81
|
-
# Install dependencies
|
|
82
|
-
npm install
|
|
83
|
-
|
|
84
|
-
# Build
|
|
85
|
-
npm run build
|
|
86
|
-
|
|
87
|
-
# Run
|
|
88
|
-
npm run start
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## โ๏ธ Complete Configuration
|
|
92
|
-
|
|
93
|
-
### Environment Variables
|
|
94
|
-
|
|
95
|
-
Memory Bank is configured through environment variables. You can set them in your MCP client or in a `.env` file:
|
|
96
|
-
|
|
97
|
-
#### Required Variables
|
|
98
|
-
|
|
99
|
-
| Variable | Description |
|
|
100
|
-
|----------|-------------|
|
|
101
|
-
| `OPENAI_API_KEY` | **REQUIRED**. Your OpenAI API key |
|
|
102
|
-
|
|
103
|
-
#### Indexing Variables
|
|
104
|
-
|
|
105
|
-
| Variable | Default | Description |
|
|
106
|
-
|----------|---------|-------------|
|
|
107
|
-
| `MEMORYBANK_STORAGE_PATH` | `.memorybank` | Directory where the vector index is stored |
|
|
108
|
-
| `MEMORYBANK_WORKSPACE_ROOT` | `process.cwd()` | Workspace root (usually auto-detected) |
|
|
109
|
-
| `MEMORYBANK_EMBEDDING_MODEL` | `text-embedding-3-small` | OpenAI embedding model |
|
|
110
|
-
| `MEMORYBANK_EMBEDDING_DIMENSIONS` | `1536` | Vector dimensions (1536 or 512) |
|
|
111
|
-
| `MEMORYBANK_MAX_TOKENS` | `7500` | Maximum tokens per chunk (limit: 8192) |
|
|
112
|
-
| `MEMORYBANK_CHUNK_OVERLAP_TOKENS` | `200` | Overlap between chunks to maintain context |
|
|
113
|
-
|
|
114
|
-
#### Project Knowledge Layer Variables
|
|
115
|
-
|
|
116
|
-
| Variable | Default | Description |
|
|
117
|
-
|----------|---------|-------------|
|
|
118
|
-
| `MEMORYBANK_REASONING_MODEL` | `gpt-5-mini` | Model for generating documentation (supports reasoning) |
|
|
119
|
-
| `MEMORYBANK_REASONING_EFFORT` | `medium` | Reasoning level: `low`, `medium`, `high` |
|
|
120
|
-
| `MEMORYBANK_AUTO_UPDATE_DOCS` | `false` | Auto-regenerate docs when indexing code |
|
|
121
|
-
|
|
122
|
-
### Configuration in Cursor IDE
|
|
123
|
-
|
|
124
|
-
Edit your MCP configuration file:
|
|
125
|
-
|
|
126
|
-
**Windows**: `%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`
|
|
127
|
-
|
|
128
|
-
#### Minimal Configuration
|
|
129
|
-
|
|
130
|
-
```json
|
|
131
|
-
{
|
|
132
|
-
"mcpServers": {
|
|
133
|
-
"memory-bank-mcp": {
|
|
134
|
-
"type": "stdio",
|
|
135
|
-
"command": "npx",
|
|
136
|
-
"args": ["@grec0/memory-bank-mcp@latest"],
|
|
137
|
-
"env": {
|
|
138
|
-
"OPENAI_API_KEY": "sk-your-api-key-here"
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
#### Complete Configuration (Recommended)
|
|
146
|
-
|
|
147
|
-
```json
|
|
148
|
-
{
|
|
149
|
-
"mcpServers": {
|
|
150
|
-
"memory-bank-mcp": {
|
|
151
|
-
"type": "stdio",
|
|
152
|
-
"command": "npx",
|
|
153
|
-
"args": ["@grec0/memory-bank-mcp@latest"],
|
|
154
|
-
"env": {
|
|
155
|
-
"OPENAI_API_KEY": "sk-your-api-key-here",
|
|
156
|
-
"MEMORYBANK_REASONING_MODEL": "gpt-5-mini",
|
|
157
|
-
"MEMORYBANK_REASONING_EFFORT": "medium",
|
|
158
|
-
"MEMORYBANK_AUTO_UPDATE_DOCS": "false",
|
|
159
|
-
"MEMORYBANK_MAX_TOKENS": "7500",
|
|
160
|
-
"MEMORYBANK_CHUNK_OVERLAP_TOKENS": "200",
|
|
161
|
-
"MEMORYBANK_EMBEDDING_MODEL": "text-embedding-3-small",
|
|
162
|
-
"MEMORYBANK_EMBEDDING_DIMENSIONS": "1536"
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Configuration in Claude Desktop
|
|
170
|
-
|
|
171
|
-
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
172
|
-
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
173
|
-
**Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
174
|
-
|
|
175
|
-
```json
|
|
176
|
-
{
|
|
177
|
-
"mcpServers": {
|
|
178
|
-
"memory-bank": {
|
|
179
|
-
"command": "npx",
|
|
180
|
-
"args": ["@grec0/memory-bank-mcp@latest"],
|
|
181
|
-
"env": {
|
|
182
|
-
"OPENAI_API_KEY": "sk-your-api-key-here",
|
|
183
|
-
"MEMORYBANK_REASONING_MODEL": "gpt-5-mini",
|
|
184
|
-
"MEMORYBANK_REASONING_EFFORT": "medium"
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Configuration with Local Installation
|
|
192
|
-
|
|
193
|
-
```json
|
|
194
|
-
{
|
|
195
|
-
"mcpServers": {
|
|
196
|
-
"memory-bank": {
|
|
197
|
-
"command": "node",
|
|
198
|
-
"args": ["/absolute/path/memory-bank-mcp/dist/index.js"],
|
|
199
|
-
"cwd": "/absolute/path/memory-bank-mcp",
|
|
200
|
-
"env": {
|
|
201
|
-
"OPENAI_API_KEY": "sk-your-api-key-here"
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## ๐ Project Documentation System (Project Knowledge Layer)
|
|
211
|
-
|
|
212
|
-
Memory Bank includes an intelligent documentation system that generates and maintains structured knowledge about your project using AI with reasoning capabilities.
|
|
213
|
-
|
|
214
|
-
### How Does It Work?
|
|
215
|
-
|
|
216
|
-
1. **Code Analysis**: The system analyzes indexed code using semantic search
|
|
217
|
-
2. **AI Generation**: Uses reasoning models (gpt-5-mini) to generate structured documentation
|
|
218
|
-
3. **Incremental Updates**: Only regenerates documents affected by significant changes
|
|
219
|
-
4. **Persistent Storage**: Documents are saved in `.memorybank/projects/{projectId}/docs/`
|
|
220
|
-
|
|
221
|
-
### Generated Documents
|
|
222
|
-
|
|
223
|
-
The system generates **6 markdown documents** that provide different perspectives of the project:
|
|
224
|
-
|
|
225
|
-
| Document | Purpose | Content |
|
|
226
|
-
|----------|---------|---------|
|
|
227
|
-
| `projectBrief.md` | **General Description** | What the project is, its main purpose, key features |
|
|
228
|
-
| `productContext.md` | **Business Perspective** | Why it exists, problems it solves, target users, UX |
|
|
229
|
-
| `systemPatterns.md` | **Architecture and Patterns** | Code structure, design patterns, technical decisions |
|
|
230
|
-
| `techContext.md` | **Tech Stack** | Technologies, dependencies, configurations, integrations |
|
|
231
|
-
| `activeContext.md` | **Current State** | What's being worked on, recent changes, next steps |
|
|
232
|
-
| `progress.md` | **Tracking** | Change history, what works, what's missing, known issues |
|
|
233
|
-
|
|
234
|
-
### Documentation Tools
|
|
235
|
-
|
|
236
|
-
#### `memorybank_generate_project_docs`
|
|
237
|
-
|
|
238
|
-
Generates or regenerates project documentation.
|
|
239
|
-
|
|
240
|
-
```json
|
|
241
|
-
{
|
|
242
|
-
"projectId": "my-project",
|
|
243
|
-
"force": false
|
|
244
|
-
}
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
- `projectId` **(REQUIRED)**: Project ID
|
|
248
|
-
- `force` (optional): `true` to regenerate everything, `false` for incremental updates
|
|
249
|
-
|
|
250
|
-
#### `memorybank_get_project_docs`
|
|
251
|
-
|
|
252
|
-
Reads generated documentation.
|
|
253
|
-
|
|
254
|
-
```json
|
|
255
|
-
// Get summary of all documents
|
|
256
|
-
{
|
|
257
|
-
"projectId": "my-project",
|
|
258
|
-
"document": "summary"
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Get specific document
|
|
262
|
-
{
|
|
263
|
-
"projectId": "my-project",
|
|
264
|
-
"document": "systemPatterns"
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Get all complete documents
|
|
268
|
-
{
|
|
269
|
-
"projectId": "my-project",
|
|
270
|
-
"document": "all",
|
|
271
|
-
"format": "full"
|
|
272
|
-
}
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
### Documentation Workflow
|
|
276
|
-
|
|
277
|
-
```
|
|
278
|
-
1. Index code
|
|
279
|
-
memorybank_index_code({ projectId: "my-project" })
|
|
280
|
-
|
|
281
|
-
2. Generate documentation
|
|
282
|
-
memorybank_generate_project_docs({ projectId: "my-project" })
|
|
283
|
-
|
|
284
|
-
3. Query documentation at the start of each session
|
|
285
|
-
memorybank_get_project_docs({ projectId: "my-project", document: "activeContext" })
|
|
286
|
-
|
|
287
|
-
4. Search specific code
|
|
288
|
-
memorybank_search({ projectId: "my-project", query: "..." })
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### Auto-Update Documentation
|
|
292
|
-
|
|
293
|
-
If you configure `MEMORYBANK_AUTO_UPDATE_DOCS=true`, documents will be automatically regenerated after each indexing. This is useful for keeping documentation always up to date but consumes more API tokens.
|
|
294
|
-
|
|
295
|
-
---
|
|
296
|
-
|
|
297
|
-
## ๐ Multi-Project: Cross-Project Queries
|
|
298
|
-
|
|
299
|
-
A powerful feature of Memory Bank is the ability to **query any indexed project from any workspace**.
|
|
300
|
-
|
|
301
|
-
### How Does It Work?
|
|
302
|
-
|
|
303
|
-
All indexed projects are stored in a shared vector store, identified by their `projectId`. This means:
|
|
304
|
-
|
|
305
|
-
1. **You can work on Project A** and query code from Project B
|
|
306
|
-
2. **Agents can learn** from similar already-indexed projects
|
|
307
|
-
3. **Reuse patterns** from other projects in your organization
|
|
308
|
-
|
|
309
|
-
### Usage Example
|
|
310
|
-
|
|
311
|
-
```
|
|
312
|
-
# You're working on "frontend-app" but need to see how something was done in "backend-api"
|
|
313
|
-
|
|
314
|
-
User: How was authentication implemented in the backend-api project?
|
|
315
|
-
|
|
316
|
-
Agent: [executes memorybank_search({
|
|
317
|
-
projectId: "backend-api", // Another project
|
|
318
|
-
query: "JWT middleware authentication"
|
|
319
|
-
})]
|
|
320
|
-
|
|
321
|
-
Found the implementation in backend-api:
|
|
322
|
-
- The auth middleware is in src/middleware/auth.ts
|
|
323
|
-
- Uses JWT with refresh tokens
|
|
324
|
-
- Validation is done with jsonwebtoken...
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
### Requirements for Multi-Project
|
|
328
|
-
|
|
329
|
-
1. **The project must be previously indexed** with its `projectId`
|
|
330
|
-
2. **Use the correct projectId** when making queries
|
|
331
|
-
3. **Documentation is independent** per project
|
|
332
|
-
|
|
333
|
-
### Real Example: Two Related Projects
|
|
334
|
-
|
|
335
|
-
```json
|
|
336
|
-
// Project 1: a2a_gateway (already indexed)
|
|
337
|
-
memorybank_search({
|
|
338
|
-
"projectId": "a2a_gateway",
|
|
339
|
-
"query": "how agents are registered"
|
|
340
|
-
})
|
|
341
|
-
|
|
342
|
-
// Project 2: GREC0AI (current workspace)
|
|
343
|
-
memorybank_search({
|
|
344
|
-
"projectId": "GREC0AI",
|
|
345
|
-
"query": "AgentEntity implementation"
|
|
346
|
-
})
|
|
347
|
-
|
|
348
|
-
// You can query both in the same session!
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
---
|
|
352
|
-
|
|
353
|
-
## ๐ Available Tools
|
|
354
|
-
|
|
355
|
-
> **โ ๏ธ IMPORTANT**: All tools require mandatory `projectId`. This ID must match the one defined in your `AGENTS.md` file.
|
|
356
|
-
|
|
357
|
-
### `memorybank_index_code`
|
|
358
|
-
|
|
359
|
-
Indexes code semantically to enable searches.
|
|
360
|
-
|
|
361
|
-
**Parameters:**
|
|
362
|
-
- `projectId` **(REQUIRED)**: Unique project identifier
|
|
363
|
-
- `path` (optional): Relative or absolute path (default: workspace root)
|
|
364
|
-
- `recursive` (optional): Index subdirectories (default: true)
|
|
365
|
-
- `forceReindex` (optional): Force complete reindexing (default: false)
|
|
366
|
-
|
|
367
|
-
**Example:**
|
|
368
|
-
```json
|
|
369
|
-
{
|
|
370
|
-
"projectId": "my-project",
|
|
371
|
-
"path": "src/auth",
|
|
372
|
-
"recursive": true
|
|
373
|
-
}
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
### `memorybank_search`
|
|
377
|
-
|
|
378
|
-
Searches code by semantic similarity.
|
|
379
|
-
|
|
380
|
-
**Parameters:**
|
|
381
|
-
- `projectId` **(REQUIRED)**: Project identifier to search in
|
|
382
|
-
- `query` (required): Natural language query
|
|
383
|
-
- `topK` (optional): Number of results (default: 10)
|
|
384
|
-
- `minScore` (optional): Minimum score 0-1 (default: 0.4)
|
|
385
|
-
- `filterByFile` (optional): Filter by file pattern
|
|
386
|
-
- `filterByLanguage` (optional): Filter by language
|
|
387
|
-
|
|
388
|
-
**Example:**
|
|
389
|
-
```json
|
|
390
|
-
{
|
|
391
|
-
"projectId": "my-project",
|
|
392
|
-
"query": "function that authenticates users with JWT",
|
|
393
|
-
"topK": 5,
|
|
394
|
-
"minScore": 0.8
|
|
395
|
-
}
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
### `memorybank_read_file`
|
|
399
|
-
|
|
400
|
-
Reads file contents.
|
|
401
|
-
|
|
402
|
-
**Parameters:**
|
|
403
|
-
- `path` (required): File path
|
|
404
|
-
- `startLine` (optional): Start line
|
|
405
|
-
- `endLine` (optional): End line
|
|
406
|
-
|
|
407
|
-
### `memorybank_write_file`
|
|
408
|
-
|
|
409
|
-
Writes a file and automatically reindexes it.
|
|
410
|
-
|
|
411
|
-
**Parameters:**
|
|
412
|
-
- `projectId` **(REQUIRED)**: Project identifier for reindexing
|
|
413
|
-
- `path` (required): File path
|
|
414
|
-
- `content` (required): File content
|
|
415
|
-
- `autoReindex` (optional): Auto-reindex (default: true)
|
|
416
|
-
|
|
417
|
-
### `memorybank_get_stats`
|
|
418
|
-
|
|
419
|
-
Gets Memory Bank statistics.
|
|
420
|
-
|
|
421
|
-
### `memorybank_analyze_coverage`
|
|
422
|
-
|
|
423
|
-
Analyzes project indexing coverage.
|
|
424
|
-
|
|
425
|
-
**Parameters:**
|
|
426
|
-
- `projectId` **(REQUIRED)**: Project identifier to analyze
|
|
427
|
-
- `path` **(REQUIRED)**: Absolute workspace path to analyze
|
|
428
|
-
|
|
429
|
-
**Example:**
|
|
430
|
-
```json
|
|
431
|
-
{
|
|
432
|
-
"projectId": "my-project",
|
|
433
|
-
"path": "C:/workspaces/my-project"
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
### `memorybank_generate_project_docs`
|
|
438
|
-
|
|
439
|
-
Generates structured project documentation using AI with reasoning.
|
|
440
|
-
|
|
441
|
-
**Parameters:**
|
|
442
|
-
- `projectId` **(REQUIRED)**: Project identifier
|
|
443
|
-
- `force` (optional): Force regeneration (default: false)
|
|
444
|
-
|
|
445
|
-
### `memorybank_get_project_docs`
|
|
446
|
-
|
|
447
|
-
Reads AI-generated project documentation.
|
|
448
|
-
|
|
449
|
-
**Parameters:**
|
|
450
|
-
- `projectId` **(REQUIRED)**: Project identifier
|
|
451
|
-
- `document` (optional): `"summary"`, `"all"`, or specific name (`projectBrief`, `systemPatterns`, etc.)
|
|
452
|
-
- `format` (optional): `"full"` or `"summary"` (default: "full")
|
|
453
|
-
|
|
454
|
-
---
|
|
455
|
-
|
|
456
|
-
## ๐ Context Management Tools (Cline-style)
|
|
457
|
-
|
|
458
|
-
These tools allow managing project context manually, complementing automatic AI generation.
|
|
459
|
-
|
|
460
|
-
### `memorybank_initialize`
|
|
461
|
-
|
|
462
|
-
Initializes Memory Bank for a new project. Creates directory structure and 7 markdown documents with initial templates. **Does not use AI**.
|
|
463
|
-
|
|
464
|
-
**Parameters:**
|
|
465
|
-
- `projectId` **(REQUIRED)**: Unique project identifier
|
|
466
|
-
- `projectPath` **(REQUIRED)**: Absolute project path
|
|
467
|
-
- `projectName` (optional): Human-readable project name
|
|
468
|
-
- `description` (optional): Initial project description
|
|
469
|
-
|
|
470
|
-
**Example:**
|
|
471
|
-
```json
|
|
472
|
-
{
|
|
473
|
-
"projectId": "my-project",
|
|
474
|
-
"projectPath": "C:/workspaces/my-project",
|
|
475
|
-
"projectName": "My Awesome Project",
|
|
476
|
-
"description": "A web application for..."
|
|
477
|
-
}
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
**Created documents:**
|
|
481
|
-
- `projectBrief.md` - General description
|
|
482
|
-
- `productContext.md` - Product context
|
|
483
|
-
- `systemPatterns.md` - Architecture patterns
|
|
484
|
-
- `techContext.md` - Tech stack
|
|
485
|
-
- `activeContext.md` - Session context
|
|
486
|
-
- `progress.md` - Progress tracking
|
|
487
|
-
- `decisionLog.md` - Decision log
|
|
488
|
-
|
|
489
|
-
### `memorybank_update_context`
|
|
490
|
-
|
|
491
|
-
Updates active context with current session information. Maintains history of the last 10 sessions. **Does not use AI**.
|
|
492
|
-
|
|
493
|
-
**Parameters:**
|
|
494
|
-
- `projectId` **(REQUIRED)**: Project identifier
|
|
495
|
-
- `currentSession` (optional): Session information (date, mode, task)
|
|
496
|
-
- `recentChanges` (optional): List of recent changes
|
|
497
|
-
- `openQuestions` (optional): Pending questions
|
|
498
|
-
- `nextSteps` (optional): Planned next steps
|
|
499
|
-
- `notes` (optional): Additional notes
|
|
500
|
-
|
|
501
|
-
**Example:**
|
|
502
|
-
```json
|
|
503
|
-
{
|
|
504
|
-
"projectId": "my-project",
|
|
505
|
-
"currentSession": {
|
|
506
|
-
"mode": "development",
|
|
507
|
-
"task": "Implementing authentication"
|
|
508
|
-
},
|
|
509
|
-
"recentChanges": ["Added JWT middleware", "Created user model"],
|
|
510
|
-
"nextSteps": ["Add refresh token", "Create login endpoint"]
|
|
511
|
-
}
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
### `memorybank_record_decision`
|
|
515
|
-
|
|
516
|
-
Records technical decisions with rationale in the decision log. **Does not use AI**.
|
|
517
|
-
|
|
518
|
-
**Parameters:**
|
|
519
|
-
- `projectId` **(REQUIRED)**: Project identifier
|
|
520
|
-
- `decision` **(REQUIRED)**: Object with decision information
|
|
521
|
-
- `title` **(REQUIRED)**: Decision title
|
|
522
|
-
- `description` **(REQUIRED)**: What was decided
|
|
523
|
-
- `rationale` **(REQUIRED)**: Why this decision was made
|
|
524
|
-
- `alternatives` (optional): Considered alternatives
|
|
525
|
-
- `impact` (optional): Expected impact
|
|
526
|
-
- `category` (optional): architecture, technology, dependencies, etc.
|
|
527
|
-
|
|
528
|
-
**Example:**
|
|
529
|
-
```json
|
|
530
|
-
{
|
|
531
|
-
"projectId": "my-project",
|
|
532
|
-
"decision": {
|
|
533
|
-
"title": "JWT Authentication",
|
|
534
|
-
"description": "Use JWT tokens for API authentication",
|
|
535
|
-
"rationale": "Stateless, scalable, works well with microservices",
|
|
536
|
-
"alternatives": ["Session-based auth", "OAuth only"],
|
|
537
|
-
"category": "architecture"
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
### `memorybank_track_progress`
|
|
543
|
-
|
|
544
|
-
Updates progress tracking with tasks, milestones, and blockers. **Does not use AI**.
|
|
545
|
-
|
|
546
|
-
**Parameters:**
|
|
547
|
-
- `projectId` **(REQUIRED)**: Project identifier
|
|
548
|
-
- `progress` (optional): Tasks to update
|
|
549
|
-
- `completed`: Completed tasks
|
|
550
|
-
- `inProgress`: Tasks in progress
|
|
551
|
-
- `blocked`: Blocked tasks
|
|
552
|
-
- `upcoming`: Upcoming tasks
|
|
553
|
-
- `milestone` (optional): Milestone to add/update (name, status, targetDate, notes)
|
|
554
|
-
- `blockers` (optional): List of blockers with severity (low/medium/high)
|
|
555
|
-
- `phase` (optional): Current project phase
|
|
556
|
-
- `phaseStatus` (optional): Phase status
|
|
557
|
-
|
|
558
|
-
**Example:**
|
|
559
|
-
```json
|
|
560
|
-
{
|
|
561
|
-
"projectId": "my-project",
|
|
562
|
-
"progress": {
|
|
563
|
-
"completed": ["Setup project structure", "Configure ESLint"],
|
|
564
|
-
"inProgress": ["Implement user authentication"],
|
|
565
|
-
"upcoming": ["Add unit tests"]
|
|
566
|
-
},
|
|
567
|
-
"milestone": {
|
|
568
|
-
"name": "MVP",
|
|
569
|
-
"status": "in_progress",
|
|
570
|
-
"targetDate": "2026-02-01"
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
---
|
|
576
|
-
|
|
577
|
-
## ๐ก MCP Resources (Direct Access)
|
|
578
|
-
|
|
579
|
-
Memory Bank exposes MCP resources for direct read-only access to project documents.
|
|
580
|
-
|
|
581
|
-
| Resource URI | Content |
|
|
582
|
-
|--------------|---------|
|
|
583
|
-
| `memory://{projectId}/active` | Active session context |
|
|
584
|
-
| `memory://{projectId}/progress` | Progress tracking |
|
|
585
|
-
| `memory://{projectId}/decisions` | Technical decision log |
|
|
586
|
-
| `memory://{projectId}/context` | Project context (brief + tech) |
|
|
587
|
-
| `memory://{projectId}/patterns` | System patterns |
|
|
588
|
-
| `memory://{projectId}/brief` | Project description |
|
|
589
|
-
|
|
590
|
-
**Usage example:**
|
|
591
|
-
```
|
|
592
|
-
// Access active context for "my-project"
|
|
593
|
-
memory://my-project/active
|
|
594
|
-
|
|
595
|
-
// Access decision log
|
|
596
|
-
memory://my-project/decisions
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
Resources are read-only. To modify documents, use the corresponding tools (`memorybank_update_context`, `memorybank_record_decision`, etc.).
|
|
600
|
-
|
|
601
|
-
---
|
|
602
|
-
|
|
603
|
-
## ๐ Agent Instruction Templates
|
|
604
|
-
|
|
605
|
-
Memory Bank includes instruction templates in two formats to configure agent behavior:
|
|
606
|
-
|
|
607
|
-
- **AGENTS.md** - Standard [agents.md](https://agents.md/) (compatible with Claude, Cursor, multiple agents)
|
|
608
|
-
- **VSCode/Copilot** - `.github/copilot-instructions.md` format for GitHub Copilot in VS Code
|
|
609
|
-
|
|
610
|
-
### Available Modes
|
|
611
|
-
|
|
612
|
-
| Mode | File | Ideal Use |
|
|
613
|
-
|------|------|-----------|
|
|
614
|
-
| **Basic** | `AGENTS.basic.md` | Total control, manual indexing |
|
|
615
|
-
| **Auto-Index** | `AGENTS.auto-index.md` | Active development, automatic sync |
|
|
616
|
-
| **Sandboxed** | `AGENTS.sandboxed.md` | Environments without direct file access |
|
|
617
|
-
|
|
618
|
-
### 1. Basic Mode
|
|
619
|
-
|
|
620
|
-
**For projects where you want total control.**
|
|
621
|
-
|
|
622
|
-
- โ
Agent ALWAYS consults Memory Bank before acting
|
|
623
|
-
- โ
Only indexes when user explicitly requests
|
|
624
|
-
- โ
Asks permission before modifying code
|
|
625
|
-
- โ
Suggests reindexing after changes
|
|
626
|
-
|
|
627
|
-
**Ideal for**: Critical projects, code review, onboarding.
|
|
628
|
-
|
|
629
|
-
### 2. Auto-Index Mode
|
|
630
|
-
|
|
631
|
-
**For active development with automatic synchronization.**
|
|
632
|
-
|
|
633
|
-
- โ
Agent consults Memory Bank automatically
|
|
634
|
-
- โ
Reindexes EVERY file after modifying it
|
|
635
|
-
- โ
Keeps Memory Bank always up to date
|
|
636
|
-
- โ
Can read/write files directly
|
|
637
|
-
|
|
638
|
-
**Ideal for**: Active development, rapid iteration, teams.
|
|
639
|
-
|
|
640
|
-
### 3. Sandboxed Mode
|
|
641
|
-
|
|
642
|
-
**For environments without direct file system access.**
|
|
643
|
-
|
|
644
|
-
- โ
Does NOT have direct file access
|
|
645
|
-
- โ
MUST use `memorybank_read_file` to read
|
|
646
|
-
- โ
MUST use `memorybank_write_file` to write
|
|
647
|
-
- โ
Auto-reindexes automatically on each write
|
|
648
|
-
|
|
649
|
-
**Ideal for**: Restricted environments, remote development, security.
|
|
650
|
-
|
|
651
|
-
### Available Templates
|
|
652
|
-
|
|
653
|
-
All templates are available in the GitHub repository:
|
|
654
|
-
|
|
655
|
-
#### AGENTS.md Format (Cursor, Claude, Multi-agent)
|
|
656
|
-
|
|
657
|
-
| Mode | URL |
|
|
658
|
-
|------|-----|
|
|
659
|
-
| **Basic** | [AGENTS.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.basic.md) |
|
|
660
|
-
| **Auto-Index** | [AGENTS.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.auto-index.md) |
|
|
661
|
-
| **Sandboxed** | [AGENTS.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.sandboxed.md) |
|
|
662
|
-
|
|
663
|
-
**Installation:**
|
|
664
|
-
|
|
665
|
-
```bash
|
|
666
|
-
# Download template (choose one)
|
|
667
|
-
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.basic.md
|
|
668
|
-
# Or
|
|
669
|
-
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.auto-index.md
|
|
670
|
-
# Or
|
|
671
|
-
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.sandboxed.md
|
|
672
|
-
|
|
673
|
-
# Edit placeholders:
|
|
674
|
-
# - Replace {{PROJECT_ID}} with your unique project ID
|
|
675
|
-
# - Replace {{WORKSPACE_PATH}} with the absolute workspace path
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
#### VS Code / GitHub Copilot Format
|
|
679
|
-
|
|
680
|
-
| Mode | URL |
|
|
681
|
-
|------|-----|
|
|
682
|
-
| **Basic** | [copilot-instructions.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.basic.md) |
|
|
683
|
-
| **Auto-Index** | [copilot-instructions.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.auto-index.md) |
|
|
684
|
-
| **Sandboxed** | [copilot-instructions.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.sandboxed.md) |
|
|
685
|
-
| **Instructions** | [memory-bank.instructions.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/memory-bank.instructions.md) |
|
|
686
|
-
|
|
687
|
-
**Installation:**
|
|
688
|
-
|
|
689
|
-
```bash
|
|
690
|
-
# Create .github folder if it doesn't exist
|
|
691
|
-
mkdir -p .github
|
|
692
|
-
|
|
693
|
-
# Download template (choose one)
|
|
694
|
-
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.basic.md
|
|
695
|
-
# Or
|
|
696
|
-
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.auto-index.md
|
|
697
|
-
# Or
|
|
698
|
-
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.sandboxed.md
|
|
699
|
-
|
|
700
|
-
# Enable in VS Code settings.json:
|
|
701
|
-
# "github.copilot.chat.codeGeneration.useInstructionFiles": true
|
|
702
|
-
```
|
|
703
|
-
|
|
704
|
-
#### Instructions with Conditional Application (VS Code)
|
|
705
|
-
|
|
706
|
-
To use the `.instructions.md` file that applies only to certain files:
|
|
707
|
-
|
|
708
|
-
```bash
|
|
709
|
-
# Create instructions folder
|
|
710
|
-
mkdir -p .github/instructions
|
|
711
|
-
|
|
712
|
-
# Download base instructions
|
|
713
|
-
curl -o .github/instructions/memory-bank.instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/memory-bank.instructions.md
|
|
714
|
-
```
|
|
715
|
-
|
|
716
|
-
This file includes `applyTo: "**/*"` which applies to all files, but you can modify it.
|
|
717
|
-
|
|
718
|
-
### Configured AGENTS.md Example
|
|
719
|
-
|
|
720
|
-
```markdown
|
|
721
|
-
# AGENTS.md
|
|
722
|
-
|
|
723
|
-
## Project Configuration
|
|
724
|
-
- **Project ID**: `my-awesome-app`
|
|
725
|
-
- **Workspace**: `C:/workspaces/my-awesome-app`
|
|
726
|
-
|
|
727
|
-
## Memory Bank Instructions
|
|
728
|
-
|
|
729
|
-
### CRITICAL: Always Consult Before Acting
|
|
730
|
-
Before any action, call `memorybank_search` with projectId="my-awesome-app"
|
|
731
|
-
|
|
732
|
-
### Auto-Indexing Policy
|
|
733
|
-
AFTER every file modification:
|
|
734
|
-
memorybank_index_code({ projectId: "my-awesome-app", path: "<modified_file>" })
|
|
735
|
-
|
|
736
|
-
### Session Start
|
|
737
|
-
At the beginning of each session, get context:
|
|
738
|
-
memorybank_get_project_docs({ projectId: "my-awesome-app", document: "activeContext" })
|
|
739
|
-
```
|
|
740
|
-
|
|
741
|
-
---
|
|
742
|
-
|
|
743
|
-
## ๐ฏ Use Cases
|
|
744
|
-
|
|
745
|
-
### 1. First Indexing
|
|
746
|
-
|
|
747
|
-
```
|
|
748
|
-
User: Hi, I want you to help me with my project. The projectId is "my-app"
|
|
749
|
-
Claude: [executes memorybank_get_stats]
|
|
750
|
-
I see there's no code indexed yet.
|
|
751
|
-
Would you like me to index the project so I can help you better?
|
|
752
|
-
|
|
753
|
-
User: Yes
|
|
754
|
-
Claude: [executes memorybank_index_code({ projectId: "my-app" })]
|
|
755
|
-
I've indexed 145 files (1,234 chunks) in 45 seconds.
|
|
756
|
-
How can I help you?
|
|
757
|
-
```
|
|
758
|
-
|
|
759
|
-
### 2. Code Search
|
|
760
|
-
|
|
761
|
-
```
|
|
762
|
-
User: How does authentication work in this project?
|
|
763
|
-
Claude: [executes memorybank_search({ projectId: "my-app", query: "authentication login users" })]
|
|
764
|
-
|
|
765
|
-
Authentication is implemented in src/auth/authService.ts (lines 23-87):
|
|
766
|
-
|
|
767
|
-
[Found code]
|
|
768
|
-
|
|
769
|
-
The system uses JWT tokens with refresh token rotation.
|
|
770
|
-
Validation is done in the middleware src/middleware/auth.ts.
|
|
771
|
-
```
|
|
772
|
-
|
|
773
|
-
### 3. Cross-Project Query
|
|
774
|
-
|
|
775
|
-
```
|
|
776
|
-
User: I'm working on "frontend-v2" but I want to see how pagination was done
|
|
777
|
-
in the "admin-dashboard" project
|
|
778
|
-
|
|
779
|
-
Claude: [executes memorybank_search({
|
|
780
|
-
projectId: "admin-dashboard",
|
|
781
|
-
query: "pagination table listing"
|
|
782
|
-
})]
|
|
783
|
-
|
|
784
|
-
In admin-dashboard, pagination was implemented like this...
|
|
785
|
-
[Shows code from the other project]
|
|
786
|
-
|
|
787
|
-
Would you like me to implement something similar in frontend-v2?
|
|
788
|
-
```
|
|
789
|
-
|
|
790
|
-
### 4. Documentation Generation
|
|
791
|
-
|
|
792
|
-
```
|
|
793
|
-
User: Generate project documentation for new developers
|
|
794
|
-
Claude: [executes memorybank_generate_project_docs({ projectId: "my-app" })]
|
|
795
|
-
|
|
796
|
-
I've generated 6 project knowledge documents:
|
|
797
|
-
- projectBrief.md: General description
|
|
798
|
-
- systemPatterns.md: Architecture and patterns
|
|
799
|
-
- techContext.md: Tech stack
|
|
800
|
-
...
|
|
801
|
-
|
|
802
|
-
You can query them anytime with memorybank_get_project_docs
|
|
803
|
-
```
|
|
804
|
-
|
|
805
|
-
---
|
|
806
|
-
|
|
807
|
-
## ๐ง Configuration Files
|
|
808
|
-
|
|
809
|
-
### `.memoryignore`
|
|
810
|
-
|
|
811
|
-
Similar to `.gitignore`, specifies patterns to exclude from indexing:
|
|
812
|
-
|
|
813
|
-
```bash
|
|
814
|
-
# Dependencies
|
|
815
|
-
node_modules/
|
|
816
|
-
vendor/
|
|
817
|
-
|
|
818
|
-
# Build outputs
|
|
819
|
-
dist/
|
|
820
|
-
build/
|
|
821
|
-
*.min.js
|
|
822
|
-
|
|
823
|
-
# Memory Bank storage
|
|
824
|
-
.memorybank/
|
|
825
|
-
|
|
826
|
-
# Large data files
|
|
827
|
-
*.csv
|
|
828
|
-
*.log
|
|
829
|
-
*.db
|
|
830
|
-
|
|
831
|
-
# Binary and media
|
|
832
|
-
*.exe
|
|
833
|
-
*.pdf
|
|
834
|
-
*.jpg
|
|
835
|
-
*.png
|
|
836
|
-
*.mp4
|
|
837
|
-
```
|
|
838
|
-
|
|
839
|
-
### Respecting `.gitignore`
|
|
840
|
-
|
|
841
|
-
Memory Bank **automatically respects** `.gitignore` patterns in your project, in addition to `.memoryignore` patterns.
|
|
842
|
-
|
|
843
|
-
---
|
|
844
|
-
|
|
845
|
-
## ๐ฐ OpenAI Costs
|
|
846
|
-
|
|
847
|
-
Memory Bank uses `text-embedding-3-small` which is very economical:
|
|
848
|
-
|
|
849
|
-
- **Embedding price**: ~$0.00002 per 1K tokens
|
|
850
|
-
- **Example**: 10,000 files ร 1,000 average tokens = **~$0.20**
|
|
851
|
-
- **Cache**: Embeddings are cached, only regenerated if code changes
|
|
852
|
-
- **Incremental**: Only modified files are reindexed
|
|
853
|
-
|
|
854
|
-
**Searches are extremely cheap** (only 1 embedding per query).
|
|
855
|
-
|
|
856
|
-
**AI Documentation** uses reasoning models which are more expensive but only run when explicitly requested.
|
|
857
|
-
|
|
858
|
-
---
|
|
859
|
-
|
|
860
|
-
## ๐งช Testing
|
|
861
|
-
|
|
862
|
-
```bash
|
|
863
|
-
# Run tests
|
|
864
|
-
npm test
|
|
865
|
-
|
|
866
|
-
# Tests with coverage
|
|
867
|
-
npm test -- --coverage
|
|
868
|
-
```
|
|
869
|
-
|
|
870
|
-
---
|
|
871
|
-
|
|
872
|
-
## ๐ Security and Privacy
|
|
873
|
-
|
|
874
|
-
- โ
**Local vector store**: LanceDB runs on your machine
|
|
875
|
-
- โ
**No telemetry**: We don't send data to external servers
|
|
876
|
-
- โ
**Embeddings only**: OpenAI only sees code text, not sensitive metadata
|
|
877
|
-
- โ
**Respects .gitignore**: Ignored files are not indexed
|
|
878
|
-
- โ
**Secure API key**: Read from environment variables, never hardcoded
|
|
879
|
-
|
|
880
|
-
### Recommendations
|
|
881
|
-
|
|
882
|
-
1. **Don't push `.memorybank/` to git** (already in .gitignore)
|
|
883
|
-
2. **Use `.memoryignore`** to exclude sensitive files
|
|
884
|
-
3. **API keys in environment variables**, never in code
|
|
885
|
-
4. **Verify `.env` is in .gitignore**
|
|
886
|
-
|
|
887
|
-
---
|
|
888
|
-
|
|
889
|
-
## ๐ Troubleshooting
|
|
890
|
-
|
|
891
|
-
### Error: "OPENAI_API_KEY is required"
|
|
892
|
-
|
|
893
|
-
**Solution**: Configure your API key in the MCP environment variables.
|
|
894
|
-
|
|
895
|
-
### Error: "No files found to index"
|
|
896
|
-
|
|
897
|
-
**Possible causes**:
|
|
898
|
-
1. Directory is empty
|
|
899
|
-
2. All files are in .gitignore/.memoryignore
|
|
900
|
-
3. No recognized code files
|
|
901
|
-
|
|
902
|
-
### Searches return irrelevant results
|
|
903
|
-
|
|
904
|
-
**Solutions**:
|
|
905
|
-
1. **Increase `minScore`**: Use 0.8 or 0.9 for more precise results
|
|
906
|
-
2. **Use filters**: `filterByFile` or `filterByLanguage`
|
|
907
|
-
3. **Rephrase query**: Be more specific and descriptive
|
|
908
|
-
4. **Reindex**: `memorybank_index_code({ path: "..." })` (automatically detects changes by hash)
|
|
909
|
-
|
|
910
|
-
### Error: "projectId is required"
|
|
911
|
-
|
|
912
|
-
**Solution**: All tools require `projectId`. Define `projectId` in your `AGENTS.md` file so the agent uses it consistently.
|
|
913
|
-
|
|
914
|
-
### Outdated Index
|
|
915
|
-
|
|
916
|
-
```json
|
|
917
|
-
memorybank_get_stats({})
|
|
918
|
-
```
|
|
919
|
-
|
|
920
|
-
If `pendingFiles` shows pending files, reindex the directory:
|
|
921
|
-
|
|
922
|
-
```json
|
|
923
|
-
{
|
|
924
|
-
"projectId": "my-project",
|
|
925
|
-
"path": "C:/workspaces/my-project/src"
|
|
926
|
-
}
|
|
927
|
-
```
|
|
928
|
-
|
|
929
|
-
The system automatically detects changes by hash. Only use `forceReindex: true` if you need to regenerate embeddings even without changes.
|
|
930
|
-
|
|
931
|
-
---
|
|
932
|
-
|
|
933
|
-
## ๐ Additional Documentation
|
|
934
|
-
|
|
935
|
-
### Instruction Templates
|
|
936
|
-
|
|
937
|
-
**AGENTS.md Format** (multi-agent standard):
|
|
938
|
-
- [AGENTS.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.basic.md) - Basic mode (manual indexing)
|
|
939
|
-
- [AGENTS.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.auto-index.md) - Auto-index mode
|
|
940
|
-
- [AGENTS.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.sandboxed.md) - Sandboxed mode (no direct file access)
|
|
941
|
-
|
|
942
|
-
**VS Code / Copilot Format**:
|
|
943
|
-
- [copilot-instructions.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.basic.md) - Basic mode
|
|
944
|
-
- [copilot-instructions.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.auto-index.md) - Auto-index mode
|
|
945
|
-
- [copilot-instructions.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.sandboxed.md) - Sandboxed mode
|
|
946
|
-
- [memory-bank.instructions.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/memory-bank.instructions.md) - Conditional instructions
|
|
947
|
-
|
|
948
|
-
---
|
|
949
|
-
|
|
950
|
-
## ๐ค Contributing
|
|
951
|
-
|
|
952
|
-
Contributions are welcome!
|
|
953
|
-
|
|
954
|
-
1. Fork the project
|
|
955
|
-
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
956
|
-
3. Commit changes (`git commit -m 'Add some AmazingFeature'`)
|
|
957
|
-
4. Push to branch (`git push origin feature/AmazingFeature`)
|
|
958
|
-
5. Open a Pull Request
|
|
959
|
-
|
|
960
|
-
---
|
|
961
|
-
|
|
962
|
-
## ๐ Inspiration
|
|
963
|
-
|
|
964
|
-
This project combines the best concepts from two complementary approaches:
|
|
965
|
-
|
|
966
|
-
### Cursor IDE - Semantic Indexing
|
|
967
|
-
|
|
968
|
-
The vector indexing and semantic search system is inspired by how Cursor IDE handles code memory:
|
|
969
|
-
|
|
970
|
-
- [Advanced Cursor: Use the Memory Bank](https://medium.com/codetodeploy/advanced-cursor-use-the-memory-bank-to-eliminate-hallucination-affd3fbeefa3) - Eliminate hallucinations with persistent memory
|
|
971
|
-
- [How Cursor Indexes Codebases Fast](https://read.engineerscodex.com/p/how-cursor-indexes-codebases-fast) - Efficient indexing techniques
|
|
972
|
-
|
|
973
|
-
### Cline - Structured Project Documentation
|
|
974
|
-
|
|
975
|
-
The **Project Knowledge Layer** system (structured markdown documents) is inspired by the Cline Memory Bank approach:
|
|
976
|
-
|
|
977
|
-
- [Cline MCP Memory Bank](https://github.com/dazeb/cline-mcp-memory-bank) - Reference Memory Bank implementation for Cline
|
|
978
|
-
- [Cline Memory Bank Custom Instructions](https://gist.github.com/zoharbabin/441e8e8b719a444f26b34bd0b189b283) - Custom instructions for using Memory Bank
|
|
979
|
-
|
|
980
|
-
**Documents from the Cline approach we adopted:**
|
|
981
|
-
| Document | Purpose |
|
|
982
|
-
|----------|---------|
|
|
983
|
-
| `projectBrief.md` | Project requirements and scope |
|
|
984
|
-
| `productContext.md` | Purpose, target users, problems solved |
|
|
985
|
-
| `activeContext.md` | Current tasks, recent changes, next steps |
|
|
986
|
-
| `systemPatterns.md` | Architectural decisions, patterns, relationships |
|
|
987
|
-
| `techContext.md` | Tech stack, dependencies, configurations |
|
|
988
|
-
| `progress.md` | Milestones, overall status, known issues |
|
|
989
|
-
|
|
990
|
-
### Our Contribution
|
|
991
|
-
|
|
992
|
-
Memory Bank MCP **merges both approaches**:
|
|
993
|
-
|
|
994
|
-
1. **Semantic Search** (Cursor-style): Vector embeddings + LanceDB to find relevant code instantly
|
|
995
|
-
2. **Structured Documentation** (Cline-style): 6 AI-generated markdown documents providing global context
|
|
996
|
-
3. **Multi-Project**: Unique capability to query multiple indexed projects from any workspace
|
|
997
|
-
|
|
998
|
-
This combination allows agents to have both **precision** (semantic search) and **global understanding** (structured documentation).
|
|
999
|
-
|
|
1000
|
-
---
|
|
1001
|
-
|
|
1002
|
-
## ๐ License
|
|
1003
|
-
|
|
1004
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
1005
|
-
|
|
1006
|
-
---
|
|
1007
|
-
|
|
1008
|
-
## ๐ Support
|
|
1009
|
-
|
|
1010
|
-
- **Issues**: [GitHub Issues](https://github.com/gcorroto/memory-bank-mcp/issues)
|
|
1011
|
-
- **Documentation**: [Project Wiki](https://github.com/gcorroto/memory-bank-mcp/wiki)
|
|
1012
|
-
- **OpenAI API**: [Official Documentation](https://platform.openai.com/docs)
|
|
1013
|
-
- **LanceDB**: [Documentation](https://lancedb.github.io/lancedb/)
|
|
1014
|
-
|
|
1015
|
-
---
|
|
1016
|
-
|
|
1017
|
-
โญ If you find this project useful, consider giving it a star!
|
|
1018
|
-
|
|
1019
|
-
**Made with โค๏ธ for the AI coding assistants community**
|
|
1
|
+
# Memory Bank MCP - Semantic Code Indexing
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for semantic code indexing. Enables AI agents like Claude, Copilot, Cursor, and others to maintain a "persistent memory" of entire codebases through vector embeddings and semantic search.
|
|
4
|
+
|
|
5
|
+
## ๐ง What is Memory Bank?
|
|
6
|
+
|
|
7
|
+
**Memory Bank** is an external memory system for code agents that solves the fundamental problem of context loss in AIs. It works as the project's "external brain":
|
|
8
|
+
|
|
9
|
+
- **Indexes** all your code using OpenAI embeddings
|
|
10
|
+
- **Chunks** intelligently using AST parsing (functions, classes, methods)
|
|
11
|
+
- **Stores** vectors in LanceDB for ultra-fast searches
|
|
12
|
+
- **Searches** semantically: ask in natural language, get relevant code
|
|
13
|
+
- **Updates** incrementally: only reindexes modified files
|
|
14
|
+
- **Multi-project**: query code from any indexed project from any workspace
|
|
15
|
+
|
|
16
|
+
### Why do you need it?
|
|
17
|
+
|
|
18
|
+
Without Memory Bank, AIs:
|
|
19
|
+
- โ Forget everything between sessions
|
|
20
|
+
- โ Only see small code snippets
|
|
21
|
+
- โ Hallucinate non-existent implementations
|
|
22
|
+
- โ Give generic answers without context
|
|
23
|
+
|
|
24
|
+
With Memory Bank, AIs:
|
|
25
|
+
- โ
Remember the entire codebase
|
|
26
|
+
- โ
Understand architecture and patterns
|
|
27
|
+
- โ
Respond with real project code
|
|
28
|
+
- โ
Generate code consistent with your style
|
|
29
|
+
- โ
**Query multiple indexed projects** simultaneously
|
|
30
|
+
|
|
31
|
+
## ๐ Features
|
|
32
|
+
|
|
33
|
+
### Core Memory Bank (Precise Search)
|
|
34
|
+
- **๐ Semantic Search**: Ask "how does authentication work?" and get relevant code
|
|
35
|
+
- **๐งฉ Intelligent Chunking**: AST parsing for TS/JS/Python with token limits (8192 max)
|
|
36
|
+
- **โก Incremental Updates**: Only reindexes modified files (hash-based detection)
|
|
37
|
+
- **๐พ Embedding Cache**: Avoids regenerating embeddings unnecessarily
|
|
38
|
+
- **๐ฏ Advanced Filters**: By file, language, chunk type
|
|
39
|
+
- **๐ Detailed Statistics**: Know the state of your index at all times
|
|
40
|
+
- **๐ Privacy**: Local vector store, respects .gitignore and .memoryignore
|
|
41
|
+
- **๐ Multi-Project**: Query any indexed project using its `projectId`
|
|
42
|
+
|
|
43
|
+
### Project Knowledge Layer (Global Knowledge)
|
|
44
|
+
- **๐ Automatic Documentation**: Generates 6 structured markdown documents about the project
|
|
45
|
+
- **๐ง AI with Reasoning**: Uses OpenAI Responses API with reasoning models (gpt-5-mini)
|
|
46
|
+
- **๐ Smart Updates**: Only regenerates documents affected by changes
|
|
47
|
+
- **๐ Global Context**: Complements precise search with high-level vision
|
|
48
|
+
|
|
49
|
+
### Context Management (Session Management) ๐
|
|
50
|
+
- **๐ Quick Initialization**: Creates Memory Bank structure with initial templates (no AI)
|
|
51
|
+
- **๐ Session Tracking**: Records active context, recent changes, and next steps
|
|
52
|
+
- **๐ Decision Log**: Documents technical decisions with rationale and alternatives
|
|
53
|
+
- **๐ Progress Tracking**: Manages tasks, milestones, and blockers
|
|
54
|
+
- **๐ก MCP Resources**: Direct read-only access to documents via URIs
|
|
55
|
+
|
|
56
|
+
## ๐ Requirements
|
|
57
|
+
|
|
58
|
+
- **Node.js** >= 18.0.0
|
|
59
|
+
- **OpenAI API Key**: [Get one here](https://platform.openai.com/api-keys)
|
|
60
|
+
- **Disk space**: ~10MB per 10,000 files (embeddings + metadata)
|
|
61
|
+
|
|
62
|
+
## ๐ ๏ธ Installation
|
|
63
|
+
|
|
64
|
+
### Option 1: NPX (Recommended)
|
|
65
|
+
|
|
66
|
+
The easiest way to use Memory Bank MCP without local installation:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx @grec0/memory-bank-mcp@latest
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Option 2: Local Installation
|
|
73
|
+
|
|
74
|
+
For development or contribution:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Clone repository
|
|
78
|
+
git clone https://github.com/gcorroto/memory-bank-mcp.git
|
|
79
|
+
cd memory-bank-mcp
|
|
80
|
+
|
|
81
|
+
# Install dependencies
|
|
82
|
+
npm install
|
|
83
|
+
|
|
84
|
+
# Build
|
|
85
|
+
npm run build
|
|
86
|
+
|
|
87
|
+
# Run
|
|
88
|
+
npm run start
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## โ๏ธ Complete Configuration
|
|
92
|
+
|
|
93
|
+
### Environment Variables
|
|
94
|
+
|
|
95
|
+
Memory Bank is configured through environment variables. You can set them in your MCP client or in a `.env` file:
|
|
96
|
+
|
|
97
|
+
#### Required Variables
|
|
98
|
+
|
|
99
|
+
| Variable | Description |
|
|
100
|
+
|----------|-------------|
|
|
101
|
+
| `OPENAI_API_KEY` | **REQUIRED**. Your OpenAI API key |
|
|
102
|
+
|
|
103
|
+
#### Indexing Variables
|
|
104
|
+
|
|
105
|
+
| Variable | Default | Description |
|
|
106
|
+
|----------|---------|-------------|
|
|
107
|
+
| `MEMORYBANK_STORAGE_PATH` | `.memorybank` | Directory where the vector index is stored |
|
|
108
|
+
| `MEMORYBANK_WORKSPACE_ROOT` | `process.cwd()` | Workspace root (usually auto-detected) |
|
|
109
|
+
| `MEMORYBANK_EMBEDDING_MODEL` | `text-embedding-3-small` | OpenAI embedding model |
|
|
110
|
+
| `MEMORYBANK_EMBEDDING_DIMENSIONS` | `1536` | Vector dimensions (1536 or 512) |
|
|
111
|
+
| `MEMORYBANK_MAX_TOKENS` | `7500` | Maximum tokens per chunk (limit: 8192) |
|
|
112
|
+
| `MEMORYBANK_CHUNK_OVERLAP_TOKENS` | `200` | Overlap between chunks to maintain context |
|
|
113
|
+
|
|
114
|
+
#### Project Knowledge Layer Variables
|
|
115
|
+
|
|
116
|
+
| Variable | Default | Description |
|
|
117
|
+
|----------|---------|-------------|
|
|
118
|
+
| `MEMORYBANK_REASONING_MODEL` | `gpt-5-mini` | Model for generating documentation (supports reasoning) |
|
|
119
|
+
| `MEMORYBANK_REASONING_EFFORT` | `medium` | Reasoning level: `low`, `medium`, `high` |
|
|
120
|
+
| `MEMORYBANK_AUTO_UPDATE_DOCS` | `false` | Auto-regenerate docs when indexing code |
|
|
121
|
+
|
|
122
|
+
### Configuration in Cursor IDE
|
|
123
|
+
|
|
124
|
+
Edit your MCP configuration file:
|
|
125
|
+
|
|
126
|
+
**Windows**: `%APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json`
|
|
127
|
+
|
|
128
|
+
#### Minimal Configuration
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"mcpServers": {
|
|
133
|
+
"memory-bank-mcp": {
|
|
134
|
+
"type": "stdio",
|
|
135
|
+
"command": "npx",
|
|
136
|
+
"args": ["@grec0/memory-bank-mcp@latest"],
|
|
137
|
+
"env": {
|
|
138
|
+
"OPENAI_API_KEY": "sk-your-api-key-here"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Complete Configuration (Recommended)
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcpServers": {
|
|
150
|
+
"memory-bank-mcp": {
|
|
151
|
+
"type": "stdio",
|
|
152
|
+
"command": "npx",
|
|
153
|
+
"args": ["@grec0/memory-bank-mcp@latest"],
|
|
154
|
+
"env": {
|
|
155
|
+
"OPENAI_API_KEY": "sk-your-api-key-here",
|
|
156
|
+
"MEMORYBANK_REASONING_MODEL": "gpt-5-mini",
|
|
157
|
+
"MEMORYBANK_REASONING_EFFORT": "medium",
|
|
158
|
+
"MEMORYBANK_AUTO_UPDATE_DOCS": "false",
|
|
159
|
+
"MEMORYBANK_MAX_TOKENS": "7500",
|
|
160
|
+
"MEMORYBANK_CHUNK_OVERLAP_TOKENS": "200",
|
|
161
|
+
"MEMORYBANK_EMBEDDING_MODEL": "text-embedding-3-small",
|
|
162
|
+
"MEMORYBANK_EMBEDDING_DIMENSIONS": "1536"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Configuration in Claude Desktop
|
|
170
|
+
|
|
171
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
172
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
173
|
+
**Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"mcpServers": {
|
|
178
|
+
"memory-bank": {
|
|
179
|
+
"command": "npx",
|
|
180
|
+
"args": ["@grec0/memory-bank-mcp@latest"],
|
|
181
|
+
"env": {
|
|
182
|
+
"OPENAI_API_KEY": "sk-your-api-key-here",
|
|
183
|
+
"MEMORYBANK_REASONING_MODEL": "gpt-5-mini",
|
|
184
|
+
"MEMORYBANK_REASONING_EFFORT": "medium"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Configuration with Local Installation
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"mcpServers": {
|
|
196
|
+
"memory-bank": {
|
|
197
|
+
"command": "node",
|
|
198
|
+
"args": ["/absolute/path/memory-bank-mcp/dist/index.js"],
|
|
199
|
+
"cwd": "/absolute/path/memory-bank-mcp",
|
|
200
|
+
"env": {
|
|
201
|
+
"OPENAI_API_KEY": "sk-your-api-key-here"
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## ๐ Project Documentation System (Project Knowledge Layer)
|
|
211
|
+
|
|
212
|
+
Memory Bank includes an intelligent documentation system that generates and maintains structured knowledge about your project using AI with reasoning capabilities.
|
|
213
|
+
|
|
214
|
+
### How Does It Work?
|
|
215
|
+
|
|
216
|
+
1. **Code Analysis**: The system analyzes indexed code using semantic search
|
|
217
|
+
2. **AI Generation**: Uses reasoning models (gpt-5-mini) to generate structured documentation
|
|
218
|
+
3. **Incremental Updates**: Only regenerates documents affected by significant changes
|
|
219
|
+
4. **Persistent Storage**: Documents are saved in `.memorybank/projects/{projectId}/docs/`
|
|
220
|
+
|
|
221
|
+
### Generated Documents
|
|
222
|
+
|
|
223
|
+
The system generates **6 markdown documents** that provide different perspectives of the project:
|
|
224
|
+
|
|
225
|
+
| Document | Purpose | Content |
|
|
226
|
+
|----------|---------|---------|
|
|
227
|
+
| `projectBrief.md` | **General Description** | What the project is, its main purpose, key features |
|
|
228
|
+
| `productContext.md` | **Business Perspective** | Why it exists, problems it solves, target users, UX |
|
|
229
|
+
| `systemPatterns.md` | **Architecture and Patterns** | Code structure, design patterns, technical decisions |
|
|
230
|
+
| `techContext.md` | **Tech Stack** | Technologies, dependencies, configurations, integrations |
|
|
231
|
+
| `activeContext.md` | **Current State** | What's being worked on, recent changes, next steps |
|
|
232
|
+
| `progress.md` | **Tracking** | Change history, what works, what's missing, known issues |
|
|
233
|
+
|
|
234
|
+
### Documentation Tools
|
|
235
|
+
|
|
236
|
+
#### `memorybank_generate_project_docs`
|
|
237
|
+
|
|
238
|
+
Generates or regenerates project documentation.
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"projectId": "my-project",
|
|
243
|
+
"force": false
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
- `projectId` **(REQUIRED)**: Project ID
|
|
248
|
+
- `force` (optional): `true` to regenerate everything, `false` for incremental updates
|
|
249
|
+
|
|
250
|
+
#### `memorybank_get_project_docs`
|
|
251
|
+
|
|
252
|
+
Reads generated documentation.
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
// Get summary of all documents
|
|
256
|
+
{
|
|
257
|
+
"projectId": "my-project",
|
|
258
|
+
"document": "summary"
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Get specific document
|
|
262
|
+
{
|
|
263
|
+
"projectId": "my-project",
|
|
264
|
+
"document": "systemPatterns"
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Get all complete documents
|
|
268
|
+
{
|
|
269
|
+
"projectId": "my-project",
|
|
270
|
+
"document": "all",
|
|
271
|
+
"format": "full"
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### Documentation Workflow
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
1. Index code
|
|
279
|
+
memorybank_index_code({ projectId: "my-project" })
|
|
280
|
+
|
|
281
|
+
2. Generate documentation
|
|
282
|
+
memorybank_generate_project_docs({ projectId: "my-project" })
|
|
283
|
+
|
|
284
|
+
3. Query documentation at the start of each session
|
|
285
|
+
memorybank_get_project_docs({ projectId: "my-project", document: "activeContext" })
|
|
286
|
+
|
|
287
|
+
4. Search specific code
|
|
288
|
+
memorybank_search({ projectId: "my-project", query: "..." })
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Auto-Update Documentation
|
|
292
|
+
|
|
293
|
+
If you configure `MEMORYBANK_AUTO_UPDATE_DOCS=true`, documents will be automatically regenerated after each indexing. This is useful for keeping documentation always up to date but consumes more API tokens.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## ๐ Multi-Project: Cross-Project Queries
|
|
298
|
+
|
|
299
|
+
A powerful feature of Memory Bank is the ability to **query any indexed project from any workspace**.
|
|
300
|
+
|
|
301
|
+
### How Does It Work?
|
|
302
|
+
|
|
303
|
+
All indexed projects are stored in a shared vector store, identified by their `projectId`. This means:
|
|
304
|
+
|
|
305
|
+
1. **You can work on Project A** and query code from Project B
|
|
306
|
+
2. **Agents can learn** from similar already-indexed projects
|
|
307
|
+
3. **Reuse patterns** from other projects in your organization
|
|
308
|
+
|
|
309
|
+
### Usage Example
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
# You're working on "frontend-app" but need to see how something was done in "backend-api"
|
|
313
|
+
|
|
314
|
+
User: How was authentication implemented in the backend-api project?
|
|
315
|
+
|
|
316
|
+
Agent: [executes memorybank_search({
|
|
317
|
+
projectId: "backend-api", // Another project
|
|
318
|
+
query: "JWT middleware authentication"
|
|
319
|
+
})]
|
|
320
|
+
|
|
321
|
+
Found the implementation in backend-api:
|
|
322
|
+
- The auth middleware is in src/middleware/auth.ts
|
|
323
|
+
- Uses JWT with refresh tokens
|
|
324
|
+
- Validation is done with jsonwebtoken...
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Requirements for Multi-Project
|
|
328
|
+
|
|
329
|
+
1. **The project must be previously indexed** with its `projectId`
|
|
330
|
+
2. **Use the correct projectId** when making queries
|
|
331
|
+
3. **Documentation is independent** per project
|
|
332
|
+
|
|
333
|
+
### Real Example: Two Related Projects
|
|
334
|
+
|
|
335
|
+
```json
|
|
336
|
+
// Project 1: a2a_gateway (already indexed)
|
|
337
|
+
memorybank_search({
|
|
338
|
+
"projectId": "a2a_gateway",
|
|
339
|
+
"query": "how agents are registered"
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
// Project 2: GREC0AI (current workspace)
|
|
343
|
+
memorybank_search({
|
|
344
|
+
"projectId": "GREC0AI",
|
|
345
|
+
"query": "AgentEntity implementation"
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
// You can query both in the same session!
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## ๐ Available Tools
|
|
354
|
+
|
|
355
|
+
> **โ ๏ธ IMPORTANT**: All tools require mandatory `projectId`. This ID must match the one defined in your `AGENTS.md` file.
|
|
356
|
+
|
|
357
|
+
### `memorybank_index_code`
|
|
358
|
+
|
|
359
|
+
Indexes code semantically to enable searches.
|
|
360
|
+
|
|
361
|
+
**Parameters:**
|
|
362
|
+
- `projectId` **(REQUIRED)**: Unique project identifier
|
|
363
|
+
- `path` (optional): Relative or absolute path (default: workspace root)
|
|
364
|
+
- `recursive` (optional): Index subdirectories (default: true)
|
|
365
|
+
- `forceReindex` (optional): Force complete reindexing (default: false)
|
|
366
|
+
|
|
367
|
+
**Example:**
|
|
368
|
+
```json
|
|
369
|
+
{
|
|
370
|
+
"projectId": "my-project",
|
|
371
|
+
"path": "src/auth",
|
|
372
|
+
"recursive": true
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### `memorybank_search`
|
|
377
|
+
|
|
378
|
+
Searches code by semantic similarity.
|
|
379
|
+
|
|
380
|
+
**Parameters:**
|
|
381
|
+
- `projectId` **(REQUIRED)**: Project identifier to search in
|
|
382
|
+
- `query` (required): Natural language query
|
|
383
|
+
- `topK` (optional): Number of results (default: 10)
|
|
384
|
+
- `minScore` (optional): Minimum score 0-1 (default: 0.4)
|
|
385
|
+
- `filterByFile` (optional): Filter by file pattern
|
|
386
|
+
- `filterByLanguage` (optional): Filter by language
|
|
387
|
+
|
|
388
|
+
**Example:**
|
|
389
|
+
```json
|
|
390
|
+
{
|
|
391
|
+
"projectId": "my-project",
|
|
392
|
+
"query": "function that authenticates users with JWT",
|
|
393
|
+
"topK": 5,
|
|
394
|
+
"minScore": 0.8
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### `memorybank_read_file`
|
|
399
|
+
|
|
400
|
+
Reads file contents.
|
|
401
|
+
|
|
402
|
+
**Parameters:**
|
|
403
|
+
- `path` (required): File path
|
|
404
|
+
- `startLine` (optional): Start line
|
|
405
|
+
- `endLine` (optional): End line
|
|
406
|
+
|
|
407
|
+
### `memorybank_write_file`
|
|
408
|
+
|
|
409
|
+
Writes a file and automatically reindexes it.
|
|
410
|
+
|
|
411
|
+
**Parameters:**
|
|
412
|
+
- `projectId` **(REQUIRED)**: Project identifier for reindexing
|
|
413
|
+
- `path` (required): File path
|
|
414
|
+
- `content` (required): File content
|
|
415
|
+
- `autoReindex` (optional): Auto-reindex (default: true)
|
|
416
|
+
|
|
417
|
+
### `memorybank_get_stats`
|
|
418
|
+
|
|
419
|
+
Gets Memory Bank statistics.
|
|
420
|
+
|
|
421
|
+
### `memorybank_analyze_coverage`
|
|
422
|
+
|
|
423
|
+
Analyzes project indexing coverage.
|
|
424
|
+
|
|
425
|
+
**Parameters:**
|
|
426
|
+
- `projectId` **(REQUIRED)**: Project identifier to analyze
|
|
427
|
+
- `path` **(REQUIRED)**: Absolute workspace path to analyze
|
|
428
|
+
|
|
429
|
+
**Example:**
|
|
430
|
+
```json
|
|
431
|
+
{
|
|
432
|
+
"projectId": "my-project",
|
|
433
|
+
"path": "C:/workspaces/my-project"
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### `memorybank_generate_project_docs`
|
|
438
|
+
|
|
439
|
+
Generates structured project documentation using AI with reasoning.
|
|
440
|
+
|
|
441
|
+
**Parameters:**
|
|
442
|
+
- `projectId` **(REQUIRED)**: Project identifier
|
|
443
|
+
- `force` (optional): Force regeneration (default: false)
|
|
444
|
+
|
|
445
|
+
### `memorybank_get_project_docs`
|
|
446
|
+
|
|
447
|
+
Reads AI-generated project documentation.
|
|
448
|
+
|
|
449
|
+
**Parameters:**
|
|
450
|
+
- `projectId` **(REQUIRED)**: Project identifier
|
|
451
|
+
- `document` (optional): `"summary"`, `"all"`, or specific name (`projectBrief`, `systemPatterns`, etc.)
|
|
452
|
+
- `format` (optional): `"full"` or `"summary"` (default: "full")
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## ๐ Context Management Tools (Cline-style)
|
|
457
|
+
|
|
458
|
+
These tools allow managing project context manually, complementing automatic AI generation.
|
|
459
|
+
|
|
460
|
+
### `memorybank_initialize`
|
|
461
|
+
|
|
462
|
+
Initializes Memory Bank for a new project. Creates directory structure and 7 markdown documents with initial templates. **Does not use AI**.
|
|
463
|
+
|
|
464
|
+
**Parameters:**
|
|
465
|
+
- `projectId` **(REQUIRED)**: Unique project identifier
|
|
466
|
+
- `projectPath` **(REQUIRED)**: Absolute project path
|
|
467
|
+
- `projectName` (optional): Human-readable project name
|
|
468
|
+
- `description` (optional): Initial project description
|
|
469
|
+
|
|
470
|
+
**Example:**
|
|
471
|
+
```json
|
|
472
|
+
{
|
|
473
|
+
"projectId": "my-project",
|
|
474
|
+
"projectPath": "C:/workspaces/my-project",
|
|
475
|
+
"projectName": "My Awesome Project",
|
|
476
|
+
"description": "A web application for..."
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
**Created documents:**
|
|
481
|
+
- `projectBrief.md` - General description
|
|
482
|
+
- `productContext.md` - Product context
|
|
483
|
+
- `systemPatterns.md` - Architecture patterns
|
|
484
|
+
- `techContext.md` - Tech stack
|
|
485
|
+
- `activeContext.md` - Session context
|
|
486
|
+
- `progress.md` - Progress tracking
|
|
487
|
+
- `decisionLog.md` - Decision log
|
|
488
|
+
|
|
489
|
+
### `memorybank_update_context`
|
|
490
|
+
|
|
491
|
+
Updates active context with current session information. Maintains history of the last 10 sessions. **Does not use AI**.
|
|
492
|
+
|
|
493
|
+
**Parameters:**
|
|
494
|
+
- `projectId` **(REQUIRED)**: Project identifier
|
|
495
|
+
- `currentSession` (optional): Session information (date, mode, task)
|
|
496
|
+
- `recentChanges` (optional): List of recent changes
|
|
497
|
+
- `openQuestions` (optional): Pending questions
|
|
498
|
+
- `nextSteps` (optional): Planned next steps
|
|
499
|
+
- `notes` (optional): Additional notes
|
|
500
|
+
|
|
501
|
+
**Example:**
|
|
502
|
+
```json
|
|
503
|
+
{
|
|
504
|
+
"projectId": "my-project",
|
|
505
|
+
"currentSession": {
|
|
506
|
+
"mode": "development",
|
|
507
|
+
"task": "Implementing authentication"
|
|
508
|
+
},
|
|
509
|
+
"recentChanges": ["Added JWT middleware", "Created user model"],
|
|
510
|
+
"nextSteps": ["Add refresh token", "Create login endpoint"]
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### `memorybank_record_decision`
|
|
515
|
+
|
|
516
|
+
Records technical decisions with rationale in the decision log. **Does not use AI**.
|
|
517
|
+
|
|
518
|
+
**Parameters:**
|
|
519
|
+
- `projectId` **(REQUIRED)**: Project identifier
|
|
520
|
+
- `decision` **(REQUIRED)**: Object with decision information
|
|
521
|
+
- `title` **(REQUIRED)**: Decision title
|
|
522
|
+
- `description` **(REQUIRED)**: What was decided
|
|
523
|
+
- `rationale` **(REQUIRED)**: Why this decision was made
|
|
524
|
+
- `alternatives` (optional): Considered alternatives
|
|
525
|
+
- `impact` (optional): Expected impact
|
|
526
|
+
- `category` (optional): architecture, technology, dependencies, etc.
|
|
527
|
+
|
|
528
|
+
**Example:**
|
|
529
|
+
```json
|
|
530
|
+
{
|
|
531
|
+
"projectId": "my-project",
|
|
532
|
+
"decision": {
|
|
533
|
+
"title": "JWT Authentication",
|
|
534
|
+
"description": "Use JWT tokens for API authentication",
|
|
535
|
+
"rationale": "Stateless, scalable, works well with microservices",
|
|
536
|
+
"alternatives": ["Session-based auth", "OAuth only"],
|
|
537
|
+
"category": "architecture"
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
### `memorybank_track_progress`
|
|
543
|
+
|
|
544
|
+
Updates progress tracking with tasks, milestones, and blockers. **Does not use AI**.
|
|
545
|
+
|
|
546
|
+
**Parameters:**
|
|
547
|
+
- `projectId` **(REQUIRED)**: Project identifier
|
|
548
|
+
- `progress` (optional): Tasks to update
|
|
549
|
+
- `completed`: Completed tasks
|
|
550
|
+
- `inProgress`: Tasks in progress
|
|
551
|
+
- `blocked`: Blocked tasks
|
|
552
|
+
- `upcoming`: Upcoming tasks
|
|
553
|
+
- `milestone` (optional): Milestone to add/update (name, status, targetDate, notes)
|
|
554
|
+
- `blockers` (optional): List of blockers with severity (low/medium/high)
|
|
555
|
+
- `phase` (optional): Current project phase
|
|
556
|
+
- `phaseStatus` (optional): Phase status
|
|
557
|
+
|
|
558
|
+
**Example:**
|
|
559
|
+
```json
|
|
560
|
+
{
|
|
561
|
+
"projectId": "my-project",
|
|
562
|
+
"progress": {
|
|
563
|
+
"completed": ["Setup project structure", "Configure ESLint"],
|
|
564
|
+
"inProgress": ["Implement user authentication"],
|
|
565
|
+
"upcoming": ["Add unit tests"]
|
|
566
|
+
},
|
|
567
|
+
"milestone": {
|
|
568
|
+
"name": "MVP",
|
|
569
|
+
"status": "in_progress",
|
|
570
|
+
"targetDate": "2026-02-01"
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
## ๐ก MCP Resources (Direct Access)
|
|
578
|
+
|
|
579
|
+
Memory Bank exposes MCP resources for direct read-only access to project documents.
|
|
580
|
+
|
|
581
|
+
| Resource URI | Content |
|
|
582
|
+
|--------------|---------|
|
|
583
|
+
| `memory://{projectId}/active` | Active session context |
|
|
584
|
+
| `memory://{projectId}/progress` | Progress tracking |
|
|
585
|
+
| `memory://{projectId}/decisions` | Technical decision log |
|
|
586
|
+
| `memory://{projectId}/context` | Project context (brief + tech) |
|
|
587
|
+
| `memory://{projectId}/patterns` | System patterns |
|
|
588
|
+
| `memory://{projectId}/brief` | Project description |
|
|
589
|
+
|
|
590
|
+
**Usage example:**
|
|
591
|
+
```
|
|
592
|
+
// Access active context for "my-project"
|
|
593
|
+
memory://my-project/active
|
|
594
|
+
|
|
595
|
+
// Access decision log
|
|
596
|
+
memory://my-project/decisions
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Resources are read-only. To modify documents, use the corresponding tools (`memorybank_update_context`, `memorybank_record_decision`, etc.).
|
|
600
|
+
|
|
601
|
+
---
|
|
602
|
+
|
|
603
|
+
## ๐ Agent Instruction Templates
|
|
604
|
+
|
|
605
|
+
Memory Bank includes instruction templates in two formats to configure agent behavior:
|
|
606
|
+
|
|
607
|
+
- **AGENTS.md** - Standard [agents.md](https://agents.md/) (compatible with Claude, Cursor, multiple agents)
|
|
608
|
+
- **VSCode/Copilot** - `.github/copilot-instructions.md` format for GitHub Copilot in VS Code
|
|
609
|
+
|
|
610
|
+
### Available Modes
|
|
611
|
+
|
|
612
|
+
| Mode | File | Ideal Use |
|
|
613
|
+
|------|------|-----------|
|
|
614
|
+
| **Basic** | `AGENTS.basic.md` | Total control, manual indexing |
|
|
615
|
+
| **Auto-Index** | `AGENTS.auto-index.md` | Active development, automatic sync |
|
|
616
|
+
| **Sandboxed** | `AGENTS.sandboxed.md` | Environments without direct file access |
|
|
617
|
+
|
|
618
|
+
### 1. Basic Mode
|
|
619
|
+
|
|
620
|
+
**For projects where you want total control.**
|
|
621
|
+
|
|
622
|
+
- โ
Agent ALWAYS consults Memory Bank before acting
|
|
623
|
+
- โ
Only indexes when user explicitly requests
|
|
624
|
+
- โ
Asks permission before modifying code
|
|
625
|
+
- โ
Suggests reindexing after changes
|
|
626
|
+
|
|
627
|
+
**Ideal for**: Critical projects, code review, onboarding.
|
|
628
|
+
|
|
629
|
+
### 2. Auto-Index Mode
|
|
630
|
+
|
|
631
|
+
**For active development with automatic synchronization.**
|
|
632
|
+
|
|
633
|
+
- โ
Agent consults Memory Bank automatically
|
|
634
|
+
- โ
Reindexes EVERY file after modifying it
|
|
635
|
+
- โ
Keeps Memory Bank always up to date
|
|
636
|
+
- โ
Can read/write files directly
|
|
637
|
+
|
|
638
|
+
**Ideal for**: Active development, rapid iteration, teams.
|
|
639
|
+
|
|
640
|
+
### 3. Sandboxed Mode
|
|
641
|
+
|
|
642
|
+
**For environments without direct file system access.**
|
|
643
|
+
|
|
644
|
+
- โ
Does NOT have direct file access
|
|
645
|
+
- โ
MUST use `memorybank_read_file` to read
|
|
646
|
+
- โ
MUST use `memorybank_write_file` to write
|
|
647
|
+
- โ
Auto-reindexes automatically on each write
|
|
648
|
+
|
|
649
|
+
**Ideal for**: Restricted environments, remote development, security.
|
|
650
|
+
|
|
651
|
+
### Available Templates
|
|
652
|
+
|
|
653
|
+
All templates are available in the GitHub repository:
|
|
654
|
+
|
|
655
|
+
#### AGENTS.md Format (Cursor, Claude, Multi-agent)
|
|
656
|
+
|
|
657
|
+
| Mode | URL |
|
|
658
|
+
|------|-----|
|
|
659
|
+
| **Basic** | [AGENTS.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.basic.md) |
|
|
660
|
+
| **Auto-Index** | [AGENTS.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.auto-index.md) |
|
|
661
|
+
| **Sandboxed** | [AGENTS.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.sandboxed.md) |
|
|
662
|
+
|
|
663
|
+
**Installation:**
|
|
664
|
+
|
|
665
|
+
```bash
|
|
666
|
+
# Download template (choose one)
|
|
667
|
+
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.basic.md
|
|
668
|
+
# Or
|
|
669
|
+
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.auto-index.md
|
|
670
|
+
# Or
|
|
671
|
+
curl -o AGENTS.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/AGENTS.sandboxed.md
|
|
672
|
+
|
|
673
|
+
# Edit placeholders:
|
|
674
|
+
# - Replace {{PROJECT_ID}} with your unique project ID
|
|
675
|
+
# - Replace {{WORKSPACE_PATH}} with the absolute workspace path
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
#### VS Code / GitHub Copilot Format
|
|
679
|
+
|
|
680
|
+
| Mode | URL |
|
|
681
|
+
|------|-----|
|
|
682
|
+
| **Basic** | [copilot-instructions.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.basic.md) |
|
|
683
|
+
| **Auto-Index** | [copilot-instructions.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.auto-index.md) |
|
|
684
|
+
| **Sandboxed** | [copilot-instructions.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.sandboxed.md) |
|
|
685
|
+
| **Instructions** | [memory-bank.instructions.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/memory-bank.instructions.md) |
|
|
686
|
+
|
|
687
|
+
**Installation:**
|
|
688
|
+
|
|
689
|
+
```bash
|
|
690
|
+
# Create .github folder if it doesn't exist
|
|
691
|
+
mkdir -p .github
|
|
692
|
+
|
|
693
|
+
# Download template (choose one)
|
|
694
|
+
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.basic.md
|
|
695
|
+
# Or
|
|
696
|
+
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.auto-index.md
|
|
697
|
+
# Or
|
|
698
|
+
curl -o .github/copilot-instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/copilot-instructions.sandboxed.md
|
|
699
|
+
|
|
700
|
+
# Enable in VS Code settings.json:
|
|
701
|
+
# "github.copilot.chat.codeGeneration.useInstructionFiles": true
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
#### Instructions with Conditional Application (VS Code)
|
|
705
|
+
|
|
706
|
+
To use the `.instructions.md` file that applies only to certain files:
|
|
707
|
+
|
|
708
|
+
```bash
|
|
709
|
+
# Create instructions folder
|
|
710
|
+
mkdir -p .github/instructions
|
|
711
|
+
|
|
712
|
+
# Download base instructions
|
|
713
|
+
curl -o .github/instructions/memory-bank.instructions.md https://raw.githubusercontent.com/gcorroto/memory-bank-mcp/main/templates/vscode/memory-bank.instructions.md
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
This file includes `applyTo: "**/*"` which applies to all files, but you can modify it.
|
|
717
|
+
|
|
718
|
+
### Configured AGENTS.md Example
|
|
719
|
+
|
|
720
|
+
```markdown
|
|
721
|
+
# AGENTS.md
|
|
722
|
+
|
|
723
|
+
## Project Configuration
|
|
724
|
+
- **Project ID**: `my-awesome-app`
|
|
725
|
+
- **Workspace**: `C:/workspaces/my-awesome-app`
|
|
726
|
+
|
|
727
|
+
## Memory Bank Instructions
|
|
728
|
+
|
|
729
|
+
### CRITICAL: Always Consult Before Acting
|
|
730
|
+
Before any action, call `memorybank_search` with projectId="my-awesome-app"
|
|
731
|
+
|
|
732
|
+
### Auto-Indexing Policy
|
|
733
|
+
AFTER every file modification:
|
|
734
|
+
memorybank_index_code({ projectId: "my-awesome-app", path: "<modified_file>" })
|
|
735
|
+
|
|
736
|
+
### Session Start
|
|
737
|
+
At the beginning of each session, get context:
|
|
738
|
+
memorybank_get_project_docs({ projectId: "my-awesome-app", document: "activeContext" })
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
---
|
|
742
|
+
|
|
743
|
+
## ๐ฏ Use Cases
|
|
744
|
+
|
|
745
|
+
### 1. First Indexing
|
|
746
|
+
|
|
747
|
+
```
|
|
748
|
+
User: Hi, I want you to help me with my project. The projectId is "my-app"
|
|
749
|
+
Claude: [executes memorybank_get_stats]
|
|
750
|
+
I see there's no code indexed yet.
|
|
751
|
+
Would you like me to index the project so I can help you better?
|
|
752
|
+
|
|
753
|
+
User: Yes
|
|
754
|
+
Claude: [executes memorybank_index_code({ projectId: "my-app" })]
|
|
755
|
+
I've indexed 145 files (1,234 chunks) in 45 seconds.
|
|
756
|
+
How can I help you?
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
### 2. Code Search
|
|
760
|
+
|
|
761
|
+
```
|
|
762
|
+
User: How does authentication work in this project?
|
|
763
|
+
Claude: [executes memorybank_search({ projectId: "my-app", query: "authentication login users" })]
|
|
764
|
+
|
|
765
|
+
Authentication is implemented in src/auth/authService.ts (lines 23-87):
|
|
766
|
+
|
|
767
|
+
[Found code]
|
|
768
|
+
|
|
769
|
+
The system uses JWT tokens with refresh token rotation.
|
|
770
|
+
Validation is done in the middleware src/middleware/auth.ts.
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
### 3. Cross-Project Query
|
|
774
|
+
|
|
775
|
+
```
|
|
776
|
+
User: I'm working on "frontend-v2" but I want to see how pagination was done
|
|
777
|
+
in the "admin-dashboard" project
|
|
778
|
+
|
|
779
|
+
Claude: [executes memorybank_search({
|
|
780
|
+
projectId: "admin-dashboard",
|
|
781
|
+
query: "pagination table listing"
|
|
782
|
+
})]
|
|
783
|
+
|
|
784
|
+
In admin-dashboard, pagination was implemented like this...
|
|
785
|
+
[Shows code from the other project]
|
|
786
|
+
|
|
787
|
+
Would you like me to implement something similar in frontend-v2?
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
### 4. Documentation Generation
|
|
791
|
+
|
|
792
|
+
```
|
|
793
|
+
User: Generate project documentation for new developers
|
|
794
|
+
Claude: [executes memorybank_generate_project_docs({ projectId: "my-app" })]
|
|
795
|
+
|
|
796
|
+
I've generated 6 project knowledge documents:
|
|
797
|
+
- projectBrief.md: General description
|
|
798
|
+
- systemPatterns.md: Architecture and patterns
|
|
799
|
+
- techContext.md: Tech stack
|
|
800
|
+
...
|
|
801
|
+
|
|
802
|
+
You can query them anytime with memorybank_get_project_docs
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
---
|
|
806
|
+
|
|
807
|
+
## ๐ง Configuration Files
|
|
808
|
+
|
|
809
|
+
### `.memoryignore`
|
|
810
|
+
|
|
811
|
+
Similar to `.gitignore`, specifies patterns to exclude from indexing:
|
|
812
|
+
|
|
813
|
+
```bash
|
|
814
|
+
# Dependencies
|
|
815
|
+
node_modules/
|
|
816
|
+
vendor/
|
|
817
|
+
|
|
818
|
+
# Build outputs
|
|
819
|
+
dist/
|
|
820
|
+
build/
|
|
821
|
+
*.min.js
|
|
822
|
+
|
|
823
|
+
# Memory Bank storage
|
|
824
|
+
.memorybank/
|
|
825
|
+
|
|
826
|
+
# Large data files
|
|
827
|
+
*.csv
|
|
828
|
+
*.log
|
|
829
|
+
*.db
|
|
830
|
+
|
|
831
|
+
# Binary and media
|
|
832
|
+
*.exe
|
|
833
|
+
*.pdf
|
|
834
|
+
*.jpg
|
|
835
|
+
*.png
|
|
836
|
+
*.mp4
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
### Respecting `.gitignore`
|
|
840
|
+
|
|
841
|
+
Memory Bank **automatically respects** `.gitignore` patterns in your project, in addition to `.memoryignore` patterns.
|
|
842
|
+
|
|
843
|
+
---
|
|
844
|
+
|
|
845
|
+
## ๐ฐ OpenAI Costs
|
|
846
|
+
|
|
847
|
+
Memory Bank uses `text-embedding-3-small` which is very economical:
|
|
848
|
+
|
|
849
|
+
- **Embedding price**: ~$0.00002 per 1K tokens
|
|
850
|
+
- **Example**: 10,000 files ร 1,000 average tokens = **~$0.20**
|
|
851
|
+
- **Cache**: Embeddings are cached, only regenerated if code changes
|
|
852
|
+
- **Incremental**: Only modified files are reindexed
|
|
853
|
+
|
|
854
|
+
**Searches are extremely cheap** (only 1 embedding per query).
|
|
855
|
+
|
|
856
|
+
**AI Documentation** uses reasoning models which are more expensive but only run when explicitly requested.
|
|
857
|
+
|
|
858
|
+
---
|
|
859
|
+
|
|
860
|
+
## ๐งช Testing
|
|
861
|
+
|
|
862
|
+
```bash
|
|
863
|
+
# Run tests
|
|
864
|
+
npm test
|
|
865
|
+
|
|
866
|
+
# Tests with coverage
|
|
867
|
+
npm test -- --coverage
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
---
|
|
871
|
+
|
|
872
|
+
## ๐ Security and Privacy
|
|
873
|
+
|
|
874
|
+
- โ
**Local vector store**: LanceDB runs on your machine
|
|
875
|
+
- โ
**No telemetry**: We don't send data to external servers
|
|
876
|
+
- โ
**Embeddings only**: OpenAI only sees code text, not sensitive metadata
|
|
877
|
+
- โ
**Respects .gitignore**: Ignored files are not indexed
|
|
878
|
+
- โ
**Secure API key**: Read from environment variables, never hardcoded
|
|
879
|
+
|
|
880
|
+
### Recommendations
|
|
881
|
+
|
|
882
|
+
1. **Don't push `.memorybank/` to git** (already in .gitignore)
|
|
883
|
+
2. **Use `.memoryignore`** to exclude sensitive files
|
|
884
|
+
3. **API keys in environment variables**, never in code
|
|
885
|
+
4. **Verify `.env` is in .gitignore**
|
|
886
|
+
|
|
887
|
+
---
|
|
888
|
+
|
|
889
|
+
## ๐ Troubleshooting
|
|
890
|
+
|
|
891
|
+
### Error: "OPENAI_API_KEY is required"
|
|
892
|
+
|
|
893
|
+
**Solution**: Configure your API key in the MCP environment variables.
|
|
894
|
+
|
|
895
|
+
### Error: "No files found to index"
|
|
896
|
+
|
|
897
|
+
**Possible causes**:
|
|
898
|
+
1. Directory is empty
|
|
899
|
+
2. All files are in .gitignore/.memoryignore
|
|
900
|
+
3. No recognized code files
|
|
901
|
+
|
|
902
|
+
### Searches return irrelevant results
|
|
903
|
+
|
|
904
|
+
**Solutions**:
|
|
905
|
+
1. **Increase `minScore`**: Use 0.8 or 0.9 for more precise results
|
|
906
|
+
2. **Use filters**: `filterByFile` or `filterByLanguage`
|
|
907
|
+
3. **Rephrase query**: Be more specific and descriptive
|
|
908
|
+
4. **Reindex**: `memorybank_index_code({ path: "..." })` (automatically detects changes by hash)
|
|
909
|
+
|
|
910
|
+
### Error: "projectId is required"
|
|
911
|
+
|
|
912
|
+
**Solution**: All tools require `projectId`. Define `projectId` in your `AGENTS.md` file so the agent uses it consistently.
|
|
913
|
+
|
|
914
|
+
### Outdated Index
|
|
915
|
+
|
|
916
|
+
```json
|
|
917
|
+
memorybank_get_stats({})
|
|
918
|
+
```
|
|
919
|
+
|
|
920
|
+
If `pendingFiles` shows pending files, reindex the directory:
|
|
921
|
+
|
|
922
|
+
```json
|
|
923
|
+
{
|
|
924
|
+
"projectId": "my-project",
|
|
925
|
+
"path": "C:/workspaces/my-project/src"
|
|
926
|
+
}
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
The system automatically detects changes by hash. Only use `forceReindex: true` if you need to regenerate embeddings even without changes.
|
|
930
|
+
|
|
931
|
+
---
|
|
932
|
+
|
|
933
|
+
## ๐ Additional Documentation
|
|
934
|
+
|
|
935
|
+
### Instruction Templates
|
|
936
|
+
|
|
937
|
+
**AGENTS.md Format** (multi-agent standard):
|
|
938
|
+
- [AGENTS.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.basic.md) - Basic mode (manual indexing)
|
|
939
|
+
- [AGENTS.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.auto-index.md) - Auto-index mode
|
|
940
|
+
- [AGENTS.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/AGENTS.sandboxed.md) - Sandboxed mode (no direct file access)
|
|
941
|
+
|
|
942
|
+
**VS Code / Copilot Format**:
|
|
943
|
+
- [copilot-instructions.basic.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.basic.md) - Basic mode
|
|
944
|
+
- [copilot-instructions.auto-index.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.auto-index.md) - Auto-index mode
|
|
945
|
+
- [copilot-instructions.sandboxed.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/copilot-instructions.sandboxed.md) - Sandboxed mode
|
|
946
|
+
- [memory-bank.instructions.md](https://github.com/gcorroto/memory-bank-mcp/blob/main/templates/vscode/memory-bank.instructions.md) - Conditional instructions
|
|
947
|
+
|
|
948
|
+
---
|
|
949
|
+
|
|
950
|
+
## ๐ค Contributing
|
|
951
|
+
|
|
952
|
+
Contributions are welcome!
|
|
953
|
+
|
|
954
|
+
1. Fork the project
|
|
955
|
+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
|
956
|
+
3. Commit changes (`git commit -m 'Add some AmazingFeature'`)
|
|
957
|
+
4. Push to branch (`git push origin feature/AmazingFeature`)
|
|
958
|
+
5. Open a Pull Request
|
|
959
|
+
|
|
960
|
+
---
|
|
961
|
+
|
|
962
|
+
## ๐ Inspiration
|
|
963
|
+
|
|
964
|
+
This project combines the best concepts from two complementary approaches:
|
|
965
|
+
|
|
966
|
+
### Cursor IDE - Semantic Indexing
|
|
967
|
+
|
|
968
|
+
The vector indexing and semantic search system is inspired by how Cursor IDE handles code memory:
|
|
969
|
+
|
|
970
|
+
- [Advanced Cursor: Use the Memory Bank](https://medium.com/codetodeploy/advanced-cursor-use-the-memory-bank-to-eliminate-hallucination-affd3fbeefa3) - Eliminate hallucinations with persistent memory
|
|
971
|
+
- [How Cursor Indexes Codebases Fast](https://read.engineerscodex.com/p/how-cursor-indexes-codebases-fast) - Efficient indexing techniques
|
|
972
|
+
|
|
973
|
+
### Cline - Structured Project Documentation
|
|
974
|
+
|
|
975
|
+
The **Project Knowledge Layer** system (structured markdown documents) is inspired by the Cline Memory Bank approach:
|
|
976
|
+
|
|
977
|
+
- [Cline MCP Memory Bank](https://github.com/dazeb/cline-mcp-memory-bank) - Reference Memory Bank implementation for Cline
|
|
978
|
+
- [Cline Memory Bank Custom Instructions](https://gist.github.com/zoharbabin/441e8e8b719a444f26b34bd0b189b283) - Custom instructions for using Memory Bank
|
|
979
|
+
|
|
980
|
+
**Documents from the Cline approach we adopted:**
|
|
981
|
+
| Document | Purpose |
|
|
982
|
+
|----------|---------|
|
|
983
|
+
| `projectBrief.md` | Project requirements and scope |
|
|
984
|
+
| `productContext.md` | Purpose, target users, problems solved |
|
|
985
|
+
| `activeContext.md` | Current tasks, recent changes, next steps |
|
|
986
|
+
| `systemPatterns.md` | Architectural decisions, patterns, relationships |
|
|
987
|
+
| `techContext.md` | Tech stack, dependencies, configurations |
|
|
988
|
+
| `progress.md` | Milestones, overall status, known issues |
|
|
989
|
+
|
|
990
|
+
### Our Contribution
|
|
991
|
+
|
|
992
|
+
Memory Bank MCP **merges both approaches**:
|
|
993
|
+
|
|
994
|
+
1. **Semantic Search** (Cursor-style): Vector embeddings + LanceDB to find relevant code instantly
|
|
995
|
+
2. **Structured Documentation** (Cline-style): 6 AI-generated markdown documents providing global context
|
|
996
|
+
3. **Multi-Project**: Unique capability to query multiple indexed projects from any workspace
|
|
997
|
+
|
|
998
|
+
This combination allows agents to have both **precision** (semantic search) and **global understanding** (structured documentation).
|
|
999
|
+
|
|
1000
|
+
---
|
|
1001
|
+
|
|
1002
|
+
## ๐ License
|
|
1003
|
+
|
|
1004
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
1005
|
+
|
|
1006
|
+
---
|
|
1007
|
+
|
|
1008
|
+
## ๐ Support
|
|
1009
|
+
|
|
1010
|
+
- **Issues**: [GitHub Issues](https://github.com/gcorroto/memory-bank-mcp/issues)
|
|
1011
|
+
- **Documentation**: [Project Wiki](https://github.com/gcorroto/memory-bank-mcp/wiki)
|
|
1012
|
+
- **OpenAI API**: [Official Documentation](https://platform.openai.com/docs)
|
|
1013
|
+
- **LanceDB**: [Documentation](https://lancedb.github.io/lancedb/)
|
|
1014
|
+
|
|
1015
|
+
---
|
|
1016
|
+
|
|
1017
|
+
โญ If you find this project useful, consider giving it a star!
|
|
1018
|
+
|
|
1019
|
+
**Made with โค๏ธ for the AI coding assistants community**
|