@agentbrain/mcp-server 1.4.36 → 1.4.37
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 +192 -9
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -1
- package/dist/tools/load-context.d.ts.map +1 -1
- package/dist/tools/load-context.js +9 -8
- package/dist/tools/load-context.js.map +1 -1
- package/dist/tools/save-context.d.ts +39 -0
- package/dist/tools/save-context.d.ts.map +1 -0
- package/dist/tools/save-context.js +97 -0
- package/dist/tools/save-context.js.map +1 -0
- package/dist/tools/setup-repo.d.ts +28 -0
- package/dist/tools/setup-repo.d.ts.map +1 -0
- package/dist/tools/setup-repo.js +73 -0
- package/dist/tools/setup-repo.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -89,11 +89,15 @@ Then reopen it.
|
|
|
89
89
|
|
|
90
90
|
1. Start a new conversation in Claude Desktop
|
|
91
91
|
2. Look for the **🔌 icon** in the toolbar or bottom of the chat
|
|
92
|
-
3. Click it - you should see "agentbrain" with
|
|
92
|
+
3. Click it - you should see "agentbrain" with 9 tools:
|
|
93
93
|
- `scan_repo`
|
|
94
|
+
- `load_standards`
|
|
94
95
|
- `load_context`
|
|
96
|
+
- `setup_repo` ⭐ NEW
|
|
97
|
+
- `save_context` ⭐ NEW
|
|
95
98
|
- `load_spec`
|
|
96
|
-
- `
|
|
99
|
+
- `detect_doom_loop`
|
|
100
|
+
- `create_spec`
|
|
97
101
|
- `save_handoff`
|
|
98
102
|
|
|
99
103
|
#### Step 6: Try It Out!
|
|
@@ -222,7 +226,7 @@ Look for MCP tools in the Windsurf interface, then ask:
|
|
|
222
226
|
|
|
223
227
|
## Available Tools
|
|
224
228
|
|
|
225
|
-
Once configured, your agent can use these
|
|
229
|
+
Once configured, your agent can use these 9 tools:
|
|
226
230
|
|
|
227
231
|
### 1. `scan_repo` - Analyze Repository Structure
|
|
228
232
|
|
|
@@ -375,6 +379,161 @@ This ensures the next session starts with awareness of potential issues.
|
|
|
375
379
|
|
|
376
380
|
---
|
|
377
381
|
|
|
382
|
+
### 6. `setup_repo` ⭐ NEW - Agent-Driven Context Setup
|
|
383
|
+
|
|
384
|
+
**What it does:** Scans the repository and returns file tree + key file contents so your **agent** can generate context documents. No API key required!
|
|
385
|
+
|
|
386
|
+
**Parameters:**
|
|
387
|
+
- `repo_path` (required): Path to repository
|
|
388
|
+
|
|
389
|
+
**Example prompts:**
|
|
390
|
+
- "Set up AgentBrain for this project"
|
|
391
|
+
- "Scan /path/to/project and help me generate context"
|
|
392
|
+
- "Initialize AgentBrain context for my repo"
|
|
393
|
+
|
|
394
|
+
**Returns:**
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"repo_path": "/path/to/project",
|
|
398
|
+
"file_tree": "src/index.ts (typescript)\nsrc/auth.ts (typescript)\n...",
|
|
399
|
+
"key_files": [
|
|
400
|
+
{ "path": "package.json", "content": "..." },
|
|
401
|
+
{ "path": "src/index.ts", "content": "..." }
|
|
402
|
+
],
|
|
403
|
+
"instructions": "Based on the file tree and key files above, generate:\n1. context.md\n2. dependency-map.md\n3. patterns.md\nThen call save_context()..."
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**How it works:**
|
|
408
|
+
1. Scans repository to find 30 most relevant files
|
|
409
|
+
2. Returns file tree and actual file contents
|
|
410
|
+
3. Your **agent reads and analyzes** the code
|
|
411
|
+
4. Agent generates 3 context documents based on what it learned
|
|
412
|
+
5. Agent calls `save_context()` to save them
|
|
413
|
+
|
|
414
|
+
**Cost:** Free - pure file I/O, no API calls
|
|
415
|
+
|
|
416
|
+
**Why this is better:**
|
|
417
|
+
- **No API key needed** - your agent does the analysis
|
|
418
|
+
- **Agent understands** - it reads actual code, not generated summaries
|
|
419
|
+
- **Customizable** - agent can focus on what matters for your current task
|
|
420
|
+
- **One-time setup** - after saving, `load_context` works instantly
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
### 7. `save_context` ⭐ NEW - Save Agent-Generated Context
|
|
425
|
+
|
|
426
|
+
**What it does:** Saves the 3 context documents generated by your agent to `.agentbrain/` directory. Works with `setup_repo` for fully agent-driven setup.
|
|
427
|
+
|
|
428
|
+
**Parameters:**
|
|
429
|
+
- `repo_path` (required): Path to repository
|
|
430
|
+
- `context` (required): Content for context.md (architecture, modules, tech stack)
|
|
431
|
+
- `dependency_map` (required): Content for dependency-map.md (module relationships, data flow)
|
|
432
|
+
- `patterns` (required): Content for patterns.md (conventions, patterns, standards)
|
|
433
|
+
|
|
434
|
+
**Example prompts:**
|
|
435
|
+
- "Save the context I generated to .agentbrain/"
|
|
436
|
+
- "Write these context files to disk"
|
|
437
|
+
|
|
438
|
+
**Returns:**
|
|
439
|
+
```json
|
|
440
|
+
{
|
|
441
|
+
"success": true,
|
|
442
|
+
"files_written": [
|
|
443
|
+
".agentbrain/context.md",
|
|
444
|
+
".agentbrain/dependency-map.md",
|
|
445
|
+
".agentbrain/patterns.md",
|
|
446
|
+
".agentbrain/cache.json"
|
|
447
|
+
],
|
|
448
|
+
"message": "Context saved successfully. load_context will now work without an API key."
|
|
449
|
+
}
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
**What it creates:**
|
|
453
|
+
- `.agentbrain/context.md` - Architecture overview
|
|
454
|
+
- `.agentbrain/dependency-map.md` - Module relationships
|
|
455
|
+
- `.agentbrain/patterns.md` - Coding conventions
|
|
456
|
+
- `.agentbrain/cache.json` - Cache metadata with git hash
|
|
457
|
+
|
|
458
|
+
**Cost:** Free - pure file I/O
|
|
459
|
+
|
|
460
|
+
**After saving:**
|
|
461
|
+
- `load_context` works instantly
|
|
462
|
+
- `load_standards` works (if you also create standards file)
|
|
463
|
+
- `load_spec`, `detect_doom_loop`, `save_handoff` all work
|
|
464
|
+
- No API key needed for any subsequent operations
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
### 8. `create_spec` - Create Task Specification
|
|
469
|
+
|
|
470
|
+
**What it does:** Creates a new task specification file from agent-generated content.
|
|
471
|
+
|
|
472
|
+
**Parameters:**
|
|
473
|
+
- `repoPath` (required): Path to repository
|
|
474
|
+
- `task` (required): Task description or name
|
|
475
|
+
- `content` (required): Full specification content
|
|
476
|
+
|
|
477
|
+
**Example prompts:**
|
|
478
|
+
- "Create a spec for adding OAuth authentication"
|
|
479
|
+
- "Save this specification as add-stripe-integration"
|
|
480
|
+
|
|
481
|
+
**Returns:**
|
|
482
|
+
```json
|
|
483
|
+
{
|
|
484
|
+
"specPath": ".agentbrain/specs/add-oauth-authentication.md",
|
|
485
|
+
"slug": "add-oauth-authentication"
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Cost:** Free - writes to disk
|
|
490
|
+
|
|
491
|
+
**Note:** The agent can analyze your request, draft a comprehensive spec (problem, approach, acceptance criteria, etc.), then call this tool to save it.
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
### 9. `detect_doom_loop` - Manually Check for Doom Loops
|
|
496
|
+
|
|
497
|
+
**What it does:** Analyzes recent git history to detect if you're stuck modifying the same files repeatedly.
|
|
498
|
+
|
|
499
|
+
**Parameters:**
|
|
500
|
+
- `repo_path` (required): Path to repository
|
|
501
|
+
- `commit_count` (optional): Number of commits to analyze (default: 10)
|
|
502
|
+
- `threshold` (optional): Min occurrences to trigger warning (default: 4)
|
|
503
|
+
|
|
504
|
+
**Example prompts:**
|
|
505
|
+
- "Check if I'm in a doom loop"
|
|
506
|
+
- "Analyze my recent commits for patterns"
|
|
507
|
+
- "Am I stuck on any files?"
|
|
508
|
+
|
|
509
|
+
**Returns:**
|
|
510
|
+
```json
|
|
511
|
+
{
|
|
512
|
+
"detected": true,
|
|
513
|
+
"files": [
|
|
514
|
+
{ "path": "src/auth.ts", "count": 8, "percentage": 80 },
|
|
515
|
+
{ "path": "src/main.ts", "count": 6, "percentage": 60 }
|
|
516
|
+
],
|
|
517
|
+
"message": "Doom loop detected. You've modified src/auth.ts 8 times in the last 10 commits (80%). Stop coding and investigate the root cause."
|
|
518
|
+
}
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
**Cost:** Free - analyzes local git history
|
|
522
|
+
|
|
523
|
+
**When to use:**
|
|
524
|
+
- When you feel stuck on a problem
|
|
525
|
+
- After multiple failed attempts
|
|
526
|
+
- Before starting a coding session
|
|
527
|
+
- When agent suggests checking
|
|
528
|
+
|
|
529
|
+
**What to do if detected:**
|
|
530
|
+
- Stop coding immediately
|
|
531
|
+
- Review why the file keeps being modified
|
|
532
|
+
- Plan a different approach
|
|
533
|
+
- Consider refactoring or architectural changes
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
378
537
|
## Complete Workflow Example
|
|
379
538
|
|
|
380
539
|
### Morning: Start Your Day
|
|
@@ -632,16 +791,25 @@ agentbrain setup --no-confirm
|
|
|
632
791
|
|
|
633
792
|
## Tips for Best Results
|
|
634
793
|
|
|
635
|
-
### 1. Generate Context
|
|
794
|
+
### 1. Generate Context (Two Options)
|
|
636
795
|
|
|
637
|
-
|
|
796
|
+
**Option A: Agent-Driven Setup** (Recommended, no API key needed)
|
|
797
|
+
```
|
|
798
|
+
You: "Set up AgentBrain for /path/to/project"
|
|
799
|
+
Agent: *Uses setup_repo tool*
|
|
800
|
+
Agent: "I've analyzed your codebase. Let me generate context documents..."
|
|
801
|
+
Agent: *Generates context.md, dependency-map.md, patterns.md*
|
|
802
|
+
Agent: *Uses save_context tool*
|
|
803
|
+
Agent: "Done! Context saved to .agentbrain/. All tools now work instantly."
|
|
804
|
+
```
|
|
638
805
|
|
|
806
|
+
**Option B: CLI Setup** (Requires API key once)
|
|
639
807
|
```bash
|
|
640
808
|
cd /path/to/project
|
|
641
809
|
agentbrain init
|
|
642
810
|
```
|
|
643
811
|
|
|
644
|
-
|
|
812
|
+
Both create the cache, making MCP tool calls instant and free.
|
|
645
813
|
|
|
646
814
|
### 2. Paths Are Flexible
|
|
647
815
|
|
|
@@ -678,17 +846,32 @@ This gives your agent full project awareness immediately.
|
|
|
678
846
|
**Q: Does this cost money?**
|
|
679
847
|
A: Depends on the tool:
|
|
680
848
|
- `scan_repo` - Free
|
|
849
|
+
- `setup_repo` ⭐ NEW - Free (no API key needed!)
|
|
850
|
+
- `save_context` ⭐ NEW - Free
|
|
681
851
|
- `load_spec` - Free
|
|
682
852
|
- `load_standards` - Free
|
|
853
|
+
- `detect_doom_loop` - Free
|
|
854
|
+
- `create_spec` - Free
|
|
683
855
|
- `load_context` (cached) - Free
|
|
684
|
-
- `load_context` (first time) - ~$0.02-0.05
|
|
856
|
+
- `load_context` (first time with API key) - ~$0.02-0.05
|
|
685
857
|
- `save_handoff` - ~$0.01
|
|
686
858
|
|
|
859
|
+
**Q: Can I use AgentBrain without an API key?**
|
|
860
|
+
A: YES! Use the new `setup_repo` + `save_context` workflow:
|
|
861
|
+
1. Ask your agent to "Set up AgentBrain for /path/to/project"
|
|
862
|
+
2. Agent uses `setup_repo` to scan files (no API call)
|
|
863
|
+
3. Agent reads and analyzes the code
|
|
864
|
+
4. Agent generates context documents
|
|
865
|
+
5. Agent uses `save_context` to save them (no API call)
|
|
866
|
+
After that, ALL tools work without an API key!
|
|
867
|
+
|
|
687
868
|
**Q: Where does it get the API key?**
|
|
688
|
-
A: From environment variables (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`) or from `~/.agentbrain/config.json` (set via `agentbrain config`).
|
|
869
|
+
A: From environment variables (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`) or from `~/.agentbrain/config.json` (set via `agentbrain config`). But with `setup_repo` + `save_context`, you don't need one!
|
|
689
870
|
|
|
690
871
|
**Q: Can I use this without the CLI?**
|
|
691
|
-
A: Yes! The MCP server works standalone.
|
|
872
|
+
A: Yes! The MCP server works standalone. You can either:
|
|
873
|
+
- Use `setup_repo` + `save_context` (no API key, agent-driven)
|
|
874
|
+
- Use CLI once (`agentbrain init`) to generate context (requires API key)
|
|
692
875
|
|
|
693
876
|
**Q: Which agent is best?**
|
|
694
877
|
A: All three work great:
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,37 @@ import { loadSpecTool, loadSpecSchema } from './tools/load-spec.js';
|
|
|
10
10
|
import { detectDoomLoop, detectDoomLoopSchema } from './tools/detect-doom-loop.js';
|
|
11
11
|
import { createSpecTool, createSpecSchema } from './tools/create-spec.js';
|
|
12
12
|
import { saveHandoff, saveHandoffSchema } from './tools/save-handoff.js';
|
|
13
|
+
import { setupRepo, setupRepoSchema } from './tools/setup-repo.js';
|
|
14
|
+
import { saveContext, saveContextSchema } from './tools/save-context.js';
|
|
15
|
+
import { existsSync } from 'node:fs';
|
|
16
|
+
import { join, resolve } from 'node:path';
|
|
17
|
+
import { homedir } from 'node:os';
|
|
18
|
+
/**
|
|
19
|
+
* Expand path: handles ~, relative paths, etc.
|
|
20
|
+
*/
|
|
21
|
+
function expandPath(path) {
|
|
22
|
+
if (path.startsWith('~/') || path === '~') {
|
|
23
|
+
return path.replace('~', homedir());
|
|
24
|
+
}
|
|
25
|
+
return resolve(path);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if .agentbrain/ directory exists. If not, return bootstrap message.
|
|
29
|
+
* Returns null if bootstrap is not needed (directory exists).
|
|
30
|
+
*/
|
|
31
|
+
async function checkBootstrap(repo_path) {
|
|
32
|
+
const expandedPath = expandPath(repo_path);
|
|
33
|
+
const contextDir = join(expandedPath, '.agentbrain');
|
|
34
|
+
if (!existsSync(contextDir)) {
|
|
35
|
+
return ('No .agentbrain/ directory found. To set up context without an API key:\n\n' +
|
|
36
|
+
'1. Call setup_repo() to scan the repo and get instructions\n' +
|
|
37
|
+
'2. Generate the three context documents based on what setup_repo returns\n' +
|
|
38
|
+
'3. Call save_context() with your generated content\n\n' +
|
|
39
|
+
'After that, this tool will work instantly with no API key needed.\n\n' +
|
|
40
|
+
'Alternative: Run `agentbrain setup` in your terminal (requires API key, one-time ~$0.03)');
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
13
44
|
// Create MCP server
|
|
14
45
|
const server = new Server({
|
|
15
46
|
name: 'agentbrain',
|
|
@@ -26,6 +57,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
26
57
|
scanRepoSchema,
|
|
27
58
|
loadStandardsSchema,
|
|
28
59
|
loadContextSchema,
|
|
60
|
+
setupRepoSchema,
|
|
61
|
+
saveContextSchema,
|
|
29
62
|
loadSpecSchema,
|
|
30
63
|
detectDoomLoopSchema,
|
|
31
64
|
createSpecSchema,
|
|
@@ -45,12 +78,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
45
78
|
};
|
|
46
79
|
}
|
|
47
80
|
case 'load_standards': {
|
|
81
|
+
const bootstrap = await checkBootstrap(args.repo_path);
|
|
82
|
+
if (bootstrap) {
|
|
83
|
+
return {
|
|
84
|
+
content: [{ type: 'text', text: bootstrap }],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
48
87
|
const result = await loadStandards(args);
|
|
49
88
|
return {
|
|
50
89
|
content: [{ type: 'text', text: result.content }],
|
|
51
90
|
};
|
|
52
91
|
}
|
|
53
92
|
case 'load_context': {
|
|
93
|
+
const bootstrap = await checkBootstrap(args.repo_path);
|
|
94
|
+
if (bootstrap) {
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: 'text', text: bootstrap }],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
54
99
|
const result = await loadContext(args);
|
|
55
100
|
return {
|
|
56
101
|
content: [
|
|
@@ -62,6 +107,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
62
107
|
};
|
|
63
108
|
}
|
|
64
109
|
case 'load_spec': {
|
|
110
|
+
const bootstrap = await checkBootstrap(args.repoPath);
|
|
111
|
+
if (bootstrap) {
|
|
112
|
+
return {
|
|
113
|
+
content: [{ type: 'text', text: bootstrap }],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
65
116
|
const result = await loadSpecTool(args);
|
|
66
117
|
return {
|
|
67
118
|
content: [
|
|
@@ -75,6 +126,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
75
126
|
};
|
|
76
127
|
}
|
|
77
128
|
case 'detect_doom_loop': {
|
|
129
|
+
const bootstrap = await checkBootstrap(args.repo_path);
|
|
130
|
+
if (bootstrap) {
|
|
131
|
+
return {
|
|
132
|
+
content: [{ type: 'text', text: bootstrap }],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
78
135
|
const result = await detectDoomLoop(args);
|
|
79
136
|
return {
|
|
80
137
|
content: [
|
|
@@ -97,6 +154,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
97
154
|
};
|
|
98
155
|
}
|
|
99
156
|
case 'save_handoff': {
|
|
157
|
+
const bootstrap = await checkBootstrap(args.repo_path);
|
|
158
|
+
if (bootstrap) {
|
|
159
|
+
return {
|
|
160
|
+
content: [{ type: 'text', text: bootstrap }],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
100
163
|
const result = await saveHandoff(args);
|
|
101
164
|
return {
|
|
102
165
|
content: [
|
|
@@ -107,6 +170,28 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
107
170
|
],
|
|
108
171
|
};
|
|
109
172
|
}
|
|
173
|
+
case 'setup_repo': {
|
|
174
|
+
const result = await setupRepo(args);
|
|
175
|
+
return {
|
|
176
|
+
content: [
|
|
177
|
+
{
|
|
178
|
+
type: 'text',
|
|
179
|
+
text: `# Repository Setup Data\n\n## File Tree\n${result.file_tree}\n\n## Key Files (${result.key_files.length} files)\n\n${result.key_files.map(f => `### ${f.path}\n\`\`\`\n${f.content}\n\`\`\``).join('\n\n')}\n\n## Instructions\n\n${result.instructions}`,
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
case 'save_context': {
|
|
185
|
+
const result = await saveContext(args);
|
|
186
|
+
return {
|
|
187
|
+
content: [
|
|
188
|
+
{
|
|
189
|
+
type: 'text',
|
|
190
|
+
text: `${result.message}\n\nFiles written:\n${result.files_written.map(f => `- ${f}`).join('\n')}`,
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
110
195
|
default:
|
|
111
196
|
throw new Error(`Unknown tool: ${name}`);
|
|
112
197
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,wBAAwB;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE/D,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAE9E,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAExE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAEnE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,oBAAoB;AACpB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,OAAO;CACjB,EACD;IACE,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;KACV;CACF,CACF,CAAA;AAED,iBAAiB;AACjB,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;IAC1D,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CAAA;IACH,CAAC;AACH,CAAC,CAAC,CAAA;AAEF,eAAe;AACf,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAE/B,oEAAoE;IACpE,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAA;AACzD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-context.d.ts","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"AAMA,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAA;AAYzB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACxC;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"load-context.d.ts","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"AAMA,OAAO,EAOL,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAA;AAYzB,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;CACxC;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqHrF;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAkB7B,CAAA"}
|
|
@@ -73,25 +73,26 @@ export async function loadContext(input) {
|
|
|
73
73
|
doom_warning: doomWarning,
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
// Need to generate -
|
|
76
|
+
// Need to generate - check for API key first
|
|
77
77
|
let aiConfig;
|
|
78
78
|
try {
|
|
79
79
|
aiConfig = await loadAIConfig();
|
|
80
80
|
}
|
|
81
81
|
catch {
|
|
82
|
-
// No API key configured - return
|
|
82
|
+
// No API key configured - return bootstrap instructions
|
|
83
83
|
return {
|
|
84
|
-
content: 'No context found for this repository
|
|
85
|
-
'
|
|
86
|
-
'
|
|
87
|
-
'
|
|
88
|
-
'
|
|
84
|
+
content: 'No context found for this repository. To set up context without an API key:\n\n' +
|
|
85
|
+
'1. Call setup_repo() to scan the repo and get instructions\n' +
|
|
86
|
+
'2. Generate the three context documents based on what setup_repo returns\n' +
|
|
87
|
+
'3. Call save_context() with your generated content\n\n' +
|
|
88
|
+
'After that, load_context will work instantly with no API key needed.\n\n' +
|
|
89
|
+
'Alternative: Run `agentbrain setup` in your terminal (requires API key, one-time ~$0.03)',
|
|
89
90
|
fromCache: false,
|
|
90
91
|
tokensUsed: 0,
|
|
91
92
|
doom_warning: null,
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
|
-
// Generate new context
|
|
95
|
+
// Generate new context using API
|
|
95
96
|
const result = await generateContext({
|
|
96
97
|
repoPath: expandedPath,
|
|
97
98
|
aiConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-context.js","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAU,EACV,SAAS,EACT,oBAAoB,GAErB,MAAM,kBAAkB,CAAA;AAEzB;;GAEG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA;IACrC,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;AACtB,CAAC;AAkBD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAuB;IACvD,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,KAAK,CAAA;IAElD,gDAAgD;IAChD,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAE1C,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;IAEpD,2CAA2C;IAC3C,MAAM,cAAc,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M,WAAW,GAAG,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAA;IAE5D,yCAAyC;IACzC,OAAO;QACL,OAAO,EAAE,QAAQ;QACjB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,MAAM,CAAC,WAAW;QAC9B,YAAY,EAAE,WAAW;KAC1B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,qPAAqP;IACvP,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;aAC/C;YACD,aAAa,EAAE;gBACb,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,4DAA4D;aAC1E;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface SaveContextInput {
|
|
2
|
+
repo_path: string;
|
|
3
|
+
context: string;
|
|
4
|
+
dependency_map: string;
|
|
5
|
+
patterns: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SaveContextOutput {
|
|
8
|
+
success: boolean;
|
|
9
|
+
files_written: string[];
|
|
10
|
+
message: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function saveContext(input: SaveContextInput): Promise<SaveContextOutput>;
|
|
13
|
+
export declare const saveContextSchema: {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: string;
|
|
18
|
+
properties: {
|
|
19
|
+
repo_path: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
context: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
dependency_map: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
patterns: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
required: string[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=save-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-context.d.ts","sourceRoot":"","sources":["../../src/tools/save-context.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiErF;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;CA0B7B,CAAA"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// MCP tool: save_context - save agent-generated context to disk
|
|
2
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { getGitHash, injectIntoAllAgents } from '@agentbrain/core';
|
|
7
|
+
/**
|
|
8
|
+
* Expand path: handles ~, relative paths, etc.
|
|
9
|
+
*/
|
|
10
|
+
function expandPath(path) {
|
|
11
|
+
if (path.startsWith('~/') || path === '~') {
|
|
12
|
+
return path.replace('~', homedir());
|
|
13
|
+
}
|
|
14
|
+
return resolve(path);
|
|
15
|
+
}
|
|
16
|
+
export async function saveContext(input) {
|
|
17
|
+
const { repo_path, context, dependency_map, patterns } = input;
|
|
18
|
+
// Expand path to handle ~, relative paths, etc.
|
|
19
|
+
const expandedPath = expandPath(repo_path);
|
|
20
|
+
const contextDir = join(expandedPath, '.agentbrain');
|
|
21
|
+
// Create .agentbrain directory if it doesn't exist
|
|
22
|
+
if (!existsSync(contextDir)) {
|
|
23
|
+
await mkdir(contextDir, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
// Write the three context files
|
|
26
|
+
const contextPath = join(contextDir, 'context.md');
|
|
27
|
+
const depMapPath = join(contextDir, 'dependency-map.md');
|
|
28
|
+
const patternsPath = join(contextDir, 'patterns.md');
|
|
29
|
+
await writeFile(contextPath, context, 'utf-8');
|
|
30
|
+
await writeFile(depMapPath, dependency_map, 'utf-8');
|
|
31
|
+
await writeFile(patternsPath, patterns, 'utf-8');
|
|
32
|
+
// Get current git hash
|
|
33
|
+
const gitHash = await getGitHash(expandedPath);
|
|
34
|
+
// Create basic cache.json with git hash
|
|
35
|
+
const cachePath = join(contextDir, 'cache.json');
|
|
36
|
+
const cache = {
|
|
37
|
+
gitHash,
|
|
38
|
+
docs: {
|
|
39
|
+
context: {
|
|
40
|
+
type: 'context',
|
|
41
|
+
content: context,
|
|
42
|
+
savedAt: new Date().toISOString(),
|
|
43
|
+
},
|
|
44
|
+
'dependency-map': {
|
|
45
|
+
type: 'dependency-map',
|
|
46
|
+
content: dependency_map,
|
|
47
|
+
savedAt: new Date().toISOString(),
|
|
48
|
+
},
|
|
49
|
+
patterns: {
|
|
50
|
+
type: 'patterns',
|
|
51
|
+
content: patterns,
|
|
52
|
+
savedAt: new Date().toISOString(),
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
savedAt: new Date().toISOString(),
|
|
56
|
+
};
|
|
57
|
+
await writeFile(cachePath, JSON.stringify(cache, null, 2), 'utf-8');
|
|
58
|
+
// Inject references into agent files if they exist
|
|
59
|
+
await injectIntoAllAgents(expandedPath, gitHash);
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
files_written: [
|
|
63
|
+
'.agentbrain/context.md',
|
|
64
|
+
'.agentbrain/dependency-map.md',
|
|
65
|
+
'.agentbrain/patterns.md',
|
|
66
|
+
'.agentbrain/cache.json',
|
|
67
|
+
],
|
|
68
|
+
message: 'Context saved successfully. load_context will now work without an API key.',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export const saveContextSchema = {
|
|
72
|
+
name: 'save_context',
|
|
73
|
+
description: 'Save agent-generated context files to .agentbrain/ directory. No API key required - pure file I/O. After saving, load_context will work instantly without needing API calls.',
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
repo_path: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: 'Absolute path to the repository',
|
|
80
|
+
},
|
|
81
|
+
context: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
description: 'Content for context.md (architecture, modules, tech stack)',
|
|
84
|
+
},
|
|
85
|
+
dependency_map: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: 'Content for dependency-map.md (module relationships, data flow)',
|
|
88
|
+
},
|
|
89
|
+
patterns: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
description: 'Content for patterns.md (conventions, patterns, standards)',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
required: ['repo_path', 'context', 'dependency_map', 'patterns'],
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=save-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-context.js","sourceRoot":"","sources":["../../src/tools/save-context.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAEhE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,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d,WAAW,EAAE,4DAA4D;aAC1E;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iEAAiE;aAC/E;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4DAA4D;aAC1E;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,CAAC;KACjE;CACF,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SetupRepoInput {
|
|
2
|
+
repo_path: string;
|
|
3
|
+
}
|
|
4
|
+
export interface SetupRepoOutput {
|
|
5
|
+
repo_path: string;
|
|
6
|
+
file_tree: string;
|
|
7
|
+
key_files: Array<{
|
|
8
|
+
path: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}>;
|
|
11
|
+
instructions: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function setupRepo(input: SetupRepoInput): Promise<SetupRepoOutput>;
|
|
14
|
+
export declare const setupRepoSchema: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: string;
|
|
19
|
+
properties: {
|
|
20
|
+
repo_path: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=setup-repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-repo.d.ts","sourceRoot":"","sources":["../../src/tools/setup-repo.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,KAAK,CAAC;QACf,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,MAAM,CAAA;KAChB,CAAC,CAAA;IACF,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAmD/E;AAED,eAAO,MAAM,eAAe;;;;;;;;;;;;;CAc3B,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// MCP tool: setup_repo - scan repo and return data for agent to generate context
|
|
2
|
+
import { scanRepository, readFileContent } from '@agentbrain/core';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
/**
|
|
6
|
+
* Expand path: handles ~, relative paths, etc.
|
|
7
|
+
*/
|
|
8
|
+
function expandPath(path) {
|
|
9
|
+
if (path.startsWith('~/') || path === '~') {
|
|
10
|
+
return path.replace('~', homedir());
|
|
11
|
+
}
|
|
12
|
+
return resolve(path);
|
|
13
|
+
}
|
|
14
|
+
export async function setupRepo(input) {
|
|
15
|
+
const { repo_path } = input;
|
|
16
|
+
// Expand path to handle ~, relative paths, etc.
|
|
17
|
+
const expandedPath = expandPath(repo_path);
|
|
18
|
+
// Scan the repository to get relevant files
|
|
19
|
+
const scanResult = await scanRepository(expandedPath, { maxFiles: 30 });
|
|
20
|
+
// Build file tree visualization
|
|
21
|
+
const fileTree = scanResult.relevantFiles
|
|
22
|
+
.map((f) => `${f.path} (${f.language})`)
|
|
23
|
+
.join('\n');
|
|
24
|
+
// Read content of top files (prioritized by scan)
|
|
25
|
+
const keyFiles = [];
|
|
26
|
+
for (const file of scanResult.relevantFiles.slice(0, 30)) {
|
|
27
|
+
const content = await readFileContent(expandedPath, file.path);
|
|
28
|
+
if (content !== null) {
|
|
29
|
+
keyFiles.push({
|
|
30
|
+
path: file.path,
|
|
31
|
+
content,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Instructions for the agent
|
|
36
|
+
const instructions = `Based on the file tree and key files above, generate:
|
|
37
|
+
|
|
38
|
+
1. context.md — Architecture overview, key modules, entry points, what the codebase does, tech stack
|
|
39
|
+
|
|
40
|
+
2. dependency-map.md — How modules relate to each other, data flow, service relationships
|
|
41
|
+
|
|
42
|
+
3. patterns.md — Coding conventions, patterns used, naming conventions, error handling approach
|
|
43
|
+
|
|
44
|
+
Then call save_context() with all three documents.
|
|
45
|
+
|
|
46
|
+
Guidelines:
|
|
47
|
+
- Be concise but thorough
|
|
48
|
+
- Focus on what's unique to this codebase
|
|
49
|
+
- Include specific file paths and module names
|
|
50
|
+
- Identify the main entry points and core business logic
|
|
51
|
+
- Note any important patterns or conventions used consistently`;
|
|
52
|
+
return {
|
|
53
|
+
repo_path: expandedPath,
|
|
54
|
+
file_tree: fileTree,
|
|
55
|
+
key_files: keyFiles,
|
|
56
|
+
instructions,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export const setupRepoSchema = {
|
|
60
|
+
name: 'setup_repo',
|
|
61
|
+
description: 'Scan repository and return file tree + key file contents for agent-driven context generation. No API key required - pure file analysis. Use this when load_context indicates setup is needed.',
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
repo_path: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Absolute path to the repository',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
required: ['repo_path'],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=setup-repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-repo.js","sourceRoot":"","sources":["../../src/tools/setup-repo.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC;;GAEG;AACH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,EAAE,YAAY;QACvB,SAAS,EAAE,QAAQ;QACnB,SAAS,EAAE,QAAQ;QACnB,YAAY;KACb,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,+LAA+L;IACjM,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;aAC/C;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentbrain/mcp-server",
|
|
3
|
-
|
|
3
|
+
"version": "1.4.37",
|
|
4
4
|
"description": "Model Context Protocol server for AgentBrain - connect Claude, Cursor, and Windsurf to repository intelligence",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"ts-jest": "^29.4.6",
|
|
53
53
|
"typescript": "^5.7.2"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|