vreko-mcp-server 3.1.1

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 ADDED
@@ -0,0 +1,548 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/lockup-white.png" width="400">
4
+ <img alt="Vreko" src="./assets/lockup-dark.png" width="400">
5
+ </picture>
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/vreko-mcp-server"><img src="https://img.shields.io/npm/v/vreko-mcp-server?style=flat-square&color=4ADE80" alt="Version" /></a>
10
+ <a href="https://github.com/vreko-dev/mcp-server/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=flat-square" alt="License" /></a>
11
+ <a href="https://discord.gg/B4BXeYkE2F"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=flat-square&logo=discord&logoColor=white" alt="Discord" /></a>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <strong>AI-powered context server for the Vreko platform.</strong><br />
16
+ Enables Claude, Cursor, and other AI assistants to coordinate with your code intelligence system.
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="#-quick-start">Quick Start</a> ·
21
+ <a href="#-what-is-vreko-mcp-server">About</a> ·
22
+ <a href="#-architecture">Architecture</a> ·
23
+ <a href="#-api-reference">API</a> ·
24
+ <a href="https://docs.vreko.dev/mcp">Documentation</a>
25
+ </p>
26
+
27
+ ---
28
+
29
+ ## What is Vreko MCP Server?
30
+
31
+ Vreko MCP Server is a **Model Context Protocol (MCP) server** that gives AI coding agents a session memory and intelligence layer. It enables Claude, Cursor, Windsurf, and any MCP-compatible assistant to:
32
+
33
+ - **Brief themselves** before every task - past learnings, active warnings, risk context
34
+ - **Check vitals mid-session** - activity level, risk pressure, trajectory
35
+ - **Capture discoveries** - patterns, gotchas, and decisions that carry forward to future sessions
36
+ - **Close with ceremony** - session outcome recorded, compound intelligence grows
37
+
38
+ **Key Capabilities:**
39
+ | Feature | Description |
40
+ |---------|-------------|
41
+ | **Session Intelligence** | `vreko` → `vreko_pulse` → `vreko_learn` → `vreko_end` - the agentic coding loop |
42
+ | **Pattern Memory** | Learns your codebase’s specific failure modes over time |
43
+ | **Multi-Assistant Support** | Works with Claude, Cursor, Windsurf, and any MCP-compatible client |
44
+ | **Cloud & Local Modes** | Deploy to Fly.io or run locally via CLI |
45
+ | **Security-First** | API key validation, path traversal protection, CORS security |
46
+
47
+ ---
48
+
49
+ ## Quick Start
50
+
51
+ ### 1. Install
52
+
53
+ **Option A: npx (No Installation)**
54
+ ```bash
55
+ npx vreko-mcp-server
56
+ ```
57
+
58
+ **Option B: Global Install**
59
+ ```bash
60
+ npm install -g vreko-mcp-server
61
+ vreko-mcp-server
62
+ ```
63
+
64
+ **Option C: Docker**
65
+ ```bash
66
+ docker run -p 8080:8080 -e VREKO_API_KEY=your_key vreko/mcp-server
67
+ ```
68
+
69
+ ### 2. Configure Your AI Assistant
70
+
71
+ **Claude Desktop Config** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
72
+ ```json
73
+ {
74
+ "mcpServers": {
75
+ "vreko": {
76
+ "command": "npx",
77
+ "args": ["vreko-mcp-server"],
78
+ "env": {
79
+ "VREKO_API_KEY": "YOUR_VREKO_API_KEY"
80
+ }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ **Cursor Config** (Settings → MCP):
87
+ ```json
88
+ {
89
+ "mcpServers": {
90
+ "vreko": {
91
+ "command": "npx",
92
+ "args": ["vreko-mcp-server"],
93
+ "env": {
94
+ "VREKO_API_KEY": "YOUR_VREKO_API_KEY"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ ### 3. Verify Installation
102
+
103
+ ```bash
104
+ # Health check
105
+ curl http://localhost:8080/health
106
+
107
+ # Expected response:
108
+ {"status":"healthy","version":"1.0.0","timestamp":"2026-01-..."}
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Architecture
114
+
115
+ Wraps the CLI-based MCP server (`packages/mcp`) in an Express HTTP server that can be deployed to Fly.io or other cloud providers. This allows Claude Desktop, Cursor, and other AI tools to connect to Vreko over HTTPS instead of requiring local installation.
116
+
117
+ ```
118
+ ┌─────────────────────────────────────────────────────────────┐
119
+ │ AI Assistant Clients │
120
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
121
+ │ │Claude Desktop│ │ Cursor │ │ Other MCP Tools │ │
122
+ │ └──────┬───────┘ └──────┬───────┘ └────────┬─────────┘ │
123
+ └─────────┼─────────────────┼───────────────────┼────────────┘
124
+ │ │ │
125
+ └─────────────────┼───────────────────┘
126
+ ▼ HTTPS
127
+ ┌─────────────────────────────────────────────────────────────┐
128
+ │ apps/mcp-server │
129
+ │ ┌────────────────────────────────────────────────────────┐ │
130
+ │ │ Express HTTP Server • API Key Auth • CORS │ │
131
+ │ │ • Request Validation • Error Handling • Logging │ │
132
+ │ └────────────────────┬───────────────────────────────────┘ │
133
+ └───────────────────────┼─────────────────────────────────────┘
134
+ ▼ Stdio
135
+ ┌─────────────────────────────────────────────────────────────┐
136
+ │ packages/mcp │
137
+ │ ┌────────────────────────────────────────────────────────┐ │
138
+ │ │ MCP Protocol Handler • Tool Registry • Context │ │
139
+ │ └────────────────────┬───────────────────────────────────┘ │
140
+ └───────────────────────┼─────────────────────────────────────┘
141
+
142
+ ┌─────────────────────────────────────────────────────────────┐
143
+ │ Vreko Platform │
144
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
145
+ │ │Pattern Memory│ │ Snapshot │ │ Intelligence │ │
146
+ │ │ Engine │ │ Engine │ │ Layer │ │
147
+ │ └──────────────┘ └──────────────┘ └──────────────────┘ │
148
+ └─────────────────────────────────────────────────────────────┘
149
+ ```
150
+
151
+ ### Component Responsibilities
152
+
153
+ | Component | Responsibility |
154
+ |-----------|----------------|
155
+ | **HTTP Server** | Handles HTTPS requests, authentication, request/response formatting |
156
+ | **MCP Protocol** | Implements Model Context Protocol spec, tool registration, JSON-RPC |
157
+ | **Vreko Core** | Pattern analysis, snapshot management, learning capture |
158
+
159
+ ## Local Development
160
+
161
+ ### Build
162
+
163
+ ```bash
164
+ pnpm build
165
+ ```
166
+
167
+ ### Run
168
+
169
+ ```bash
170
+ # Development
171
+ PORT=8080 NODE_ENV=development node dist/index.js
172
+
173
+ # With API key
174
+ VREKO_API_KEY=YOUR_VREKO_API_KEY PORT=8080 node dist/index.js
175
+ ```
176
+
177
+ ### Test Health
178
+
179
+ ```bash
180
+ curl http://localhost:8080/health
181
+ ```
182
+
183
+ ### Test MCP Call
184
+
185
+ ```bash
186
+ # Initialize MCP session (standard JSON-RPC initialize handshake)
187
+ curl -X POST http://localhost:8080/mcp \
188
+ -H "Content-Type: application/json" \
189
+ -H "x-workspace-path: /path/to/your/project" \
190
+ -H "x-api-key: YOUR_VREKO_API_KEY" \
191
+ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
192
+ ```
193
+
194
+ ## Deployment to Fly.io
195
+
196
+ ### Quick Deploy (Recommended)
197
+
198
+ From the monorepo root:
199
+
200
+ ```bash
201
+ # Full deployment with pre-flight checks and verification
202
+ pnpm --filter=vreko-mcp-server deploy
203
+
204
+ # Dry run (validates without deploying)
205
+ pnpm --filter=vreko-mcp-server deploy:dry-run
206
+ ```
207
+
208
+ The deploy script automatically:
209
+ - ✅ Validates Fly CLI is installed and authenticated
210
+ - ✅ Checks for uncommitted changes
211
+ - ✅ Builds and validates the bundle
212
+ - ✅ Deploys to Fly.io
213
+ - ✅ Verifies health and `/bridge/push` endpoints after deployment
214
+
215
+ ### Alternative Deploy Methods
216
+
217
+ ```bash
218
+ # Quick deploy (skips pre-flight checks)
219
+ pnpm --filter=vreko-mcp-server deploy:quick
220
+
221
+ # Force immediate deployment (no rolling update)
222
+ pnpm --filter=vreko-mcp-server deploy:force
223
+
224
+ # Check deployment status
225
+ pnpm --filter=vreko-mcp-server deploy:status
226
+
227
+ # View live logs
228
+ pnpm --filter=vreko-mcp-server deploy:logs
229
+
230
+ # View releases for rollback
231
+ pnpm --filter=vreko-mcp-server deploy:rollback
232
+ ```
233
+
234
+ ### First-Time Setup
235
+
236
+ If deploying for the first time:
237
+
238
+ ```bash
239
+ # 1. Login to Fly.io
240
+ fly auth login
241
+
242
+ # 2. Create the app (only once)
243
+ fly apps create vreko-mcp
244
+
245
+ # 3. Set secrets
246
+ fly secrets set VREKO_API_KEY=YOUR_VREKO_API_KEY -a vreko-mcp
247
+ fly secrets set CORS_ORIGIN=https://your-domain.com -a vreko-mcp
248
+
249
+ # 4. Deploy
250
+ pnpm --filter=vreko-mcp-server deploy
251
+ ```
252
+
253
+ ### CI/CD Deployment
254
+
255
+ Automatic deployments are triggered on push to `main` when changes are detected in:
256
+ - `apps/mcp-server/**`
257
+ - `packages/mcp/**`, `packages/core/**`, `packages/intelligence/**`
258
+
259
+ **Required GitHub Secret**: `FLY_API_TOKEN`
260
+
261
+ Generate a token: `fly tokens create deploy -x 999999h`
262
+
263
+ ### Verify Deployment
264
+
265
+ ```bash
266
+ # Health check
267
+ curl https://vreko-mcp.fly.dev/health
268
+
269
+ # Bridge endpoint test
270
+ curl -X POST https://vreko-mcp.fly.dev/bridge/push \
271
+ -H "Content-Type: application/json" \
272
+ -d '{"workspaceId":"ws_00000000000000000000000000000000","observations":[]}'
273
+ ```
274
+
275
+ Expected responses:
276
+ ```json
277
+ {"status":"healthy","uptime":123.456,"timestamp":"2025-01-06T...","version":"1.0.0"}
278
+ {"received":true,"observationsCount":0,"changesCount":0}
279
+ ```
280
+
281
+ ### Rollback
282
+
283
+ If something goes wrong:
284
+
285
+ ```bash
286
+ # List recent releases
287
+ fly releases -a vreko-mcp
288
+
289
+ # Rollback to a previous version
290
+ fly releases rollback v123 -a vreko-mcp
291
+ ```
292
+
293
+ ## Configuration
294
+
295
+ ### Environment Variables
296
+
297
+ | Variable | Default | Description |
298
+ |----------|---------|-------------|
299
+ | `PORT` | 8080 | Server port |
300
+ | `NODE_ENV` | development | Environment (production/development) |
301
+ | `VREKO_API_KEY` | (required) | API key for authentication |
302
+ | `CORS_ORIGIN` | * | Allowed CORS origins (comma-separated) |
303
+ | `LOG_LEVEL` | info | Logging level |
304
+
305
+ ### Fly.io Secrets
306
+
307
+ Set via `fly secrets set KEY=value`:
308
+
309
+ ```bash
310
+ fly secrets set VREKO_API_KEY=YOUR_VREKO_API_KEY
311
+ fly secrets set CORS_ORIGIN=https://your-app.com
312
+ ```
313
+
314
+ View secrets:
315
+ ```bash
316
+ fly secrets list
317
+ ```
318
+
319
+ ## The V2 Agentic Workflow
320
+
321
+ Vreko MCP exposes a **4-tool session API** designed for the agentic coding loop. Configure once, and your AI assistant uses it automatically:
322
+
323
+ | Tool | When | What it does |
324
+ |------|------|--------------|
325
+ | `vreko` | Task start | Returns intelligence briefing: recent learnings, active warnings, session lineage |
326
+ | `vreko_pulse` | Mid-session | Read-only vitals: pulse level, risk pressure, trajectory |
327
+ | `vreko_learn` | Any discovery | Records a pattern, gotcha, or decision for future sessions |
328
+ | `vreko_end` | Task complete | Closes session with ceremony - outcome, carry-forward context |
329
+
330
+ ```
331
+ vreko({ task: "add rate limiting to API" })
332
+ → briefing: 3 past learnings, 1 active warning, lineage from last session
333
+
334
+ [... agent works ...]
335
+
336
+ vreko_pulse()
337
+ → pulse: racing, pressure: 71%, trajectory: increasing - snapshot recommended
338
+
339
+ vreko_learn({ insight: "rate limiting config is shared - test in staging first" })
340
+
341
+ vreko_end({ outcome: "completed" })
342
+ → ceremony: 4 files modified, 1 learning captured, context carried forward
343
+ ```
344
+
345
+ The full consolidated surface is also available: `check`, `advise`, `guide`, `safe_to_write`, intelligence and refactoring tools. See [MCP documentation →](https://docs.vreko.dev/mcp)
346
+
347
+ ---
348
+
349
+ ## API Reference
350
+
351
+ ### `GET /health`
352
+
353
+ Health check endpoint.
354
+
355
+ **Response:**
356
+ ```json
357
+ {
358
+ "status": "healthy",
359
+ "uptime": 123.456,
360
+ "timestamp": "2024-12-30T...",
361
+ "version": "1.0.0"
362
+ }
363
+ ```
364
+
365
+ ### `POST /mcp`
366
+
367
+ Main MCP endpoint - handles standard JSON-RPC 2.0 requests per the MCP protocol spec.
368
+
369
+ **Headers:**
370
+ ```
371
+ x-workspace-path: /absolute/path/to/project
372
+ x-api-key: YOUR_VREKO_API_KEY
373
+ mcp-session-id: (returned from initialize, required for subsequent calls)
374
+ ```
375
+
376
+ **Example - initialize session:**
377
+ ```json
378
+ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-client","version":"1.0"}}}
379
+ ```
380
+
381
+ **Response:** Standard JSON-RPC 2.0 response. The `mcp-session-id` header in the response must be included in all subsequent requests.
382
+
383
+ ## Security
384
+
385
+ - **Authentication**: Required `apiKey` parameter (validated against `VREKO_API_KEY`)
386
+ - **HTTPS Only**: Fly.io auto-configures HTTPS on port 443
387
+ - **CORS**: Configurable via `CORS_ORIGIN` environment variable
388
+ - **Non-root user**: Container runs as unprivileged user
389
+ - **Request timeouts**: 30-second timeout on MCP calls
390
+ - **Rate limiting**: Consider adding in production (not yet implemented)
391
+
392
+ ## Monitoring
393
+
394
+ ### Logs
395
+
396
+ ```bash
397
+ fly logs
398
+ ```
399
+
400
+ ### Metrics
401
+
402
+ ```bash
403
+ # CPU/Memory usage
404
+ fly scale show
405
+
406
+ # App status
407
+ fly status
408
+ ```
409
+
410
+ ### Scaling
411
+
412
+ Edit `fly.toml`:
413
+ ```toml
414
+ [scaling]
415
+ min_count = 1
416
+ max_count = 5
417
+ ```
418
+
419
+ Then deploy:
420
+ ```bash
421
+ fly deploy
422
+ ```
423
+
424
+ ## Troubleshooting
425
+
426
+ ### "Connection refused"
427
+
428
+ Ensure Fly.io app is running:
429
+ ```bash
430
+ fly status
431
+ ```
432
+
433
+ ### "Unauthorized"
434
+
435
+ Check that API key is set:
436
+ ```bash
437
+ fly secrets list
438
+ ```
439
+
440
+ Should show `VREKO_API_KEY`.
441
+
442
+ ### "MCP server timeout"
443
+
444
+ Default timeout is 30 seconds. Check workspace size and API key validity.
445
+
446
+ ### Logs show errors
447
+
448
+ View detailed logs:
449
+ ```bash
450
+ fly logs --follow
451
+ ```
452
+
453
+ ## Integration with VS Code Extension
454
+
455
+ ### Quick Setup (2 steps)
456
+
457
+ 1. **Get your API key** from deployment output (look for `YOUR_VREKO_API_KEY`)
458
+ 2. **Configure VS Code settings**:
459
+
460
+ ```json
461
+ {
462
+ "vreko.mcp.enabled": true,
463
+ "vreko.mcp.serverUrl": "https://vreko-mcp.fly.dev",
464
+ "vreko.mcp.authType": "apikey"
465
+ }
466
+ ```
467
+
468
+ 3. **Store your API key securely** using VS Code command palette:
469
+ - Press `Cmd+Shift+P` / `Ctrl+Shift+P`
470
+ - Run: `Vreko: Set MCP Auth Token (Secure)`
471
+ - Paste your API key: `YOUR_VREKO_API_KEY`
472
+
473
+ ### Configuration Options
474
+
475
+ | Setting | Default | Description |
476
+ |---------|---------|-------------|
477
+ | `vreko.mcp.enabled` | `true` | Enable MCP integration |
478
+ | `vreko.mcp.serverUrl` | `https://mcp.vreko.dev` | Remote MCP server URL |
479
+ | `vreko.mcp.authType` | `bearer` | Authentication type (`bearer` or `apikey`) |
480
+ | `vreko.mcp.timeout` | `5000` | Request timeout in milliseconds |
481
+
482
+ ### Programmatic Usage
483
+
484
+ The VS Code extension automatically uses `RemoteMCPClient` when `serverUrl` is configured:
485
+
486
+ ```typescript
487
+ const client = new RemoteMCPClient({
488
+ serverUrl: 'https://vreko-mcp.fly.dev',
489
+ apiKey: 'YOUR_VREKO_API_KEY',
490
+ authType: 'apikey',
491
+ timeout: 5000,
492
+ maxRetries: 3,
493
+ });
494
+
495
+ await client.connect();
496
+ ```
497
+
498
+ See [`apps/vscode/src/services/RemoteMCPClient.ts`](../vscode/src/services/RemoteMCPClient.ts) for implementation details.
499
+
500
+ ### Health Check
501
+
502
+ Verify the server is accessible:
503
+
504
+ ```bash
505
+ curl https://vreko-mcp.fly.dev/health
506
+ ```
507
+
508
+ Expected response:
509
+ ```json
510
+ {"status":"healthy","uptime":123.45,"timestamp":"2025-12-31T...","version":"1.0.0"}
511
+ ```
512
+
513
+ ## Cost
514
+
515
+ Fly.io free tier includes:
516
+ - 3 shared-cpu-1x VMs (256MB each)
517
+ - 160GB bandwidth/month
518
+
519
+ This MCP server easily fits within free tier for individual/small team use.
520
+
521
+ ## Status
522
+
523
+ | Metric | Value |
524
+ |--------|-------|
525
+ | **Version** | 3.1.0 |
526
+ | **License** | Apache-2.0 |
527
+ | **Status** | Production Ready |
528
+ | **Node.js** | >= 20.0.0 |
529
+
530
+ ## References
531
+
532
+ - [Fly.io Docs](https://fly.io/docs/)
533
+ - [MCP Protocol Spec](https://modelcontextprotocol.io/)
534
+ - [Vreko Documentation](https://docs.vreko.dev/mcp)
535
+ - [VS Code Extension](https://github.com/vreko-dev/vscode)
536
+
537
+ ---
538
+
539
+ <p align="center">
540
+ <sub>Built with 💚 by <a href="https://vreko.dev">Marcelle Labs</a></sub>
541
+ </p>
542
+
543
+ <p align="center">
544
+ <a href="https://vreko.dev">Website</a> •
545
+ <a href="https://docs.vreko.dev">Docs</a> •
546
+ <a href="https://discord.gg/B4BXeYkE2F">Discord</a> •
547
+ <a href="https://github.com/vreko-dev/mcp-server/issues">Issues</a>
548
+ </p>