mindkeg-mcp 0.3.0 → 0.4.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 +141 -16
- package/dist/cli/index.js +1317 -76
- package/dist/cli/index.js.map +1 -1
- package/dist/{embedding-service-m_1dIxe7.d.ts → embedding-service-CBZ6mdiX.d.ts} +89 -0
- package/dist/{index-CZwu1Tzr.d.ts → index-D3_vod9f.d.ts} +89 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +822 -100
- package/dist/index.js.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.js +74 -8
- package/dist/models/index.js.map +1 -1
- package/dist/server/index.d.ts +65 -2
- package/dist/server/index.js +578 -94
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +173 -50
- package/dist/services/index.js.map +1 -1
- package/dist/storage/storage-adapter.d.ts +54 -2
- package/package.json +5 -2
- package/templates/AGENTS.md +20 -3
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ Unlike traditional RAG systems that chunk large documents, Mind Keg stores **pre
|
|
|
32
32
|
- API key authentication with per-repository access control
|
|
33
33
|
- SQLite storage (zero dependencies, zero config)
|
|
34
34
|
- Import/export for backup and migration
|
|
35
|
+
- **Enterprise security**: encryption at rest, audit logging, TTL/data retention, Prometheus monitoring, rate limiting, content integrity verification
|
|
35
36
|
|
|
36
37
|
## Quick Start
|
|
37
38
|
|
|
@@ -206,6 +207,18 @@ mindkeg dedup-scan --dry-run
|
|
|
206
207
|
# Backup and restore
|
|
207
208
|
mindkeg export --output backup.json
|
|
208
209
|
mindkeg import backup.json --regenerate-embeddings
|
|
210
|
+
|
|
211
|
+
# Data retention
|
|
212
|
+
mindkeg purge --older-than 90 # Purge learnings older than 90 days
|
|
213
|
+
mindkeg purge --repository /path/repo # Purge all learnings for a repo
|
|
214
|
+
mindkeg purge --all --confirm # Purge everything (requires --confirm)
|
|
215
|
+
|
|
216
|
+
# Encryption at rest
|
|
217
|
+
mindkeg encrypt-db # Encrypt existing database (requires MINDKEG_ENCRYPTION_KEY)
|
|
218
|
+
mindkeg decrypt-db # Decrypt existing database (requires MINDKEG_ENCRYPTION_KEY)
|
|
219
|
+
|
|
220
|
+
# Integrity backfill
|
|
221
|
+
mindkeg backfill-integrity # Compute SHA-256 hashes for legacy learnings
|
|
209
222
|
```
|
|
210
223
|
|
|
211
224
|
## Configuration
|
|
@@ -243,24 +256,131 @@ export MINDKEG_EMBEDDING_PROVIDER=none
|
|
|
243
256
|
|
|
244
257
|
Disables semantic search and falls back to SQLite FTS5 full-text search — all other features work identically.
|
|
245
258
|
|
|
259
|
+
## Enterprise Security
|
|
260
|
+
|
|
261
|
+
Mind Keg 0.4.0 ships a suite of security features suitable for corporate and regulated environments.
|
|
262
|
+
|
|
263
|
+
### Encryption at Rest
|
|
264
|
+
|
|
265
|
+
Encrypt `content` and `embedding` fields using AES-256-GCM. All other fields (category, tags, timestamps) remain plaintext.
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Generate a 256-bit key
|
|
269
|
+
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
|
|
270
|
+
|
|
271
|
+
export MINDKEG_ENCRYPTION_KEY=<your-base64-key>
|
|
272
|
+
mindkeg serve --stdio
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
To encrypt an existing database in-place:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
MINDKEG_ENCRYPTION_KEY=<key> mindkeg encrypt-db
|
|
279
|
+
# Creates a backup automatically before operating
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
> **Note**: FTS5 keyword search does not work when encryption is enabled. Use FastEmbed or OpenAI embedding providers for search.
|
|
283
|
+
|
|
284
|
+
### Audit Logging
|
|
285
|
+
|
|
286
|
+
All MCP tool invocations are written to a structured JSON lines audit log (SIEM-compatible).
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
export MINDKEG_AUDIT_LOG=~/.mindkeg/audit.jsonl # default
|
|
290
|
+
# Or: MINDKEG_AUDIT_LOG=stderr (write to stderr alongside app logs)
|
|
291
|
+
# Or: MINDKEG_AUDIT_LOG=none (disable)
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Each audit entry contains: `timestamp` (ISO 8601), `action`, `actor` (API key prefix), `resource_id`, `result`, `client` transport metadata. Sensitive fields (`content`, `embedding`) are never logged.
|
|
295
|
+
|
|
296
|
+
### TTL and Data Retention
|
|
297
|
+
|
|
298
|
+
Set a global default TTL or a per-learning TTL to automatically expire old entries.
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
export MINDKEG_DEFAULT_TTL_DAYS=365 # Expire all learnings after 1 year by default
|
|
302
|
+
export MINDKEG_PURGE_INTERVAL_HOURS=24 # Run purge every 24 hours (default)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Per-learning TTL overrides the global default:
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
{ "content": "...", "ttl_days": 30 }
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Manual purge:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
mindkeg purge --older-than 180 --confirm
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Monitoring
|
|
318
|
+
|
|
319
|
+
HTTP transport exposes Prometheus-compatible endpoints:
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
GET /health → JSON: { status, version, uptime, database }
|
|
323
|
+
GET /metrics → Prometheus text format
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Both endpoints are unauthenticated by default. Set `MINDKEG_METRICS_AUTH=true` to require API key auth.
|
|
327
|
+
|
|
328
|
+
Metrics exposed: `mindkeg_learnings_total`, `mindkeg_tool_invocations_total`, `mindkeg_tool_duration_seconds`, `mindkeg_errors_total`, `mindkeg_uptime_seconds`, `mindkeg_search_latency_seconds`.
|
|
329
|
+
|
|
330
|
+
### Rate Limiting
|
|
331
|
+
|
|
332
|
+
HTTP transport enforces per-API-key token bucket rate limits with separate write and read buckets.
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
export MINDKEG_RATE_LIMIT_WRITE_RPM=100 # default: 100 write req/min per key
|
|
336
|
+
export MINDKEG_RATE_LIMIT_READ_RPM=300 # default: 300 read req/min per key
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Returns HTTP 429 with `Retry-After` header when exceeded. stdio transport is not rate-limited.
|
|
340
|
+
|
|
341
|
+
### Supply Chain Security
|
|
342
|
+
|
|
343
|
+
- npm packages published with `--provenance` (Sigstore attestation via GitHub Actions)
|
|
344
|
+
- CycloneDX SBOM generated and uploaded as a release asset on every GitHub release
|
|
345
|
+
- Cosign signatures for npm tarballs uploaded as release assets
|
|
346
|
+
|
|
347
|
+
### Content Integrity
|
|
348
|
+
|
|
349
|
+
SHA-256 integrity hashes are computed and stored for every learning on write. Verify on demand:
|
|
350
|
+
|
|
351
|
+
```json
|
|
352
|
+
{ "query": "...", "verify_integrity": true }
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Each result includes `integrity_valid: true | false | null` (`null` for legacy learnings without a stored hash).
|
|
356
|
+
|
|
357
|
+
Backfill integrity hashes for existing learnings:
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
mindkeg backfill-integrity
|
|
361
|
+
```
|
|
362
|
+
|
|
246
363
|
## Data Model
|
|
247
364
|
|
|
248
365
|
Each learning contains:
|
|
249
366
|
|
|
250
|
-
| Field
|
|
251
|
-
|
|
252
|
-
| `id`
|
|
253
|
-
| `content`
|
|
254
|
-
| `category`
|
|
255
|
-
| `tags`
|
|
256
|
-
| `repository`
|
|
257
|
-
| `workspace`
|
|
258
|
-
| `group_id`
|
|
259
|
-
| `source`
|
|
260
|
-
| `status`
|
|
261
|
-
| `stale_flag`
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
367
|
+
| Field | Type | Notes |
|
|
368
|
+
|-------------------|-------------------|-------------------------------------------------------------|
|
|
369
|
+
| `id` | UUID | Auto-generated |
|
|
370
|
+
| `content` | string (max 500) | The atomic learning text (sanitized on write) |
|
|
371
|
+
| `category` | enum | One of 6 categories |
|
|
372
|
+
| `tags` | string[] | Free-form labels |
|
|
373
|
+
| `repository` | string or null | Repo path; null = workspace or global |
|
|
374
|
+
| `workspace` | string or null | Workspace path; null = repo-specific or global |
|
|
375
|
+
| `group_id` | UUID or null | Link related learnings |
|
|
376
|
+
| `source` | string | Who created this (e.g., "claude-code") |
|
|
377
|
+
| `status` | enum | `active` or `deprecated` |
|
|
378
|
+
| `stale_flag` | boolean | Agent-flagged as potentially outdated |
|
|
379
|
+
| `ttl_days` | integer or null | Per-learning TTL; overrides global `MINDKEG_DEFAULT_TTL_DAYS` |
|
|
380
|
+
| `source_agent` | string or null | Agent name for provenance tracking |
|
|
381
|
+
| `integrity_hash` | string or null | SHA-256 hash of canonical fields for tamper detection |
|
|
382
|
+
| `created_at` | ISO 8601 | Auto-set on creation |
|
|
383
|
+
| `updated_at` | ISO 8601 | Auto-updated on modification; TTL expiry anchors to this |
|
|
264
384
|
|
|
265
385
|
## Scoping
|
|
266
386
|
|
|
@@ -326,14 +446,19 @@ Mind Keg works fully offline by default. FastEmbed provides free, local semantic
|
|
|
326
446
|
```
|
|
327
447
|
CLI (Commander.js)
|
|
328
448
|
└── init / stats / serve / api-key / migrate / export / import / dedup-scan
|
|
449
|
+
purge / encrypt-db / decrypt-db / backfill-integrity
|
|
329
450
|
|
|
330
451
|
src/
|
|
331
452
|
index.ts Entry point, stdio + HTTP transports
|
|
332
453
|
server.ts MCP server + tool registration
|
|
333
454
|
config.ts Config loading (env vars → defaults)
|
|
455
|
+
audit/ Structured JSON lines audit logger
|
|
334
456
|
auth/ API key generation + validation middleware
|
|
335
|
-
|
|
336
|
-
|
|
457
|
+
crypto/ AES-256-GCM field encryption
|
|
458
|
+
monitoring/ Prometheus metrics + /health endpoint
|
|
459
|
+
security/ Content sanitization, integrity hashing, rate limiter
|
|
460
|
+
tools/ One file per MCP tool (9 tools) + shared tool-utils
|
|
461
|
+
services/ LearningService + EmbeddingService + PurgeService
|
|
337
462
|
storage/ StorageAdapter interface + SQLite impl
|
|
338
463
|
models/ Zod schemas + TypeScript types
|
|
339
464
|
utils/ Logger (pino → stderr) + error classes
|