@pan-sec/notebooklm-mcp 1.4.0 → 1.6.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.
Files changed (123) hide show
  1. package/README.md +61 -7
  2. package/SECURITY.md +40 -6
  3. package/dist/auth/mcp-auth.d.ts.map +1 -1
  4. package/dist/auth/mcp-auth.js +3 -6
  5. package/dist/auth/mcp-auth.js.map +1 -1
  6. package/dist/compliance/alert-manager.d.ts +120 -0
  7. package/dist/compliance/alert-manager.d.ts.map +1 -0
  8. package/dist/compliance/alert-manager.js +420 -0
  9. package/dist/compliance/alert-manager.js.map +1 -0
  10. package/dist/compliance/breach-detection.d.ts +134 -0
  11. package/dist/compliance/breach-detection.d.ts.map +1 -0
  12. package/dist/compliance/breach-detection.js +456 -0
  13. package/dist/compliance/breach-detection.js.map +1 -0
  14. package/dist/compliance/change-log.d.ts +113 -0
  15. package/dist/compliance/change-log.d.ts.map +1 -0
  16. package/dist/compliance/change-log.js +275 -0
  17. package/dist/compliance/change-log.js.map +1 -0
  18. package/dist/compliance/compliance-logger.d.ts +136 -0
  19. package/dist/compliance/compliance-logger.d.ts.map +1 -0
  20. package/dist/compliance/compliance-logger.js +425 -0
  21. package/dist/compliance/compliance-logger.js.map +1 -0
  22. package/dist/compliance/compliance-tools.d.ts +18 -0
  23. package/dist/compliance/compliance-tools.d.ts.map +1 -0
  24. package/dist/compliance/compliance-tools.js +673 -0
  25. package/dist/compliance/compliance-tools.js.map +1 -0
  26. package/dist/compliance/consent-manager.d.ts +130 -0
  27. package/dist/compliance/consent-manager.d.ts.map +1 -0
  28. package/dist/compliance/consent-manager.js +386 -0
  29. package/dist/compliance/consent-manager.js.map +1 -0
  30. package/dist/compliance/dashboard.d.ts +243 -0
  31. package/dist/compliance/dashboard.d.ts.map +1 -0
  32. package/dist/compliance/dashboard.js +519 -0
  33. package/dist/compliance/dashboard.js.map +1 -0
  34. package/dist/compliance/data-classification.d.ts +117 -0
  35. package/dist/compliance/data-classification.d.ts.map +1 -0
  36. package/dist/compliance/data-classification.js +469 -0
  37. package/dist/compliance/data-classification.js.map +1 -0
  38. package/dist/compliance/data-erasure.d.ts +110 -0
  39. package/dist/compliance/data-erasure.d.ts.map +1 -0
  40. package/dist/compliance/data-erasure.js +501 -0
  41. package/dist/compliance/data-erasure.js.map +1 -0
  42. package/dist/compliance/data-export.d.ts +85 -0
  43. package/dist/compliance/data-export.d.ts.map +1 -0
  44. package/dist/compliance/data-export.js +394 -0
  45. package/dist/compliance/data-export.js.map +1 -0
  46. package/dist/compliance/data-inventory.d.ts +136 -0
  47. package/dist/compliance/data-inventory.d.ts.map +1 -0
  48. package/dist/compliance/data-inventory.js +335 -0
  49. package/dist/compliance/data-inventory.js.map +1 -0
  50. package/dist/compliance/dsar-handler.d.ts +123 -0
  51. package/dist/compliance/dsar-handler.d.ts.map +1 -0
  52. package/dist/compliance/dsar-handler.js +371 -0
  53. package/dist/compliance/dsar-handler.js.map +1 -0
  54. package/dist/compliance/evidence-collector.d.ts +187 -0
  55. package/dist/compliance/evidence-collector.d.ts.map +1 -0
  56. package/dist/compliance/evidence-collector.js +656 -0
  57. package/dist/compliance/evidence-collector.js.map +1 -0
  58. package/dist/compliance/health-monitor.d.ts +111 -0
  59. package/dist/compliance/health-monitor.d.ts.map +1 -0
  60. package/dist/compliance/health-monitor.js +509 -0
  61. package/dist/compliance/health-monitor.js.map +1 -0
  62. package/dist/compliance/incident-manager.d.ts +131 -0
  63. package/dist/compliance/incident-manager.d.ts.map +1 -0
  64. package/dist/compliance/incident-manager.js +418 -0
  65. package/dist/compliance/incident-manager.js.map +1 -0
  66. package/dist/compliance/index.d.ts +32 -0
  67. package/dist/compliance/index.d.ts.map +1 -0
  68. package/dist/compliance/index.js +35 -0
  69. package/dist/compliance/index.js.map +1 -0
  70. package/dist/compliance/policy-docs.d.ts +108 -0
  71. package/dist/compliance/policy-docs.d.ts.map +1 -0
  72. package/dist/compliance/policy-docs.js +464 -0
  73. package/dist/compliance/policy-docs.js.map +1 -0
  74. package/dist/compliance/privacy-notice-text.d.ts +58 -0
  75. package/dist/compliance/privacy-notice-text.d.ts.map +1 -0
  76. package/dist/compliance/privacy-notice-text.js +161 -0
  77. package/dist/compliance/privacy-notice-text.js.map +1 -0
  78. package/dist/compliance/privacy-notice.d.ts +128 -0
  79. package/dist/compliance/privacy-notice.d.ts.map +1 -0
  80. package/dist/compliance/privacy-notice.js +250 -0
  81. package/dist/compliance/privacy-notice.js.map +1 -0
  82. package/dist/compliance/report-generator.d.ts +168 -0
  83. package/dist/compliance/report-generator.d.ts.map +1 -0
  84. package/dist/compliance/report-generator.js +830 -0
  85. package/dist/compliance/report-generator.js.map +1 -0
  86. package/dist/compliance/retention-engine.d.ts +130 -0
  87. package/dist/compliance/retention-engine.d.ts.map +1 -0
  88. package/dist/compliance/retention-engine.js +510 -0
  89. package/dist/compliance/retention-engine.js.map +1 -0
  90. package/dist/compliance/siem-exporter.d.ts +150 -0
  91. package/dist/compliance/siem-exporter.d.ts.map +1 -0
  92. package/dist/compliance/siem-exporter.js +509 -0
  93. package/dist/compliance/siem-exporter.js.map +1 -0
  94. package/dist/compliance/types.d.ts +601 -0
  95. package/dist/compliance/types.d.ts.map +1 -0
  96. package/dist/compliance/types.js +22 -0
  97. package/dist/compliance/types.js.map +1 -0
  98. package/dist/config.d.ts +4 -0
  99. package/dist/config.d.ts.map +1 -1
  100. package/dist/config.js +8 -1
  101. package/dist/config.js.map +1 -1
  102. package/dist/library/notebook-library.d.ts.map +1 -1
  103. package/dist/library/notebook-library.js +2 -1
  104. package/dist/library/notebook-library.js.map +1 -1
  105. package/dist/session/shared-context-manager.d.ts.map +1 -1
  106. package/dist/session/shared-context-manager.js +2 -1
  107. package/dist/session/shared-context-manager.js.map +1 -1
  108. package/dist/utils/audit-logger.d.ts +21 -1
  109. package/dist/utils/audit-logger.d.ts.map +1 -1
  110. package/dist/utils/audit-logger.js +53 -4
  111. package/dist/utils/audit-logger.js.map +1 -1
  112. package/dist/utils/crypto.d.ts.map +1 -1
  113. package/dist/utils/crypto.js +8 -15
  114. package/dist/utils/crypto.js.map +1 -1
  115. package/dist/utils/file-permissions.d.ts +85 -0
  116. package/dist/utils/file-permissions.d.ts.map +1 -0
  117. package/dist/utils/file-permissions.js +180 -0
  118. package/dist/utils/file-permissions.js.map +1 -0
  119. package/dist/utils/settings-manager.d.ts.map +1 -1
  120. package/dist/utils/settings-manager.js +6 -11
  121. package/dist/utils/settings-manager.js.map +1 -1
  122. package/docs/COMPLIANCE-SPEC.md +1452 -0
  123. package/package.json +30 -4
