@agentbrain/mcp-server 1.0.0
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 +578 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/load-context.d.ts +29 -0
- package/dist/tools/load-context.d.ts.map +1 -0
- package/dist/tools/load-context.js +86 -0
- package/dist/tools/load-context.js.map +1 -0
- package/dist/tools/load-standards.d.ts +31 -0
- package/dist/tools/load-standards.d.ts.map +1 -0
- package/dist/tools/load-standards.js +51 -0
- package/dist/tools/load-standards.js.map +1 -0
- package/dist/tools/save-handoff.d.ts +29 -0
- package/dist/tools/save-handoff.d.ts.map +1 -0
- package/dist/tools/save-handoff.js +59 -0
- package/dist/tools/save-handoff.js.map +1 -0
- package/dist/tools/scan-repo.d.ts +33 -0
- package/dist/tools/scan-repo.d.ts.map +1 -0
- package/dist/tools/scan-repo.js +49 -0
- package/dist/tools/scan-repo.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
# @agentbrain/mcp-server
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for AgentBrain - connect your AI agent directly to repository intelligence.
|
|
4
|
+
|
|
5
|
+
## What is This?
|
|
6
|
+
|
|
7
|
+
This MCP server lets **Claude Desktop**, **Cursor**, and **Windsurf** access AgentBrain functionality directly from within your coding sessions. Your AI agent can automatically:
|
|
8
|
+
|
|
9
|
+
- 🔍 Scan your repository structure
|
|
10
|
+
- 📖 Load comprehensive codebase context
|
|
11
|
+
- 📋 Read coding standards
|
|
12
|
+
- 💾 Save session handoffs
|
|
13
|
+
|
|
14
|
+
**No CLI commands needed** - your agent does it all automatically!
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g @agentbrain/mcp-server
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Setup by Platform
|
|
27
|
+
|
|
28
|
+
### 🟣 Claude Desktop
|
|
29
|
+
|
|
30
|
+
#### Step 1: Find the Server Path
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
which agentbrain-mcp
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Example output:**
|
|
37
|
+
```
|
|
38
|
+
/Users/yourname/.nvm/versions/node/v20.19.4/bin/agentbrain-mcp
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Copy this exact path** - you'll need it in the next step.
|
|
42
|
+
|
|
43
|
+
#### Step 2: Edit Claude Desktop Config
|
|
44
|
+
|
|
45
|
+
**macOS:**
|
|
46
|
+
```bash
|
|
47
|
+
# Open in your text editor
|
|
48
|
+
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
|
|
49
|
+
|
|
50
|
+
# Or use nano
|
|
51
|
+
nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Windows:**
|
|
55
|
+
```bash
|
|
56
|
+
# The config is at:
|
|
57
|
+
%APPDATA%\Claude\claude_desktop_config.json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Step 3: Add AgentBrain to Config
|
|
61
|
+
|
|
62
|
+
Add this configuration (use the path from Step 1):
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"agentbrain": {
|
|
68
|
+
"command": "/Users/yourname/.nvm/versions/node/v20.19.4/bin/agentbrain-mcp"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**⚠️ Important:** Use the **absolute path** you got from `which agentbrain-mcp`.
|
|
75
|
+
|
|
76
|
+
**If you have other MCP servers already:**
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"filesystem": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"]
|
|
83
|
+
},
|
|
84
|
+
"agentbrain": {
|
|
85
|
+
"command": "/Users/yourname/.nvm/versions/node/v20.19.4/bin/agentbrain-mcp"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Step 4: Restart Claude Desktop
|
|
92
|
+
|
|
93
|
+
**Completely quit** Claude Desktop (don't just close the window):
|
|
94
|
+
- macOS: `Cmd + Q` or Claude → Quit Claude
|
|
95
|
+
- Windows: Right-click taskbar icon → Quit
|
|
96
|
+
|
|
97
|
+
Then reopen it.
|
|
98
|
+
|
|
99
|
+
#### Step 5: Verify It's Working
|
|
100
|
+
|
|
101
|
+
1. Start a new conversation in Claude Desktop
|
|
102
|
+
2. Look for the **🔌 icon** in the toolbar or bottom of the chat
|
|
103
|
+
3. Click it - you should see "agentbrain" with 4 tools:
|
|
104
|
+
- `scan_repo`
|
|
105
|
+
- `load_context`
|
|
106
|
+
- `load_standards`
|
|
107
|
+
- `save_handoff`
|
|
108
|
+
|
|
109
|
+
#### Step 6: Try It Out!
|
|
110
|
+
|
|
111
|
+
Ask Claude:
|
|
112
|
+
```
|
|
113
|
+
"Use the scan_repo tool to analyze my project at /Users/yourname/my-project"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Claude will automatically use the AgentBrain tools!
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
### 🔵 Cursor
|
|
121
|
+
|
|
122
|
+
#### Step 1: Find the Server Path
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
which agentbrain-mcp
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Copy the output path.
|
|
129
|
+
|
|
130
|
+
#### Step 2: Open Cursor MCP Settings
|
|
131
|
+
|
|
132
|
+
1. Open Cursor
|
|
133
|
+
2. Press `Cmd + Shift + P` (macOS) or `Ctrl + Shift + P` (Windows/Linux)
|
|
134
|
+
3. Type "MCP" and select **"MCP: Configure Servers"**
|
|
135
|
+
|
|
136
|
+
Or manually edit the config file:
|
|
137
|
+
|
|
138
|
+
**macOS:**
|
|
139
|
+
```bash
|
|
140
|
+
code ~/Library/Application\ Support/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Linux:**
|
|
144
|
+
```bash
|
|
145
|
+
code ~/.config/Cursor/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Windows:**
|
|
149
|
+
```bash
|
|
150
|
+
code %APPDATA%\Cursor\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Step 3: Add AgentBrain Configuration
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"mcpServers": {
|
|
158
|
+
"agentbrain": {
|
|
159
|
+
"command": "/Users/yourname/.nvm/versions/node/v20.19.4/bin/agentbrain-mcp"
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Step 4: Restart Cursor
|
|
166
|
+
|
|
167
|
+
Completely quit and reopen Cursor.
|
|
168
|
+
|
|
169
|
+
#### Step 5: Verify
|
|
170
|
+
|
|
171
|
+
1. Open a project in Cursor
|
|
172
|
+
2. Open the Cursor chat (usually `Cmd + L` or `Ctrl + L`)
|
|
173
|
+
3. Type `@` and you should see MCP tools available
|
|
174
|
+
4. Or check the MCP panel in settings
|
|
175
|
+
|
|
176
|
+
#### Step 6: Use It
|
|
177
|
+
|
|
178
|
+
In Cursor chat:
|
|
179
|
+
```
|
|
180
|
+
"Scan the current repository using AgentBrain"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Cursor will automatically use the MCP tools!
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### 🟢 Windsurf
|
|
188
|
+
|
|
189
|
+
#### Step 1: Find the Server Path
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
which agentbrain-mcp
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Copy the output path.
|
|
196
|
+
|
|
197
|
+
#### Step 2: Open Windsurf Settings
|
|
198
|
+
|
|
199
|
+
**Method 1: Via UI**
|
|
200
|
+
1. Open Windsurf
|
|
201
|
+
2. Go to Settings (gear icon)
|
|
202
|
+
3. Search for "MCP" or "Model Context Protocol"
|
|
203
|
+
4. Add new server configuration
|
|
204
|
+
|
|
205
|
+
**Method 2: Edit Config File**
|
|
206
|
+
|
|
207
|
+
**macOS:**
|
|
208
|
+
```bash
|
|
209
|
+
code ~/Library/Application\ Support/Windsurf/User/globalStorage/windsurf-mcp/settings.json
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Linux:**
|
|
213
|
+
```bash
|
|
214
|
+
code ~/.config/Windsurf/User/globalStorage/windsurf-mcp/settings.json
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Windows:**
|
|
218
|
+
```bash
|
|
219
|
+
code %APPDATA%\Windsurf\User\globalStorage\windsurf-mcp\settings.json
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### Step 3: Add AgentBrain
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"mcpServers": {
|
|
227
|
+
"agentbrain": {
|
|
228
|
+
"command": "/Users/yourname/.nvm/versions/node/v20.19.4/bin/agentbrain-mcp"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### Step 4: Restart Windsurf
|
|
235
|
+
|
|
236
|
+
Quit completely and reopen.
|
|
237
|
+
|
|
238
|
+
#### Step 5: Verify & Use
|
|
239
|
+
|
|
240
|
+
Look for MCP tools in the Windsurf interface, then ask:
|
|
241
|
+
```
|
|
242
|
+
"Use AgentBrain to scan this project"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Available Tools
|
|
248
|
+
|
|
249
|
+
Once configured, your agent can use these 4 tools:
|
|
250
|
+
|
|
251
|
+
### 1. `scan_repo` - Analyze Repository Structure
|
|
252
|
+
|
|
253
|
+
**What it does:** Scans your repository and lists all relevant files with language and size info.
|
|
254
|
+
|
|
255
|
+
**Example prompts for your agent:**
|
|
256
|
+
- "Scan this repository at /path/to/project"
|
|
257
|
+
- "Show me the structure of my codebase"
|
|
258
|
+
- "What files are in this project?"
|
|
259
|
+
|
|
260
|
+
**Cost:** Free - no API calls
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### 2. `load_context` - Load Full Context
|
|
265
|
+
|
|
266
|
+
**What it does:** Loads comprehensive documentation about your entire codebase (context.md + dependency-map.md + patterns.md).
|
|
267
|
+
|
|
268
|
+
**Example prompts:**
|
|
269
|
+
- "Load the context for /path/to/project"
|
|
270
|
+
- "Give me the full context of this codebase"
|
|
271
|
+
- "Load project intelligence for my app"
|
|
272
|
+
|
|
273
|
+
**Cost:**
|
|
274
|
+
- **First time:** ~$0.02-0.05 (generates documentation)
|
|
275
|
+
- **After that:** $0.00 (uses cache)
|
|
276
|
+
|
|
277
|
+
**Note:** If the context doesn't exist, it will generate it using your API key.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
### 3. `load_standards` - Load Coding Standards
|
|
282
|
+
|
|
283
|
+
**What it does:** Loads the coding standards file for your specific agent (CLAUDE.md, .cursor/rules, or .windsurfrules).
|
|
284
|
+
|
|
285
|
+
**Example prompts:**
|
|
286
|
+
- "Load the coding standards for this project"
|
|
287
|
+
- "What are my code standards?"
|
|
288
|
+
- "Show me the project conventions"
|
|
289
|
+
|
|
290
|
+
**Cost:** Free - reads from disk
|
|
291
|
+
|
|
292
|
+
**Note:** Standards file must exist (create with `agentbrain standards` CLI command first).
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
### 4. `save_handoff` - Save Session Handoff
|
|
297
|
+
|
|
298
|
+
**What it does:** Analyzes your recent git changes and creates a handoff document for the next session.
|
|
299
|
+
|
|
300
|
+
**Example prompts:**
|
|
301
|
+
- "Save a handoff for this session"
|
|
302
|
+
- "Create a handoff document with goal: implemented auth"
|
|
303
|
+
- "Generate a session summary"
|
|
304
|
+
|
|
305
|
+
**Cost:** ~$0.01
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Complete Workflow Example
|
|
310
|
+
|
|
311
|
+
### Morning: Start Your Day
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
You: "Load the context for /Users/me/my-app"
|
|
315
|
+
Agent: *Uses load_context tool*
|
|
316
|
+
Agent: "I've loaded the full context. Your app is a React/TypeScript
|
|
317
|
+
project with 47 files. I can see you have authentication,
|
|
318
|
+
user management, and API integration modules..."
|
|
319
|
+
|
|
320
|
+
You: "What are the coding standards?"
|
|
321
|
+
Agent: *Uses load_standards tool*
|
|
322
|
+
Agent: "I've loaded the standards. You're using TypeScript with strict
|
|
323
|
+
mode, Prettier for formatting, and following clean architecture
|
|
324
|
+
patterns..."
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### During Development
|
|
328
|
+
|
|
329
|
+
```
|
|
330
|
+
You: "Help me add a new feature for user notifications"
|
|
331
|
+
Agent: *Already has full context from earlier*
|
|
332
|
+
Agent: "Based on your current architecture, I recommend adding a
|
|
333
|
+
NotificationService class in src/services/..."
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### End of Day
|
|
337
|
+
|
|
338
|
+
```
|
|
339
|
+
You: "Save a handoff with goal: Implemented notification system"
|
|
340
|
+
Agent: *Uses save_handoff tool*
|
|
341
|
+
Agent: "Handoff saved to agentbrain/handoff.md!
|
|
342
|
+
Summary: Added NotificationService, integrated with existing
|
|
343
|
+
user system, added tests. Next steps: Add email integration
|
|
344
|
+
and push notification support."
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Troubleshooting
|
|
350
|
+
|
|
351
|
+
### "AgentBrain not showing up in my agent"
|
|
352
|
+
|
|
353
|
+
**1. Check the path is correct:**
|
|
354
|
+
```bash
|
|
355
|
+
which agentbrain-mcp
|
|
356
|
+
# Copy this exact path to your config
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**2. Verify config file location:**
|
|
360
|
+
|
|
361
|
+
**Claude Desktop (macOS):**
|
|
362
|
+
```bash
|
|
363
|
+
cat ~/Library/Application\ Support/Claude/claude_desktop_config.json
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**3. Check for JSON syntax errors:**
|
|
367
|
+
- Missing commas between entries
|
|
368
|
+
- Missing quotes
|
|
369
|
+
- Invalid path format
|
|
370
|
+
|
|
371
|
+
**4. Restart completely:**
|
|
372
|
+
- Don't just close the window
|
|
373
|
+
- Actually quit the application (Cmd+Q / Ctrl+Q)
|
|
374
|
+
- Reopen
|
|
375
|
+
|
|
376
|
+
**5. Check logs:**
|
|
377
|
+
|
|
378
|
+
**Claude Desktop:**
|
|
379
|
+
- Go to Help → Show Logs (or Developer → Show Logs)
|
|
380
|
+
- Look for MCP connection errors
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
### "Tool calls are failing"
|
|
385
|
+
|
|
386
|
+
**1. Check the path exists:**
|
|
387
|
+
```bash
|
|
388
|
+
# Verify the repository exists
|
|
389
|
+
ls ~/my-project # or whatever path you're using
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**2. Check API key for generation:**
|
|
393
|
+
|
|
394
|
+
If loading context for the first time:
|
|
395
|
+
```bash
|
|
396
|
+
# Check if key exists
|
|
397
|
+
echo $ANTHROPIC_API_KEY
|
|
398
|
+
|
|
399
|
+
# Or
|
|
400
|
+
agentbrain config --show
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**3. Check the repo exists:**
|
|
404
|
+
```bash
|
|
405
|
+
ls /path/to/your/project
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
### "Command not found: agentbrain-mcp"
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
# Reinstall
|
|
414
|
+
npm install -g @agentbrain/mcp-server
|
|
415
|
+
|
|
416
|
+
# Verify
|
|
417
|
+
which agentbrain-mcp
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
### "Getting 'permission denied' errors"
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
# Check file permissions
|
|
426
|
+
ls -la $(which agentbrain-mcp)
|
|
427
|
+
|
|
428
|
+
# Should be executable (has 'x' in permissions)
|
|
429
|
+
# If not, fix it:
|
|
430
|
+
chmod +x $(which agentbrain-mcp)
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Configuration Examples
|
|
436
|
+
|
|
437
|
+
### Minimal Configuration
|
|
438
|
+
|
|
439
|
+
```json
|
|
440
|
+
{
|
|
441
|
+
"mcpServers": {
|
|
442
|
+
"agentbrain": {
|
|
443
|
+
"command": "/absolute/path/to/agentbrain-mcp"
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
### With Environment Variables
|
|
450
|
+
|
|
451
|
+
```json
|
|
452
|
+
{
|
|
453
|
+
"mcpServers": {
|
|
454
|
+
"agentbrain": {
|
|
455
|
+
"command": "/absolute/path/to/agentbrain-mcp",
|
|
456
|
+
"env": {
|
|
457
|
+
"ANTHROPIC_API_KEY": "sk-ant-..."
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### Multiple MCP Servers
|
|
465
|
+
|
|
466
|
+
```json
|
|
467
|
+
{
|
|
468
|
+
"mcpServers": {
|
|
469
|
+
"filesystem": {
|
|
470
|
+
"command": "npx",
|
|
471
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/projects"]
|
|
472
|
+
},
|
|
473
|
+
"agentbrain": {
|
|
474
|
+
"command": "/Users/me/.nvm/versions/node/v20.19.4/bin/agentbrain-mcp"
|
|
475
|
+
},
|
|
476
|
+
"github": {
|
|
477
|
+
"command": "npx",
|
|
478
|
+
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
479
|
+
"env": {
|
|
480
|
+
"GITHUB_TOKEN": "ghp_..."
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## Tips for Best Results
|
|
490
|
+
|
|
491
|
+
### 1. Generate Context First
|
|
492
|
+
|
|
493
|
+
Before using the MCP server, generate context once via CLI:
|
|
494
|
+
|
|
495
|
+
```bash
|
|
496
|
+
cd /path/to/project
|
|
497
|
+
agentbrain init
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
This creates the cache, making MCP tool calls instant and free.
|
|
501
|
+
|
|
502
|
+
### 2. Paths Are Flexible
|
|
503
|
+
|
|
504
|
+
AgentBrain automatically handles different path formats:
|
|
505
|
+
```
|
|
506
|
+
✅ "Load context for /Users/me/my-project" (absolute)
|
|
507
|
+
✅ "Load context for ~/my-project" (~ expansion)
|
|
508
|
+
✅ "Load context for ../my-project" (relative)
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
All three work! The MCP server automatically expands them.
|
|
512
|
+
|
|
513
|
+
### 3. Generate Standards
|
|
514
|
+
|
|
515
|
+
Create standards files so `load_standards` works:
|
|
516
|
+
```bash
|
|
517
|
+
cd /path/to/project
|
|
518
|
+
agentbrain standards
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### 4. Morning Routine
|
|
522
|
+
|
|
523
|
+
Start each day by asking:
|
|
524
|
+
```
|
|
525
|
+
"Load the context and standards for /Users/me/my-project"
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
This gives your agent full project awareness immediately.
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
## Frequently Asked Questions
|
|
533
|
+
|
|
534
|
+
**Q: Does this cost money?**
|
|
535
|
+
A: Depends on the tool:
|
|
536
|
+
- `scan_repo` - Free
|
|
537
|
+
- `load_standards` - Free
|
|
538
|
+
- `load_context` (cached) - Free
|
|
539
|
+
- `load_context` (first time) - ~$0.02-0.05
|
|
540
|
+
- `save_handoff` - ~$0.01
|
|
541
|
+
|
|
542
|
+
**Q: Where does it get the API key?**
|
|
543
|
+
A: From environment variables (`ANTHROPIC_API_KEY` or `OPENAI_API_KEY`) or from `~/.agentbrain/config.json` (set via `agentbrain config`).
|
|
544
|
+
|
|
545
|
+
**Q: Can I use this without the CLI?**
|
|
546
|
+
A: Yes! The MCP server works standalone. But using the CLI once to generate initial context (`agentbrain init`) will make subsequent MCP calls free and instant.
|
|
547
|
+
|
|
548
|
+
**Q: Which agent is best?**
|
|
549
|
+
A: All three work great:
|
|
550
|
+
- **Claude Desktop** - Native MCP support, excellent integration
|
|
551
|
+
- **Cursor** - Popular for coding, good MCP support
|
|
552
|
+
- **Windsurf** - Emerging option with MCP support
|
|
553
|
+
|
|
554
|
+
**Q: How do I update?**
|
|
555
|
+
```bash
|
|
556
|
+
npm update -g @agentbrain/mcp-server
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
## Related Packages
|
|
562
|
+
|
|
563
|
+
- **[@agentbrain/cli](../cli)** - Generate context via command line
|
|
564
|
+
- **[@agentbrain/core](../core)** - Core library for custom integrations
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## Support
|
|
569
|
+
|
|
570
|
+
- **Documentation:** [Main README](../../README.md)
|
|
571
|
+
- **Issues:** [GitHub Issues](https://github.com/yourusername/agentbrain/issues)
|
|
572
|
+
- **MCP Protocol:** [modelcontextprotocol.io](https://modelcontextprotocol.io)
|
|
573
|
+
|
|
574
|
+
---
|
|
575
|
+
|
|
576
|
+
## License
|
|
577
|
+
|
|
578
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// AgentBrain MCP Server
|
|
3
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import { scanRepo, scanRepoSchema } from './tools/scan-repo.js';
|
|
7
|
+
import { loadStandards, loadStandardsSchema } from './tools/load-standards.js';
|
|
8
|
+
import { loadContext, loadContextSchema } from './tools/load-context.js';
|
|
9
|
+
import { saveHandoff, saveHandoffSchema } from './tools/save-handoff.js';
|
|
10
|
+
// Create MCP server
|
|
11
|
+
const server = new Server({
|
|
12
|
+
name: 'agentbrain',
|
|
13
|
+
version: '1.0.0',
|
|
14
|
+
}, {
|
|
15
|
+
capabilities: {
|
|
16
|
+
tools: {},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// Register tools
|
|
20
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
21
|
+
return {
|
|
22
|
+
tools: [scanRepoSchema, loadStandardsSchema, loadContextSchema, saveHandoffSchema],
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
// Handle tool calls
|
|
26
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
27
|
+
const { name, arguments: args } = request.params;
|
|
28
|
+
try {
|
|
29
|
+
switch (name) {
|
|
30
|
+
case 'scan_repo': {
|
|
31
|
+
const result = await scanRepo(args);
|
|
32
|
+
return {
|
|
33
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
case 'load_standards': {
|
|
37
|
+
const result = await loadStandards(args);
|
|
38
|
+
return {
|
|
39
|
+
content: [{ type: 'text', text: result.content }],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
case 'load_context': {
|
|
43
|
+
const result = await loadContext(args);
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: 'text',
|
|
48
|
+
text: `${result.content}\n\n---\n\n[Loaded from ${result.fromCache ? 'cache' : 'fresh generation'}, tokens used: ${result.tokensUsed}]`,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
case 'save_handoff': {
|
|
54
|
+
const result = await saveHandoff(args);
|
|
55
|
+
return {
|
|
56
|
+
content: [
|
|
57
|
+
{
|
|
58
|
+
type: 'text',
|
|
59
|
+
text: `Handoff saved to ${result.filePath}\n\nTokens used: ${result.tokensUsed}\n\n---\n\n${result.content}`,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
default:
|
|
65
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: 'text', text: `Error: ${message}` }],
|
|
72
|
+
isError: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// Start server
|
|
77
|
+
async function main() {
|
|
78
|
+
const transport = new StdioServerTransport();
|
|
79
|
+
await server.connect(transport);
|
|
80
|
+
// Log to stderr so it doesn't interfere with MCP protocol on stdout
|
|
81
|
+
console.error('AgentBrain MCP server running on stdio');
|
|
82
|
+
}
|
|
83
|
+
main().catch((error) => {
|
|
84
|
+
console.error('Fatal error:', error);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,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,OAAO;QACL,KAAK,EAAE,CAAC,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,iBAAiB,CAAC;KACnF,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,oBAAoB;AACpB,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,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U,cAAc,MAAM,CAAC,OAAO,EAAE;yBAC7G;qBACF;iBACF,CAAA;YACH,CAAC;YAED;gBACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;QACxE,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC;YACtD,OAAO,EAAE,IAAI;SACd,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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface LoadContextInput {
|
|
2
|
+
repo_path: string;
|
|
3
|
+
force_refresh?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface LoadContextOutput {
|
|
6
|
+
content: string;
|
|
7
|
+
fromCache: boolean;
|
|
8
|
+
tokensUsed: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function loadContext(input: LoadContextInput): Promise<LoadContextOutput>;
|
|
11
|
+
export declare const loadContextSchema: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: string;
|
|
16
|
+
properties: {
|
|
17
|
+
repo_path: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
force_refresh: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
required: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=load-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-context.d.ts","sourceRoot":"","sources":["../../src/tools/load-context.ts"],"names":[],"mappings":"AAkBA,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;CACnB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAiErF;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAkB7B,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// MCP tool: load_context - load context docs at session start
|
|
2
|
+
import { readFile } 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 { loadAIConfig, generateContext, getCachedDoc, getGitHash } 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 loadContext(input) {
|
|
17
|
+
const { repo_path, force_refresh = false } = input;
|
|
18
|
+
// Expand path to handle ~, relative paths, etc.
|
|
19
|
+
const expandedPath = expandPath(repo_path);
|
|
20
|
+
const contextDir = join(expandedPath, 'agentbrain');
|
|
21
|
+
// Try to load from disk first
|
|
22
|
+
const contextPath = join(contextDir, 'context.md');
|
|
23
|
+
const depMapPath = join(contextDir, 'dependency-map.md');
|
|
24
|
+
const patternsPath = join(contextDir, 'patterns.md');
|
|
25
|
+
const allExist = existsSync(contextPath) && existsSync(depMapPath) && existsSync(patternsPath);
|
|
26
|
+
if (!force_refresh && allExist) {
|
|
27
|
+
// Load from disk
|
|
28
|
+
const context = await readFile(contextPath, 'utf-8');
|
|
29
|
+
const depMap = await readFile(depMapPath, 'utf-8');
|
|
30
|
+
const patterns = await readFile(patternsPath, 'utf-8');
|
|
31
|
+
const combined = `# Repository Context\n\n${context}\n\n---\n\n# Dependency Map\n\n${depMap}\n\n---\n\n# Patterns\n\n${patterns}`;
|
|
32
|
+
return {
|
|
33
|
+
content: combined,
|
|
34
|
+
fromCache: true,
|
|
35
|
+
tokensUsed: 0,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Need to generate - requires API key
|
|
39
|
+
const aiConfig = await loadAIConfig();
|
|
40
|
+
const gitHash = await getGitHash(expandedPath);
|
|
41
|
+
// Check cache validity
|
|
42
|
+
const cachedContext = await getCachedDoc(expandedPath, gitHash, 'context');
|
|
43
|
+
const cachedDepMap = await getCachedDoc(expandedPath, gitHash, 'dependency-map');
|
|
44
|
+
const cachedPatterns = await getCachedDoc(expandedPath, gitHash, 'patterns');
|
|
45
|
+
if (!force_refresh && cachedContext && cachedDepMap && cachedPatterns) {
|
|
46
|
+
const combined = `# Repository Context\n\n${cachedContext.content}\n\n---\n\n# Dependency Map\n\n${cachedDepMap.content}\n\n---\n\n# Patterns\n\n${cachedPatterns.content}`;
|
|
47
|
+
return {
|
|
48
|
+
content: combined,
|
|
49
|
+
fromCache: true,
|
|
50
|
+
tokensUsed: 0,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Generate new context
|
|
54
|
+
const result = await generateContext({
|
|
55
|
+
repoPath: expandedPath,
|
|
56
|
+
aiConfig,
|
|
57
|
+
useCache: !force_refresh,
|
|
58
|
+
});
|
|
59
|
+
const combined = result.docs
|
|
60
|
+
.map((doc) => `# ${doc.type}\n\n${doc.content}`)
|
|
61
|
+
.join('\n\n---\n\n');
|
|
62
|
+
return {
|
|
63
|
+
content: combined,
|
|
64
|
+
fromCache: false,
|
|
65
|
+
tokensUsed: result.totalTokens,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export const loadContextSchema = {
|
|
69
|
+
name: 'load_context',
|
|
70
|
+
description: 'Load combined context documentation (context.md + dependency-map.md + patterns.md). Cached by git hash - repeat calls are free.',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
repo_path: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
description: 'Absolute path to the repository',
|
|
77
|
+
},
|
|
78
|
+
force_refresh: {
|
|
79
|
+
type: 'boolean',
|
|
80
|
+
description: 'Force regeneration even if cache is valid (default: false)',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ['repo_path'],
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=load-context.js.map
|
|
@@ -0,0 +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,EAAE,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ACjB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,MAAM,CAAC,WAAW;KAC/B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,iIAAiI;IACnI,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,31 @@
|
|
|
1
|
+
import type { AgentTarget } from '@agentbrain/core';
|
|
2
|
+
export interface LoadStandardsInput {
|
|
3
|
+
repo_path: string;
|
|
4
|
+
agent: AgentTarget;
|
|
5
|
+
}
|
|
6
|
+
export interface LoadStandardsOutput {
|
|
7
|
+
content: string;
|
|
8
|
+
filePath: string;
|
|
9
|
+
agent: AgentTarget;
|
|
10
|
+
}
|
|
11
|
+
export declare function loadStandards(input: LoadStandardsInput): Promise<LoadStandardsOutput>;
|
|
12
|
+
export declare const loadStandardsSchema: {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: string;
|
|
17
|
+
properties: {
|
|
18
|
+
repo_path: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
agent: {
|
|
23
|
+
type: string;
|
|
24
|
+
enum: string[];
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
required: string[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=load-standards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-standards.d.ts","sourceRoot":"","sources":["../../src/tools/load-standards.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAYnD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsB3F;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;CAmB/B,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// MCP tool: load_standards - read standards file for an agent
|
|
2
|
+
import { readFile } 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 { AGENT_FILE_PATHS } 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 loadStandards(input) {
|
|
17
|
+
const { repo_path, agent } = input;
|
|
18
|
+
// Expand path to handle ~, relative paths, etc.
|
|
19
|
+
const expandedPath = expandPath(repo_path);
|
|
20
|
+
const relativePath = AGENT_FILE_PATHS[agent];
|
|
21
|
+
const filePath = join(expandedPath, relativePath);
|
|
22
|
+
if (!existsSync(filePath)) {
|
|
23
|
+
throw new Error(`Standards file not found: ${relativePath}. Run "agentbrain standards" to generate it.`);
|
|
24
|
+
}
|
|
25
|
+
const content = await readFile(filePath, 'utf-8');
|
|
26
|
+
return {
|
|
27
|
+
content,
|
|
28
|
+
filePath: relativePath,
|
|
29
|
+
agent,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export const loadStandardsSchema = {
|
|
33
|
+
name: 'load_standards',
|
|
34
|
+
description: 'Load coding standards file for a specific agent (Claude Code, Cursor, or Windsurf). Reads from disk - no AI call needed.',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
repo_path: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Absolute path to the repository',
|
|
41
|
+
},
|
|
42
|
+
agent: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
enum: ['claude-code', 'cursor', 'windsurf'],
|
|
45
|
+
description: 'Which agent to load standards for',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ['repo_path', 'agent'],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=load-standards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-standards.js","sourceRoot":"","sources":["../../src/tools/load-standards.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,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGnD;;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,IA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: string;
|
|
8
|
+
tokensUsed: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function saveHandoff(input: SaveHandoffInput): Promise<SaveHandoffOutput>;
|
|
11
|
+
export declare const saveHandoffSchema: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: string;
|
|
16
|
+
properties: {
|
|
17
|
+
repo_path: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
goal: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
required: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=save-handoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-handoff.d.ts","sourceRoot":"","sources":["../../src/tools/save-handoff.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA8BrF;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAkB7B,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// MCP tool: save_handoff - save handoff at session end
|
|
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 { loadAIConfig, generateHandoff } 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 saveHandoff(input) {
|
|
17
|
+
const { repo_path, goal } = input;
|
|
18
|
+
// Expand path to handle ~, relative paths, etc.
|
|
19
|
+
const expandedPath = expandPath(repo_path);
|
|
20
|
+
// Load AI config
|
|
21
|
+
const aiConfig = await loadAIConfig();
|
|
22
|
+
// Generate handoff
|
|
23
|
+
const result = await generateHandoff({
|
|
24
|
+
repoPath: expandedPath,
|
|
25
|
+
aiConfig,
|
|
26
|
+
goal,
|
|
27
|
+
});
|
|
28
|
+
// Write to disk
|
|
29
|
+
const outputDir = join(expandedPath, 'agentbrain');
|
|
30
|
+
if (!existsSync(outputDir)) {
|
|
31
|
+
await mkdir(outputDir, { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
const filePath = join(outputDir, 'handoff.md');
|
|
34
|
+
await writeFile(filePath, result.doc.content, 'utf-8');
|
|
35
|
+
return {
|
|
36
|
+
content: result.doc.content,
|
|
37
|
+
filePath: 'agentbrain/handoff.md',
|
|
38
|
+
tokensUsed: result.tokenCount,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export const saveHandoffSchema = {
|
|
42
|
+
name: 'save_handoff',
|
|
43
|
+
description: 'Generate and save handoff document from git diff and recent commits. Creates agentbrain/handoff.md with session summary.',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
repo_path: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Absolute path to the repository',
|
|
50
|
+
},
|
|
51
|
+
goal: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'Optional session goal or objective to include in handoff',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
required: ['repo_path'],
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=save-handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-handoff.js","sourceRoot":"","sources":["../../src/tools/save-handoff.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,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,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEhE;;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;AAaD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAuB;IACvD,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;IAEjC,gDAAgD;IAChD,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;IAE1C,iBAAiB;IACjB,MAAM,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAA;IAErC,mBAAmB;IACnB,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC;QACnC,QAAQ,EAAE,YAAY;QACtB,QAAQ;QACR,IAAI;KACL,CAAC,CAAA;IAEF,gBAAgB;IAChB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;IAClD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;IAC9C,MAAM,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAEtD,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,OAAO;QAC3B,QAAQ,EAAE,uBAAuB;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,0HAA0H;IAC5H,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;aAC/C;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0DAA0D;aACxE;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface ScanRepoInput {
|
|
2
|
+
repo_path: string;
|
|
3
|
+
max_files?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ScanRepoOutput {
|
|
6
|
+
totalFiles: number;
|
|
7
|
+
relevantFiles: Array<{
|
|
8
|
+
path: string;
|
|
9
|
+
language: string;
|
|
10
|
+
size: number;
|
|
11
|
+
}>;
|
|
12
|
+
scannedAt: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function scanRepo(input: ScanRepoInput): Promise<ScanRepoOutput>;
|
|
15
|
+
export declare const scanRepoSchema: {
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: string;
|
|
20
|
+
properties: {
|
|
21
|
+
repo_path: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
max_files: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
required: string[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=scan-repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-repo.d.ts","sourceRoot":"","sources":["../../src/tools/scan-repo.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,KAAK,CAAC;QACnB,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAA;KACb,CAAC,CAAA;IACF,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,wBAAsB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAiB5E;AAED,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;CAkB1B,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// MCP tool: scan_repo - inspect repo structure (no API key needed)
|
|
2
|
+
import { scanRepository } 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
|
+
// Expand ~ to home directory
|
|
10
|
+
if (path.startsWith('~/') || path === '~') {
|
|
11
|
+
return path.replace('~', homedir());
|
|
12
|
+
}
|
|
13
|
+
// Resolve relative paths
|
|
14
|
+
return resolve(path);
|
|
15
|
+
}
|
|
16
|
+
export async function scanRepo(input) {
|
|
17
|
+
const { repo_path, max_files = 100 } = input;
|
|
18
|
+
// Expand path to handle ~, relative paths, etc.
|
|
19
|
+
const expandedPath = expandPath(repo_path);
|
|
20
|
+
const result = await scanRepository(expandedPath, { maxFiles: max_files });
|
|
21
|
+
return {
|
|
22
|
+
totalFiles: result.totalFiles,
|
|
23
|
+
relevantFiles: result.relevantFiles.map((f) => ({
|
|
24
|
+
path: f.path,
|
|
25
|
+
language: f.language,
|
|
26
|
+
size: f.size,
|
|
27
|
+
})),
|
|
28
|
+
scannedAt: result.scannedAt,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export const scanRepoSchema = {
|
|
32
|
+
name: 'scan_repo',
|
|
33
|
+
description: 'Inspect repository structure and get list of relevant files. No API key required - pure file analysis.',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
repo_path: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'Absolute path to the repository',
|
|
40
|
+
},
|
|
41
|
+
max_files: {
|
|
42
|
+
type: 'number',
|
|
43
|
+
description: 'Maximum number of files to analyze (default: 100)',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ['repo_path'],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=scan-repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-repo.js","sourceRoot":"","sources":["../../src/tools/scan-repo.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEjC;;GAEG;AACH,SAAS,UAAU,CAAC,IAAY;IAC9B,6BAA6B;IAC7B,IAAI,IAAI,CAAC,UAAU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
+
{
|
|
2
|
+
"name": "@agentbrain/mcp-server",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Model Context Protocol server for AgentBrain - connect Claude, Cursor, and Windsurf to repository intelligence",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agentbrain-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"ai",
|
|
17
|
+
"context",
|
|
18
|
+
"claude",
|
|
19
|
+
"cursor",
|
|
20
|
+
"windsurf",
|
|
21
|
+
"coding-agent",
|
|
22
|
+
"agentbrain"
|
|
23
|
+
],
|
|
24
|
+
"author": "AgentBrain",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/yourusername/agentbrain.git",
|
|
29
|
+
"directory": "packages/mcp-server"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/yourusername/agentbrain/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/yourusername/agentbrain#readme",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc -p tsconfig.json",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"clean": "rm -rf dist"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@agentbrain/core": "*",
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.0.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^22.10.7",
|
|
46
|
+
"typescript": "^5.7.2"
|
|
47
|
+
}
|
|
48
|
+
}
|