@@ -0,0 +1,1452 @@
1
+ # Enterprise Compliance Specification
2
+
3
+ **Version**: 1.0.0
4
+ **Date**: 2025-12-16
5
+ **Standards**: GDPR, SOC2 Type II, CSSF (Luxembourg)
6
+ **Status**: Draft
7
+
8
+ ---
9
+
10
+ ## Table of Contents
11
+
12
+ 1. [Overview](#overview)
13
+ 2. [Phase 1: Core Compliance Infrastructure](#phase-1-core-compliance-infrastructure)
14
+ 3. [Phase 2: Data Subject Rights](#phase-2-data-subject-rights-gdpr)
15
+ 4. [Phase 3: Security Monitoring & Incident Response](#phase-3-security-monitoring--incident-response)
16
+ 5. [Phase 4: Compliance Reporting & Documentation](#phase-4-compliance-reporting--documentation)
17
+ 6. [Configuration Reference](#configuration-reference)
18
+ 7. [File Structure](#file-structure)
19
+
20
+ ---
21
+
22
+ ## Overview
23
+
24
+ ### Current State
25
+
26
+ The NotebookLM MCP Server already implements strong security foundations:
27
+
28
+ | Existing Feature | Implementation |
29
+ |-----------------|----------------|
30
+ | Audit Logging | Hash-chained JSONL with tamper detection |
31
+ | Encryption at Rest | ML-KEM-768 + ChaCha20-Poly1305 (post-quantum) |
32
+ | Encryption in Transit | TLS with certificate pinning |
33
+ | PII Protection | Auto-sanitization in all logs |
34
+ | Access Control | Token-based auth with rate limiting |
35
+ | Session Security | Hard timeout (8h) + inactivity (30m) |
36
+ | Secrets Detection | 50+ patterns, auto-redaction |
37
+ | Memory Security | Secure wiping, auto-expiry credentials |
38
+ | Data Retention | 30-day audit log rotation |
39
+
40
+ ### Compliance Gaps
41
+
42
+ | Gap | GDPR | SOC2 | CSSF | Priority |
43
+ |-----|------|------|------|----------|
44
+ | Consent Management | Required | - | Required | P1 |
45
+ | Data Subject Rights (DSAR) | Required | - | Required | P1 |
46
+ | Data Export/Portability | Required | - | Required | P1 |
47
+ | Right to Erasure | Required | - | Required | P1 |
48
+ | Data Classification | - | Required | Required | P1 |
49
+ | SIEM Integration | - | Required | Required | P2 |
50
+ | Breach Detection | Required | Required | Required | P2 |
51
+ | Incident Response | - | Required | Required | P2 |
52
+ | Compliance Reporting | - | Required | Required | P3 |
53
+ | Change Management | - | Required | Required | P3 |
54
+
55
+ ---
56
+
57
+ ## Phase 1: Core Compliance Infrastructure
58
+
59
+ ### 1.1 Compliance Logger
60
+
61
+ **File**: `src/utils/compliance-logger.ts`
62
+
63
+ **Purpose**: Structured logging specifically for compliance events, separate from operational audit logs.
64
+
65
+ **Event Categories**:
66
+
67
+ ```typescript
68
+ type ComplianceEventCategory =
69
+ | "consent" // Consent granted/revoked
70
+ | "data_access" // Data access requests
71
+ | "data_export" // Data portability requests
72
+ | "data_deletion" // Erasure requests
73
+ | "data_processing" // Processing activities
74
+ | "security_incident" // Security events
75
+ | "policy_change" // Configuration changes
76
+ | "access_control" // Auth events
77
+ | "retention" // Data retention events
78
+ | "breach"; // Breach notifications
79
+ ```
80
+
81
+ **Event Structure**:
82
+
83
+ ```typescript
84
+ interface ComplianceEvent {
85
+ // Required fields
86
+ id: string; // UUID v4
87
+ timestamp: string; // ISO 8601
88
+ category: ComplianceEventCategory;
89
+ event_type: string; // Specific event (e.g., "consent_granted")
90
+
91
+ // Actor information
92
+ actor: {
93
+ type: "user" | "system" | "admin";
94
+ id?: string; // User/session ID if applicable
95
+ ip?: string; // Masked IP (last octet zeroed)
96
+ };
97
+
98
+ // Event details
99
+ resource?: {
100
+ type: string; // e.g., "notebook", "session", "audit_log"
101
+ id?: string;
102
+ };
103
+
104
+ // Compliance metadata
105
+ legal_basis?: string; // GDPR legal basis
106
+ data_categories?: string[]; // Types of data involved
107
+ retention_days?: number; // How long to retain this event
108
+
109
+ // Outcome
110
+ outcome: "success" | "failure" | "pending";
111
+ failure_reason?: string;
112
+
113
+ // Integrity
114
+ hash: string;
115
+ previous_hash: string;
116
+ }
117
+ ```
118
+
119
+ **Storage**:
120
+ - Location: `<data_dir>/compliance/events-YYYY-MM.jsonl`
121
+ - Retention: Configurable, default 7 years (CSSF requirement)
122
+ - Format: JSONL with hash chain
123
+ - Encryption: Post-quantum encrypted
124
+
125
+ **Configuration**:
126
+
127
+ ```bash
128
+ NLMCP_COMPLIANCE_ENABLED=true
129
+ NLMCP_COMPLIANCE_DIR=/path/to/compliance
130
+ NLMCP_COMPLIANCE_RETENTION_YEARS=7
131
+ NLMCP_COMPLIANCE_ENCRYPTION=true
132
+ ```
133
+
134
+ ---
135
+
136
+ ### 1.2 Data Classification System
137
+
138
+ **File**: `src/utils/data-classification.ts`
139
+
140
+ **Purpose**: Tag all data by sensitivity level for appropriate handling.
141
+
142
+ **Classification Levels**:
143
+
144
+ ```typescript
145
+ enum DataClassification {
146
+ PUBLIC = "public", // No restrictions
147
+ INTERNAL = "internal", // Internal use only
148
+ CONFIDENTIAL = "confidential", // Restricted access
149
+ RESTRICTED = "restricted", // Highly sensitive (PII, credentials)
150
+ REGULATED = "regulated" // Subject to regulatory requirements
151
+ }
152
+
153
+ interface ClassifiedData {
154
+ classification: DataClassification;
155
+ data_categories: DataCategory[];
156
+ retention_policy: string;
157
+ encryption_required: boolean;
158
+ audit_required: boolean;
159
+ exportable: boolean;
160
+ erasable: boolean;
161
+ }
162
+
163
+ type DataCategory =
164
+ | "personal_data" // GDPR personal data
165
+ | "sensitive_data" // GDPR special categories
166
+ | "credentials" // Auth tokens, passwords
167
+ | "session_data" // Browser session state
168
+ | "usage_data" // Analytics, telemetry
169
+ | "configuration" // Settings, preferences
170
+ | "audit_logs" // Compliance logs
171
+ | "notebook_metadata"; // Notebook URLs, descriptions
172
+ ```
173
+
174
+ **Data Inventory**:
175
+
176
+ | Data Type | Classification | Categories | Retention | Encrypted |
177
+ |-----------|---------------|------------|-----------|-----------|
178
+ | Auth tokens | RESTRICTED | credentials | Session | Yes |
179
+ | Browser cookies | RESTRICTED | session_data, personal_data | 24h | Yes |
180
+ | Notebook library | CONFIDENTIAL | notebook_metadata | Indefinite | Yes |
181
+ | Audit logs | REGULATED | audit_logs | 7 years | Yes |
182
+ | Compliance events | REGULATED | audit_logs | 7 years | Yes |
183
+ | User settings | INTERNAL | configuration | Indefinite | No |
184
+ | Session data | CONFIDENTIAL | session_data | 8h max | Yes |
185
+ | PQ encryption keys | RESTRICTED | credentials | Indefinite | Yes |
186
+
187
+ ---
188
+
189
+ ### 1.3 Consent Manager
190
+
191
+ **File**: `src/compliance/consent-manager.ts`
192
+
193
+ **Purpose**: Track and manage user consent for data processing activities.
194
+
195
+ **Consent Types**:
196
+
197
+ ```typescript
198
+ interface ConsentRecord {
199
+ id: string; // UUID
200
+ version: string; // Consent version (e.g., "1.0.0")
201
+ granted_at: string; // ISO 8601
202
+ expires_at?: string; // Optional expiry
203
+
204
+ // What was consented to
205
+ purposes: ConsentPurpose[];
206
+ data_categories: DataCategory[];
207
+
208
+ // Legal basis (GDPR Article 6)
209
+ legal_basis: LegalBasis;
210
+
211
+ // Consent metadata
212
+ method: "explicit" | "implicit" | "contractual";
213
+ evidence?: string; // How consent was obtained
214
+
215
+ // Revocation
216
+ revoked?: boolean;
217
+ revoked_at?: string;
218
+ revocation_reason?: string;
219
+ }
220
+
221
+ type ConsentPurpose =
222
+ | "service_provision" // Core service functionality
223
+ | "session_management" // Browser session handling
224
+ | "security_logging" // Security audit logging
225
+ | "error_diagnostics" // Error logging for debugging
226
+ | "usage_analytics"; // Optional usage tracking
227
+
228
+ type LegalBasis =
229
+ | "consent" // User explicitly consented
230
+ | "contract" // Necessary for contract performance
231
+ | "legal_obligation" // Required by law
232
+ | "vital_interests" // Protect vital interests
233
+ | "public_interest" // Public interest task
234
+ | "legitimate_interest"; // Legitimate business interest
235
+ ```
236
+
237
+ **Default Legal Bases**:
238
+
239
+ | Processing Activity | Legal Basis | Requires Explicit Consent |
240
+ |--------------------|-------------|---------------------------|
241
+ | Browser session for NotebookLM access | Contract | No |
242
+ | Security audit logging | Legitimate Interest | No |
243
+ | Credential encryption | Legal Obligation | No |
244
+ | Error logging | Legitimate Interest | No |
245
+ | Compliance logging | Legal Obligation | No |
246
+
247
+ **Storage**:
248
+ - Location: `<config_dir>/consent.json.pqenc`
249
+ - Encrypted: Yes (post-quantum)
250
+ - Backed up: Yes (with compliance events)
251
+
252
+ **API**:
253
+
254
+ ```typescript
255
+ class ConsentManager {
256
+ // Record new consent
257
+ async grantConsent(purposes: ConsentPurpose[], legalBasis: LegalBasis): Promise<ConsentRecord>;
258
+
259
+ // Revoke consent
260
+ async revokeConsent(consentId: string, reason?: string): Promise<void>;
261
+
262
+ // Check if consent exists for purpose
263
+ hasConsent(purpose: ConsentPurpose): boolean;
264
+
265
+ // Get all active consents
266
+ getActiveConsents(): ConsentRecord[];
267
+
268
+ // Get consent history (for DSAR)
269
+ getConsentHistory(): ConsentRecord[];
270
+
271
+ // Check if first run (needs consent prompt)
272
+ isFirstRun(): boolean;
273
+
274
+ // Export consent records (for DSAR)
275
+ exportConsents(): string; // JSON
276
+ }
277
+ ```
278
+
279
+ ---
280
+
281
+ ### 1.4 Privacy Notice Display
282
+
283
+ **File**: `src/compliance/privacy-notice.ts`
284
+
285
+ **Purpose**: Display privacy notice on first run and track acceptance.
286
+
287
+ **Notice Content** (stored in `src/compliance/privacy-notice-text.ts`):
288
+
289
+ ```typescript
290
+ interface PrivacyNotice {
291
+ version: string;
292
+ effective_date: string;
293
+
294
+ sections: {
295
+ data_controller: string;
296
+ data_collected: string[];
297
+ purposes: string[];
298
+ legal_basis: string[];
299
+ retention: string;
300
+ rights: string[];
301
+ contact: string;
302
+ };
303
+
304
+ // Short summary for CLI display
305
+ summary: string;
306
+ }
307
+ ```
308
+
309
+ **Display Behavior**:
310
+
311
+ 1. **First Run**: Display full privacy notice, require acknowledgment
312
+ 2. **Notice Updated**: Display changes, require re-acknowledgment
313
+ 3. **On Demand**: Available via `get_privacy_notice` MCP tool
314
+
315
+ **CLI Display Example**:
316
+
317
+ ```
318
+ ╔══════════════════════════════════════════════════════════════════╗
319
+ ║ PRIVACY NOTICE v1.0.0 ║
320
+ ╠══════════════════════════════════════════════════════════════════╣
321
+ ║ ║
322
+ ║ This tool processes the following data locally on your device: ║
323
+ ║ ║
324
+ ║ • Browser session data (cookies, local storage) ║
325
+ ║ • NotebookLM URLs and metadata ║
326
+ ║ • Query history (for session context) ║
327
+ ║ • Security audit logs ║
328
+ ║ ║
329
+ ║ All data is: ║
330
+ ║ ✓ Stored locally only (no cloud sync) ║
331
+ ║ ✓ Encrypted with post-quantum cryptography ║
332
+ ║ ✓ Subject to automatic retention policies ║
333
+ ║ ║
334
+ ║ Your rights: Access, Export, Erasure, Portability ║
335
+ ║ ║
336
+ ║ Full policy: https://github.com/Pantheon-Security/... ║
337
+ ║ ║
338
+ ╠══════════════════════════════════════════════════════════════════╣
339
+ ║ By continuing, you acknowledge this privacy notice. ║
340
+ ║ ║
341
+ ║ [Press Enter to continue, or Ctrl+C to exit] ║
342
+ ╚══════════════════════════════════════════════════════════════════╝
343
+ ```
344
+
345
+ ---
346
+
347
+ ### 1.5 Enhanced Audit Events
348
+
349
+ **File**: Update `src/utils/audit-logger.ts`
350
+
351
+ **New Event Types**:
352
+
353
+ ```typescript
354
+ // Add to existing AuditEventType
355
+ type AuditEventType =
356
+ | "tool" // Existing
357
+ | "auth" // Existing
358
+ | "session" // Existing
359
+ | "security" // Existing
360
+ | "system" // Existing
361
+ | "compliance" // NEW: Compliance events
362
+ | "data_access" // NEW: Data access events
363
+ | "configuration" // NEW: Config changes
364
+ | "retention"; // NEW: Data retention events
365
+
366
+ // New compliance-specific logging methods
367
+ interface AuditLogger {
368
+ // Existing methods...
369
+
370
+ // NEW: Compliance event logging
371
+ logComplianceEvent(
372
+ event: string,
373
+ category: ComplianceEventCategory,
374
+ details: Record<string, unknown>
375
+ ): Promise<void>;
376
+
377
+ // NEW: Data access logging (for DSAR)
378
+ logDataAccess(
379
+ action: "view" | "export" | "delete",
380
+ dataType: string,
381
+ details: Record<string, unknown>
382
+ ): Promise<void>;
383
+
384
+ // NEW: Configuration change logging
385
+ logConfigChange(
386
+ setting: string,
387
+ oldValue: unknown,
388
+ newValue: unknown,
389
+ changedBy: string
390
+ ): Promise<void>;
391
+
392
+ // NEW: Retention event logging
393
+ logRetentionEvent(
394
+ action: "cleanup" | "archive" | "delete",
395
+ dataType: string,
396
+ count: number,
397
+ details: Record<string, unknown>
398
+ ): Promise<void>;
399
+ }
400
+ ```
401
+
402
+ ---
403
+
404
+ ## Phase 2: Data Subject Rights (GDPR)
405
+
406
+ ### 2.1 Data Export Tool
407
+
408
+ **File**: `src/compliance/data-export.ts`
409
+
410
+ **Purpose**: Export all user data in machine-readable format (GDPR Article 20).
411
+
412
+ **Export Format**:
413
+
414
+ ```typescript
415
+ interface DataExport {
416
+ export_metadata: {
417
+ version: string;
418
+ exported_at: string;
419
+ format: "json";
420
+ encryption: "none" | "password";
421
+ checksum: string;
422
+ };
423
+
424
+ data: {
425
+ // User identity
426
+ consent_records: ConsentRecord[];
427
+
428
+ // Notebooks
429
+ notebook_library: NotebookEntry[];
430
+
431
+ // Settings
432
+ user_settings: Settings;
433
+
434
+ // Session history (if retained)
435
+ session_history?: SessionSummary[];
436
+
437
+ // Audit logs (user's own activity)
438
+ activity_log: AuditEvent[];
439
+
440
+ // Compliance events
441
+ compliance_events: ComplianceEvent[];
442
+ };
443
+
444
+ data_inventory: {
445
+ category: string;
446
+ count: number;
447
+ date_range: { from: string; to: string };
448
+ }[];
449
+ }
450
+ ```
451
+
452
+ **Export Options**:
453
+
454
+ ```typescript
455
+ interface ExportOptions {
456
+ // What to include
457
+ include_notebooks: boolean; // Default: true
458
+ include_settings: boolean; // Default: true
459
+ include_sessions: boolean; // Default: true
460
+ include_audit_logs: boolean; // Default: true
461
+ include_compliance_events: boolean; // Default: true
462
+
463
+ // Date range
464
+ from_date?: string;
465
+ to_date?: string;
466
+
467
+ // Security
468
+ encrypt_export: boolean; // Default: false
469
+ export_password?: string;
470
+
471
+ // Format
472
+ format: "json" | "json_pretty";
473
+
474
+ // Delivery
475
+ output_path?: string; // Default: stdout
476
+ }
477
+ ```
478
+
479
+ **MCP Tool**:
480
+
481
+ ```typescript
482
+ // New MCP tool: export_user_data
483
+ {
484
+ name: "export_user_data",
485
+ description: "Export all user data (GDPR Article 20 - Right to Data Portability)",
486
+ inputSchema: {
487
+ type: "object",
488
+ properties: {
489
+ include_audit_logs: { type: "boolean", default: true },
490
+ from_date: { type: "string", format: "date" },
491
+ to_date: { type: "string", format: "date" },
492
+ format: { type: "string", enum: ["json", "json_pretty"], default: "json_pretty" }
493
+ }
494
+ }
495
+ }
496
+ ```
497
+
498
+ ---
499
+
500
+ ### 2.2 Right to Erasure
501
+
502
+ **File**: `src/compliance/data-erasure.ts`
503
+
504
+ **Purpose**: Complete deletion of user data (GDPR Article 17).
505
+
506
+ **Erasure Scope**:
507
+
508
+ ```typescript
509
+ interface ErasureRequest {
510
+ request_id: string;
511
+ requested_at: string;
512
+
513
+ // What to delete
514
+ scope: ErasureScope;
515
+
516
+ // Verification
517
+ confirmed: boolean;
518
+ confirmation_method: "explicit" | "timeout";
519
+
520
+ // Execution
521
+ executed_at?: string;
522
+ items_deleted: ErasureResult[];
523
+
524
+ // Retention (we must keep the erasure record itself)
525
+ erasure_record_retention_days: number; // Default: 2555 (7 years)
526
+ }
527
+
528
+ interface ErasureScope {
529
+ // Data types to delete
530
+ notebooks: boolean; // Notebook library
531
+ settings: boolean; // User settings
532
+ browser_data: boolean; // Browser profiles, cookies
533
+ audit_logs: boolean; // User activity logs
534
+ compliance_events: boolean; // Keep erasure record only
535
+ encryption_keys: boolean; // PQ keys (careful!)
536
+
537
+ // Or delete everything
538
+ complete_erasure: boolean;
539
+ }
540
+
541
+ interface ErasureResult {
542
+ data_type: string;
543
+ path: string;
544
+ items_deleted: number;
545
+ size_bytes: number;
546
+ method: "overwrite" | "delete" | "crypto_shred";
547
+ verified: boolean;
548
+ }
549
+ ```
550
+
551
+ **Secure Deletion Methods**:
552
+
553
+ 1. **Overwrite**: 3-pass overwrite with random data
554
+ 2. **Delete**: Standard file deletion
555
+ 3. **Crypto Shred**: Delete encryption keys (data unrecoverable)
556
+
557
+ **Retention Exceptions** (data that cannot be deleted):
558
+
559
+ - Erasure request record itself (legal requirement)
560
+ - Security incident logs (if applicable)
561
+ - Data required for legal proceedings
562
+
563
+ **MCP Tool**:
564
+
565
+ ```typescript
566
+ // New MCP tool: request_data_erasure
567
+ {
568
+ name: "request_data_erasure",
569
+ description: "Request deletion of all user data (GDPR Article 17 - Right to Erasure)",
570
+ inputSchema: {
571
+ type: "object",
572
+ properties: {
573
+ scope: {
574
+ type: "string",
575
+ enum: ["complete", "notebooks", "sessions", "audit_logs"],
576
+ default: "complete"
577
+ },
578
+ confirm: {
579
+ type: "boolean",
580
+ description: "Explicit confirmation required"
581
+ }
582
+ },
583
+ required: ["confirm"]
584
+ }
585
+ }
586
+ ```
587
+
588
+ ---
589
+
590
+ ### 2.3 Data Access Request Handler
591
+
592
+ **File**: `src/compliance/dsar-handler.ts`
593
+
594
+ **Purpose**: Handle Data Subject Access Requests (GDPR Article 15).
595
+
596
+ **DSAR Response**:
597
+
598
+ ```typescript
599
+ interface DSARResponse {
600
+ request_id: string;
601
+ submitted_at: string;
602
+ completed_at: string;
603
+
604
+ // Identity confirmation
605
+ subject_verified: boolean;
606
+
607
+ // Data provided
608
+ personal_data: {
609
+ category: string;
610
+ data: unknown;
611
+ source: string;
612
+ retention_period: string;
613
+ }[];
614
+
615
+ // Processing information
616
+ processing_purposes: string[];
617
+ legal_bases: string[];
618
+ data_recipients: string[]; // Empty for local-only
619
+
620
+ // Rights information
621
+ available_rights: string[];
622
+
623
+ // Metadata
624
+ format: "json";
625
+ encrypted: boolean;
626
+ }
627
+ ```
628
+
629
+ **MCP Tool**:
630
+
631
+ ```typescript
632
+ // New MCP tool: submit_data_access_request
633
+ {
634
+ name: "submit_data_access_request",
635
+ description: "Submit a Data Subject Access Request (GDPR Article 15)",
636
+ inputSchema: {
637
+ type: "object",
638
+ properties: {
639
+ include_processing_info: { type: "boolean", default: true },
640
+ format: { type: "string", enum: ["json", "summary"], default: "summary" }
641
+ }
642
+ }
643
+ }
644
+ ```
645
+
646
+ ---
647
+
648
+ ### 2.4 Data Inventory
649
+
650
+ **File**: `src/compliance/data-inventory.ts`
651
+
652
+ **Purpose**: Maintain inventory of all personal data stored.
653
+
654
+ **Inventory Structure**:
655
+
656
+ ```typescript
657
+ interface DataInventoryEntry {
658
+ id: string;
659
+
660
+ // What
661
+ data_type: string;
662
+ description: string;
663
+ classification: DataClassification;
664
+ data_categories: DataCategory[];
665
+
666
+ // Where
667
+ storage_location: string;
668
+ encrypted: boolean;
669
+
670
+ // How long
671
+ retention_policy: string;
672
+ retention_days: number | "indefinite";
673
+
674
+ // Legal
675
+ legal_basis: LegalBasis;
676
+ processing_purposes: string[];
677
+
678
+ // Access
679
+ who_can_access: string[];
680
+ exportable: boolean;
681
+ erasable: boolean;
682
+
683
+ // Metadata
684
+ last_updated: string;
685
+ }
686
+ ```
687
+
688
+ **Auto-Discovery**:
689
+ - Scan data directories on startup
690
+ - Register new data types automatically
691
+ - Track data lifecycle
692
+
693
+ ---
694
+
695
+ ### 2.5 Retention Policy Engine
696
+
697
+ **File**: `src/compliance/retention-engine.ts`
698
+
699
+ **Purpose**: Enforce data retention policies automatically.
700
+
701
+ **Policy Configuration**:
702
+
703
+ ```typescript
704
+ interface RetentionPolicy {
705
+ id: string;
706
+ name: string;
707
+
708
+ // What it applies to
709
+ data_types: string[];
710
+ classifications?: DataClassification[];
711
+
712
+ // How long to keep
713
+ retention_days: number;
714
+
715
+ // What to do after expiry
716
+ action: "delete" | "archive" | "anonymize";
717
+
718
+ // When to run
719
+ schedule: "daily" | "weekly" | "monthly";
720
+
721
+ // Exceptions
722
+ exceptions?: {
723
+ condition: string;
724
+ extended_retention_days: number;
725
+ }[];
726
+
727
+ // Compliance
728
+ regulatory_requirement?: string; // e.g., "CSSF Circular 20/750"
729
+ }
730
+ ```
731
+
732
+ **Default Policies**:
733
+
734
+ | Data Type | Retention | Action | Regulation |
735
+ |-----------|-----------|--------|------------|
736
+ | Audit logs | 7 years | Archive | CSSF |
737
+ | Compliance events | 7 years | Archive | CSSF |
738
+ | Session data | 24 hours | Delete | - |
739
+ | Browser cache | 7 days | Delete | - |
740
+ | Error logs | 30 days | Delete | - |
741
+ | Consent records | 7 years | Archive | GDPR |
742
+ | Erasure records | 7 years | Archive | GDPR |
743
+
744
+ ---
745
+
746
+ ## Phase 3: Security Monitoring & Incident Response
747
+
748
+ ### 3.1 SIEM Integration
749
+
750
+ **File**: `src/compliance/siem-exporter.ts`
751
+
752
+ **Purpose**: Export logs to external Security Information and Event Management systems.
753
+
754
+ **Supported Formats**:
755
+
756
+ ```typescript
757
+ type SIEMFormat =
758
+ | "json" // Raw JSON
759
+ | "cef" // Common Event Format (ArcSight)
760
+ | "leef" // Log Event Extended Format (IBM QRadar)
761
+ | "syslog" // RFC 5424 syslog
762
+ | "splunk_hec"; // Splunk HTTP Event Collector
763
+
764
+ interface SIEMConfig {
765
+ enabled: boolean;
766
+ format: SIEMFormat;
767
+
768
+ // Destination
769
+ endpoint?: string; // For HTTP-based (Splunk HEC)
770
+ syslog_host?: string; // For syslog
771
+ syslog_port?: number;
772
+
773
+ // Authentication
774
+ api_key?: string;
775
+
776
+ // Filtering
777
+ min_severity: "info" | "warning" | "error" | "critical";
778
+ event_types: string[]; // Which events to export
779
+
780
+ // Batching
781
+ batch_size: number; // Default: 100
782
+ flush_interval_ms: number; // Default: 5000
783
+
784
+ // Reliability
785
+ retry_attempts: number; // Default: 3
786
+ queue_max_size: number; // Default: 10000
787
+ }
788
+ ```
789
+
790
+ **CEF Format Example**:
791
+
792
+ ```
793
+ CEF:0|Pantheon Security|NotebookLM MCP|1.5.1|auth_failed|Authentication Failed|7|src=192.168.1.100 suser=unknown outcome=failure reason=invalid_token
794
+ ```
795
+
796
+ **Configuration**:
797
+
798
+ ```bash
799
+ NLMCP_SIEM_ENABLED=true
800
+ NLMCP_SIEM_FORMAT=cef
801
+ NLMCP_SIEM_ENDPOINT=https://siem.example.com/api/events
802
+ NLMCP_SIEM_API_KEY=xxx
803
+ NLMCP_SIEM_MIN_SEVERITY=warning
804
+ ```
805
+
806
+ ---
807
+
808
+ ### 3.2 Breach Detection
809
+
810
+ **File**: `src/compliance/breach-detection.ts`
811
+
812
+ **Purpose**: Detect potential security breaches and policy violations.
813
+
814
+ **Detection Rules**:
815
+
816
+ ```typescript
817
+ interface BreachRule {
818
+ id: string;
819
+ name: string;
820
+ description: string;
821
+ severity: "low" | "medium" | "high" | "critical";
822
+
823
+ // Detection
824
+ event_pattern: string; // Regex or event type
825
+ threshold?: number; // Count threshold
826
+ window_seconds?: number; // Time window
827
+
828
+ // Response
829
+ actions: BreachAction[];
830
+
831
+ // Regulatory
832
+ notification_required: boolean;
833
+ notification_deadline_hours?: number; // e.g., 72 for GDPR
834
+ }
835
+
836
+ type BreachAction =
837
+ | "log" // Log to compliance events
838
+ | "alert" // Send alert
839
+ | "block" // Block further access
840
+ | "notify_admin" // Email/webhook notification
841
+ | "create_incident"; // Create incident record
842
+
843
+ ```
844
+
845
+ **Default Rules**:
846
+
847
+ | Rule | Trigger | Severity | Actions |
848
+ |------|---------|----------|---------|
849
+ | Brute Force | 10 failed auth in 5 min | High | block, alert, log |
850
+ | Secrets Leaked | Secrets detected in output | Critical | alert, log, create_incident |
851
+ | Cert Pinning Violation | TLS cert mismatch | Critical | block, alert, log |
852
+ | Unusual Access Pattern | Access outside normal hours | Medium | alert, log |
853
+ | Mass Data Export | Large export request | Medium | log, notify_admin |
854
+ | Encryption Failure | Encryption operation failed | High | alert, log |
855
+
856
+ ---
857
+
858
+ ### 3.3 Incident Response Log
859
+
860
+ **File**: `src/compliance/incident-manager.ts`
861
+
862
+ **Purpose**: Track and manage security incidents.
863
+
864
+ **Incident Structure**:
865
+
866
+ ```typescript
867
+ interface SecurityIncident {
868
+ id: string;
869
+
870
+ // Classification
871
+ type: IncidentType;
872
+ severity: "low" | "medium" | "high" | "critical";
873
+ status: "open" | "investigating" | "contained" | "resolved" | "closed";
874
+
875
+ // Timeline
876
+ detected_at: string;
877
+ reported_at?: string;
878
+ contained_at?: string;
879
+ resolved_at?: string;
880
+ closed_at?: string;
881
+
882
+ // Details
883
+ title: string;
884
+ description: string;
885
+ affected_data: string[];
886
+ affected_systems: string[];
887
+
888
+ // Response
889
+ actions_taken: IncidentAction[];
890
+ root_cause?: string;
891
+ remediation?: string;
892
+
893
+ // Notification
894
+ notification_required: boolean;
895
+ notification_sent?: boolean;
896
+ notification_deadline?: string;
897
+
898
+ // Evidence
899
+ related_events: string[]; // Event IDs from audit log
900
+ }
901
+
902
+ type IncidentType =
903
+ | "unauthorized_access"
904
+ | "data_breach"
905
+ | "malware"
906
+ | "dos_attack"
907
+ | "policy_violation"
908
+ | "data_loss"
909
+ | "configuration_error"
910
+ | "other";
911
+
912
+ interface IncidentAction {
913
+ timestamp: string;
914
+ action: string;
915
+ performed_by: string;
916
+ notes?: string;
917
+ }
918
+ ```
919
+
920
+ ---
921
+
922
+ ### 3.4 Alert System
923
+
924
+ **File**: `src/compliance/alert-manager.ts`
925
+
926
+ **Purpose**: Send alerts for security and compliance events.
927
+
928
+ **Alert Channels**:
929
+
930
+ ```typescript
931
+ interface AlertConfig {
932
+ enabled: boolean;
933
+
934
+ channels: {
935
+ // Console (always available)
936
+ console: boolean;
937
+
938
+ // File-based alerts
939
+ file?: {
940
+ path: string;
941
+ format: "json" | "text";
942
+ };
943
+
944
+ // Webhook (Slack, Teams, etc.)
945
+ webhook?: {
946
+ url: string;
947
+ headers?: Record<string, string>;
948
+ template?: string;
949
+ };
950
+
951
+ // Email (via external service)
952
+ email?: {
953
+ smtp_host: string;
954
+ smtp_port: number;
955
+ from: string;
956
+ to: string[];
957
+ use_tls: boolean;
958
+ };
959
+ };
960
+
961
+ // Filtering
962
+ min_severity: "info" | "warning" | "error" | "critical";
963
+ event_types?: string[];
964
+
965
+ // Rate limiting
966
+ cooldown_seconds: number; // Don't repeat same alert within
967
+ max_alerts_per_hour: number;
968
+ }
969
+ ```
970
+
971
+ **Configuration**:
972
+
973
+ ```bash
974
+ NLMCP_ALERTS_ENABLED=true
975
+ NLMCP_ALERTS_WEBHOOK_URL=https://hooks.slack.com/xxx
976
+ NLMCP_ALERTS_MIN_SEVERITY=warning
977
+ NLMCP_ALERTS_COOLDOWN=300
978
+ ```
979
+
980
+ ---
981
+
982
+ ### 3.5 Health Monitoring
983
+
984
+ **File**: `src/compliance/health-monitor.ts`
985
+
986
+ **Purpose**: Monitor system health and availability (SOC2 requirement).
987
+
988
+ **Health Metrics**:
989
+
990
+ ```typescript
991
+ interface HealthMetrics {
992
+ timestamp: string;
993
+
994
+ // System health
995
+ status: "healthy" | "degraded" | "unhealthy";
996
+ uptime_seconds: number;
997
+
998
+ // Component status
999
+ components: {
1000
+ name: string;
1001
+ status: "up" | "down" | "degraded";
1002
+ last_check: string;
1003
+ response_time_ms?: number;
1004
+ error?: string;
1005
+ }[];
1006
+
1007
+ // Resource usage
1008
+ resources: {
1009
+ memory_used_mb: number;
1010
+ memory_limit_mb: number;
1011
+ disk_used_mb: number;
1012
+ disk_available_mb: number;
1013
+ };
1014
+
1015
+ // Security status
1016
+ security: {
1017
+ encryption_enabled: boolean;
1018
+ auth_enabled: boolean;
1019
+ cert_pinning_enabled: boolean;
1020
+ last_security_scan?: string;
1021
+ open_incidents: number;
1022
+ };
1023
+
1024
+ // Compliance status
1025
+ compliance: {
1026
+ consent_valid: boolean;
1027
+ retention_policies_active: number;
1028
+ pending_erasure_requests: number;
1029
+ last_compliance_check: string;
1030
+ };
1031
+ }
1032
+ ```
1033
+
1034
+ **MCP Tool Enhancement**:
1035
+
1036
+ ```typescript
1037
+ // Enhance existing get_health tool
1038
+ {
1039
+ name: "get_health",
1040
+ description: "Get server health including compliance status",
1041
+ // Add compliance metrics to response
1042
+ }
1043
+ ```
1044
+
1045
+ ---
1046
+
1047
+ ## Phase 4: Compliance Reporting & Documentation
1048
+
1049
+ ### 4.1 Compliance Dashboard
1050
+
1051
+ **File**: `src/compliance/dashboard.ts`
1052
+
1053
+ **Purpose**: Generate compliance status overview.
1054
+
1055
+ **Dashboard Output**:
1056
+
1057
+ ```typescript
1058
+ interface ComplianceDashboard {
1059
+ generated_at: string;
1060
+
1061
+ // Overall status
1062
+ overall_status: "compliant" | "non_compliant" | "needs_attention";
1063
+
1064
+ // By regulation
1065
+ regulations: {
1066
+ name: "GDPR" | "SOC2" | "CSSF";
1067
+ status: "compliant" | "non_compliant" | "partial";
1068
+ requirements_met: number;
1069
+ requirements_total: number;
1070
+ issues: ComplianceIssue[];
1071
+ }[];
1072
+
1073
+ // Key metrics
1074
+ metrics: {
1075
+ active_consents: number;
1076
+ pending_dsars: number;
1077
+ pending_erasures: number;
1078
+ open_incidents: number;
1079
+ audit_log_integrity: "verified" | "issues_found";
1080
+ encryption_status: "enabled" | "disabled" | "partial";
1081
+ retention_compliance: number; // Percentage
1082
+ };
1083
+
1084
+ // Recent events
1085
+ recent_compliance_events: ComplianceEvent[];
1086
+
1087
+ // Upcoming deadlines
1088
+ deadlines: {
1089
+ type: string;
1090
+ deadline: string;
1091
+ days_remaining: number;
1092
+ }[];
1093
+ }
1094
+
1095
+ interface ComplianceIssue {
1096
+ severity: "critical" | "high" | "medium" | "low";
1097
+ regulation: string;
1098
+ requirement: string;
1099
+ description: string;
1100
+ remediation: string;
1101
+ }
1102
+ ```
1103
+
1104
+ **MCP Tool**:
1105
+
1106
+ ```typescript
1107
+ // New MCP tool: get_compliance_status
1108
+ {
1109
+ name: "get_compliance_status",
1110
+ description: "Get compliance dashboard showing status across GDPR, SOC2, CSSF",
1111
+ inputSchema: {
1112
+ type: "object",
1113
+ properties: {
1114
+ regulations: {
1115
+ type: "array",
1116
+ items: { type: "string", enum: ["GDPR", "SOC2", "CSSF"] },
1117
+ default: ["GDPR", "SOC2", "CSSF"]
1118
+ },
1119
+ include_events: { type: "boolean", default: true }
1120
+ }
1121
+ }
1122
+ }
1123
+ ```
1124
+
1125
+ ---
1126
+
1127
+ ### 4.2 Audit Report Generator
1128
+
1129
+ **File**: `src/compliance/report-generator.ts`
1130
+
1131
+ **Purpose**: Generate compliance audit reports.
1132
+
1133
+ **Report Types**:
1134
+
1135
+ ```typescript
1136
+ type ReportType =
1137
+ | "compliance_summary" // High-level compliance status
1138
+ | "audit_trail" // Detailed audit log report
1139
+ | "access_report" // Who accessed what
1140
+ | "retention_report" // Data retention status
1141
+ | "incident_report" // Security incident summary
1142
+ | "dsar_report" // Data subject request summary
1143
+ | "consent_report"; // Consent status report
1144
+
1145
+ interface ReportConfig {
1146
+ type: ReportType;
1147
+
1148
+ // Time range
1149
+ from_date: string;
1150
+ to_date: string;
1151
+
1152
+ // Format
1153
+ format: "json" | "html" | "pdf" | "csv";
1154
+
1155
+ // Filters
1156
+ regulations?: string[];
1157
+ severity_min?: string;
1158
+
1159
+ // Output
1160
+ output_path?: string;
1161
+ include_evidence?: boolean;
1162
+ }
1163
+ ```
1164
+
1165
+ ---
1166
+
1167
+ ### 4.3 Policy Documentation
1168
+
1169
+ **File**: `src/compliance/policy-docs.ts`
1170
+
1171
+ **Purpose**: Machine-readable policy documentation.
1172
+
1173
+ **Policies**:
1174
+
1175
+ ```typescript
1176
+ interface PolicyDocument {
1177
+ id: string;
1178
+ type: PolicyType;
1179
+ version: string;
1180
+ effective_date: string;
1181
+
1182
+ // Content
1183
+ title: string;
1184
+ description: string;
1185
+ full_text: string;
1186
+
1187
+ // Applicability
1188
+ regulations: string[];
1189
+ data_types: string[];
1190
+
1191
+ // Enforcement
1192
+ enforced: boolean;
1193
+ enforcement_method: "automatic" | "manual" | "audit";
1194
+
1195
+ // Review
1196
+ last_reviewed: string;
1197
+ next_review: string;
1198
+ approved_by: string;
1199
+ }
1200
+
1201
+ type PolicyType =
1202
+ | "privacy_policy"
1203
+ | "data_retention"
1204
+ | "access_control"
1205
+ | "encryption"
1206
+ | "incident_response"
1207
+ | "acceptable_use";
1208
+ ```
1209
+
1210
+ ---
1211
+
1212
+ ### 4.4 Change Log
1213
+
1214
+ **File**: `src/compliance/change-log.ts`
1215
+
1216
+ **Purpose**: Track all configuration changes (SOC2 requirement).
1217
+
1218
+ **Change Record**:
1219
+
1220
+ ```typescript
1221
+ interface ChangeRecord {
1222
+ id: string;
1223
+ timestamp: string;
1224
+
1225
+ // What changed
1226
+ component: string;
1227
+ setting: string;
1228
+ old_value: unknown;
1229
+ new_value: unknown;
1230
+
1231
+ // Who/how
1232
+ changed_by: "user" | "system" | "admin";
1233
+ method: "cli" | "env" | "api" | "config_file";
1234
+
1235
+ // Approval (for sensitive changes)
1236
+ requires_approval: boolean;
1237
+ approved_by?: string;
1238
+ approved_at?: string;
1239
+
1240
+ // Impact
1241
+ impact: "low" | "medium" | "high";
1242
+ affected_compliance: string[];
1243
+ }
1244
+ ```
1245
+
1246
+ ---
1247
+
1248
+ ### 4.5 Evidence Collection
1249
+
1250
+ **File**: `src/compliance/evidence-collector.ts`
1251
+
1252
+ **Purpose**: Automated collection of compliance evidence for audits.
1253
+
1254
+ **Evidence Types**:
1255
+
1256
+ ```typescript
1257
+ interface EvidencePackage {
1258
+ id: string;
1259
+ generated_at: string;
1260
+
1261
+ // What it's for
1262
+ audit_type: "SOC2" | "GDPR" | "CSSF" | "internal";
1263
+ period: { from: string; to: string };
1264
+
1265
+ // Contents
1266
+ items: EvidenceItem[];
1267
+
1268
+ // Integrity
1269
+ checksum: string;
1270
+ signed_by?: string;
1271
+ }
1272
+
1273
+ interface EvidenceItem {
1274
+ id: string;
1275
+ type: EvidenceType;
1276
+ description: string;
1277
+
1278
+ // Content
1279
+ content: string | object;
1280
+ format: "json" | "text" | "screenshot" | "log";
1281
+
1282
+ // Metadata
1283
+ collected_at: string;
1284
+ source: string;
1285
+
1286
+ // Compliance mapping
1287
+ controls: string[]; // e.g., ["SOC2-CC6.1", "GDPR-Art32"]
1288
+ }
1289
+
1290
+ type EvidenceType =
1291
+ | "policy_document"
1292
+ | "configuration"
1293
+ | "audit_log_sample"
1294
+ | "access_review"
1295
+ | "encryption_status"
1296
+ | "retention_proof"
1297
+ | "consent_records"
1298
+ | "incident_response";
1299
+ ```
1300
+
1301
+ ---
1302
+
1303
+ ## Configuration Reference
1304
+
1305
+ ### All New Environment Variables
1306
+
1307
+ ```bash
1308
+ # ============================================
1309
+ # COMPLIANCE CONFIGURATION
1310
+ # ============================================
1311
+
1312
+ # Core Compliance
1313
+ NLMCP_COMPLIANCE_ENABLED=true # Enable compliance features
1314
+ NLMCP_COMPLIANCE_MODE=full # full | minimal | audit_only
1315
+ NLMCP_COMPLIANCE_REGULATIONS=GDPR,SOC2,CSSF # Which regulations to enforce
1316
+
1317
+ # Compliance Logging
1318
+ NLMCP_COMPLIANCE_DIR=/path/to/compliance # Compliance event directory
1319
+ NLMCP_COMPLIANCE_RETENTION_YEARS=7 # Retention for compliance events
1320
+ NLMCP_COMPLIANCE_ENCRYPTION=true # Encrypt compliance logs
1321
+
1322
+ # Consent Management
1323
+ NLMCP_CONSENT_REQUIRED=true # Require consent on first run
1324
+ NLMCP_CONSENT_VERSION=1.0.0 # Current consent version
1325
+ NLMCP_PRIVACY_NOTICE_URL=https://... # Link to full privacy policy
1326
+
1327
+ # Data Subject Rights
1328
+ NLMCP_DSAR_ENABLED=true # Enable DSAR handling
1329
+ NLMCP_ERASURE_ENABLED=true # Enable right to erasure
1330
+ NLMCP_EXPORT_ENABLED=true # Enable data export
1331
+ NLMCP_EXPORT_ENCRYPT=false # Encrypt exports by default
1332
+
1333
+ # Retention Policies
1334
+ NLMCP_RETENTION_AUDIT_DAYS=2555 # 7 years for audit logs
1335
+ NLMCP_RETENTION_SESSION_HOURS=24 # Session data retention
1336
+ NLMCP_RETENTION_BROWSER_DAYS=7 # Browser cache retention
1337
+ NLMCP_RETENTION_CHECK_SCHEDULE=daily # When to run retention cleanup
1338
+
1339
+ # SIEM Integration
1340
+ NLMCP_SIEM_ENABLED=false # Enable SIEM export
1341
+ NLMCP_SIEM_FORMAT=cef # cef | leef | syslog | json | splunk_hec
1342
+ NLMCP_SIEM_ENDPOINT=https://... # SIEM endpoint URL
1343
+ NLMCP_SIEM_API_KEY=xxx # SIEM API key
1344
+ NLMCP_SIEM_BATCH_SIZE=100 # Events per batch
1345
+ NLMCP_SIEM_FLUSH_INTERVAL_MS=5000 # Flush interval
1346
+
1347
+ # Breach Detection
1348
+ NLMCP_BREACH_DETECTION=true # Enable breach detection
1349
+ NLMCP_BREACH_NOTIFICATION=true # Auto-notify on breach
1350
+ NLMCP_BREACH_WEBHOOK=https://... # Breach notification webhook
1351
+
1352
+ # Incident Response
1353
+ NLMCP_INCIDENT_TRACKING=true # Enable incident tracking
1354
+ NLMCP_INCIDENT_AUTO_CREATE=true # Auto-create incidents on breach
1355
+
1356
+ # Alerts
1357
+ NLMCP_ALERTS_ENABLED=true # Enable alerts
1358
+ NLMCP_ALERTS_WEBHOOK_URL=https://... # Slack/Teams webhook
1359
+ NLMCP_ALERTS_EMAIL_TO=security@example.com # Alert email recipients
1360
+ NLMCP_ALERTS_MIN_SEVERITY=warning # Minimum alert severity
1361
+ NLMCP_ALERTS_COOLDOWN=300 # Seconds between repeated alerts
1362
+
1363
+ # Health Monitoring
1364
+ NLMCP_HEALTH_MONITORING=true # Enable health monitoring
1365
+ NLMCP_HEALTH_CHECK_INTERVAL=60 # Seconds between health checks
1366
+
1367
+ # Reporting
1368
+ NLMCP_REPORTS_DIR=/path/to/reports # Report output directory
1369
+ NLMCP_REPORTS_AUTO_GENERATE=false # Auto-generate periodic reports
1370
+ NLMCP_REPORTS_SCHEDULE=monthly # Report generation schedule
1371
+ ```
1372
+
1373
+ ---
1374
+
1375
+ ## File Structure
1376
+
1377
+ ```
1378
+ src/
1379
+ ├── compliance/
1380
+ │ ├── index.ts # Module exports
1381
+ │ ├── compliance-logger.ts # Phase 1.1
1382
+ │ ├── data-classification.ts # Phase 1.2
1383
+ │ ├── consent-manager.ts # Phase 1.3
1384
+ │ ├── privacy-notice.ts # Phase 1.4
1385
+ │ ├── privacy-notice-text.ts # Privacy notice content
1386
+ │ ├── data-export.ts # Phase 2.1
1387
+ │ ├── data-erasure.ts # Phase 2.2
1388
+ │ ├── dsar-handler.ts # Phase 2.3
1389
+ │ ├── data-inventory.ts # Phase 2.4
1390
+ │ ├── retention-engine.ts # Phase 2.5
1391
+ │ ├── siem-exporter.ts # Phase 3.1
1392
+ │ ├── breach-detection.ts # Phase 3.2
1393
+ │ ├── incident-manager.ts # Phase 3.3
1394
+ │ ├── alert-manager.ts # Phase 3.4
1395
+ │ ├── health-monitor.ts # Phase 3.5
1396
+ │ ├── dashboard.ts # Phase 4.1
1397
+ │ ├── report-generator.ts # Phase 4.2
1398
+ │ ├── policy-docs.ts # Phase 4.3
1399
+ │ ├── change-log.ts # Phase 4.4
1400
+ │ ├── evidence-collector.ts # Phase 4.5
1401
+ │ └── types.ts # Shared types
1402
+ ├── utils/
1403
+ │ └── audit-logger.ts # Enhanced (Phase 1.5)
1404
+ └── tools/
1405
+ └── compliance-tools.ts # New MCP tools
1406
+ ```
1407
+
1408
+ ---
1409
+
1410
+ ## Implementation Order
1411
+
1412
+ ### Phase 1 (Foundation) - Implement First
1413
+ 1. `types.ts` - Shared types
1414
+ 2. `compliance-logger.ts` - Core logging
1415
+ 3. `data-classification.ts` - Classification system
1416
+ 4. `consent-manager.ts` - Consent tracking
1417
+ 5. `privacy-notice.ts` + `privacy-notice-text.ts` - Privacy display
1418
+ 6. Update `audit-logger.ts` - Enhanced events
1419
+
1420
+ ### Phase 2 (GDPR Rights) - Implement Second
1421
+ 1. `data-inventory.ts` - Data catalog
1422
+ 2. `retention-engine.ts` - Retention enforcement
1423
+ 3. `data-export.ts` - Export functionality
1424
+ 4. `data-erasure.ts` - Erasure functionality
1425
+ 5. `dsar-handler.ts` - DSAR handling
1426
+
1427
+ ### Phase 3 (Monitoring) - Implement Third
1428
+ 1. `alert-manager.ts` - Alert system
1429
+ 2. `breach-detection.ts` - Breach detection
1430
+ 3. `incident-manager.ts` - Incident tracking
1431
+ 4. `siem-exporter.ts` - SIEM integration
1432
+ 5. `health-monitor.ts` - Health monitoring
1433
+
1434
+ ### Phase 4 (Reporting) - Implement Last
1435
+ 1. `change-log.ts` - Change tracking
1436
+ 2. `policy-docs.ts` - Policy documentation
1437
+ 3. `dashboard.ts` - Compliance dashboard
1438
+ 4. `report-generator.ts` - Report generation
1439
+ 5. `evidence-collector.ts` - Evidence collection
1440
+ 6. `compliance-tools.ts` - MCP tools
1441
+
1442
+ ---
1443
+
1444
+ ## Approval
1445
+
1446
+ - [ ] Phase 1 Specification Approved
1447
+ - [ ] Phase 2 Specification Approved
1448
+ - [ ] Phase 3 Specification Approved
1449
+ - [ ] Phase 4 Specification Approved
1450
+
1451
+ **Approved By**: ___________________
1452
+ **Date**: ___________________