@ansvar/us-regulations-mcp 1.0.0 โ 1.2.2
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 +422 -79
- package/data/regulations.db +0 -0
- package/data/seed/colorado-cpa.json +97 -0
- package/data/seed/ffiec.json +103 -0
- package/data/seed/mappings/ccpa-nist-csf.json +11 -1
- package/data/seed/mappings/hipaa-nist-800-53.json +10 -1
- package/data/seed/nydfs.json +122 -0
- package/data/seed/sox.json +109 -0
- package/dist/index.js +1 -1
- package/dist/ingest/adapters/colorado-public.d.ts +25 -0
- package/dist/ingest/adapters/colorado-public.d.ts.map +1 -0
- package/dist/ingest/adapters/colorado-public.js +76 -0
- package/dist/ingest/adapters/colorado-public.js.map +1 -0
- package/dist/ingest/adapters/connecticut-cga.d.ts +22 -0
- package/dist/ingest/adapters/connecticut-cga.d.ts.map +1 -0
- package/dist/ingest/adapters/connecticut-cga.js +116 -0
- package/dist/ingest/adapters/connecticut-cga.js.map +1 -0
- package/dist/ingest/adapters/ecfr.d.ts +46 -4
- package/dist/ingest/adapters/ecfr.d.ts.map +1 -1
- package/dist/ingest/adapters/ecfr.js +131 -16
- package/dist/ingest/adapters/ecfr.js.map +1 -1
- package/dist/ingest/adapters/ffiec.d.ts +42 -0
- package/dist/ingest/adapters/ffiec.d.ts.map +1 -0
- package/dist/ingest/adapters/ffiec.js +68 -0
- package/dist/ingest/adapters/ffiec.js.map +1 -0
- package/dist/ingest/adapters/nydfs.d.ts +42 -0
- package/dist/ingest/adapters/nydfs.d.ts.map +1 -0
- package/dist/ingest/adapters/nydfs.js +68 -0
- package/dist/ingest/adapters/nydfs.js.map +1 -0
- package/dist/ingest/adapters/regulations-gov.d.ts +11 -12
- package/dist/ingest/adapters/regulations-gov.d.ts.map +1 -1
- package/dist/ingest/adapters/regulations-gov.js +46 -43
- package/dist/ingest/adapters/regulations-gov.js.map +1 -1
- package/dist/ingest/adapters/utah-xcode.d.ts +19 -0
- package/dist/ingest/adapters/utah-xcode.d.ts.map +1 -0
- package/dist/ingest/adapters/utah-xcode.js +112 -0
- package/dist/ingest/adapters/utah-xcode.js.map +1 -0
- package/dist/ingest/adapters/virginia-law.d.ts +21 -0
- package/dist/ingest/adapters/virginia-law.d.ts.map +1 -0
- package/dist/ingest/adapters/virginia-law.js +111 -0
- package/dist/ingest/adapters/virginia-law.js.map +1 -0
- package/package.json +27 -5
- package/scripts/build-db.ts +50 -32
- package/scripts/check-updates.ts +184 -0
- package/scripts/ingest.ts +72 -25
- package/src/index.ts +1 -1
- package/src/ingest/adapters/colorado-public.ts +96 -0
- package/src/ingest/adapters/connecticut-cga.ts +150 -0
- package/src/ingest/adapters/ecfr.ts +158 -17
- package/src/ingest/adapters/ffiec.ts +77 -0
- package/src/ingest/adapters/nydfs.ts +77 -0
- package/src/ingest/adapters/regulations-gov.ts +48 -47
- package/src/ingest/adapters/utah-xcode.ts +143 -0
- package/src/ingest/adapters/virginia-law.ts +140 -0
- package/scripts/quality-test.ts +0 -346
- package/scripts/test-mcp-tools.ts +0 -187
- package/scripts/test-remaining-tools.ts +0 -107
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env npx tsx
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Test MCP Tools
|
|
5
|
-
* Verifies all MCP tools work correctly with populated database
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import Database from 'better-sqlite3';
|
|
9
|
-
import { join, dirname } from 'path';
|
|
10
|
-
import { fileURLToPath } from 'url';
|
|
11
|
-
import { searchRegulations } from '../src/tools/search.js';
|
|
12
|
-
import { getSection } from '../src/tools/section.js';
|
|
13
|
-
import { listRegulations } from '../src/tools/list.js';
|
|
14
|
-
import { mapControls } from '../src/tools/map.js';
|
|
15
|
-
import { checkApplicability } from '../src/tools/applicability.js';
|
|
16
|
-
import { getDefinitions } from '../src/tools/definitions.js';
|
|
17
|
-
import { compareRequirements } from '../src/tools/compare.js';
|
|
18
|
-
|
|
19
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
-
const __dirname = dirname(__filename);
|
|
21
|
-
const DB_PATH = join(__dirname, '..', 'data', 'regulations.db');
|
|
22
|
-
|
|
23
|
-
const db = new Database(DB_PATH, { readonly: true });
|
|
24
|
-
|
|
25
|
-
async function runTests() {
|
|
26
|
-
console.log('๐งช Testing US Compliance MCP Tools\n');
|
|
27
|
-
let passed = 0;
|
|
28
|
-
let failed = 0;
|
|
29
|
-
|
|
30
|
-
// Test 1: Search Regulations
|
|
31
|
-
console.log('1๏ธโฃ Testing search_regulations...');
|
|
32
|
-
try {
|
|
33
|
-
const result = await searchRegulations(db, { query: 'encryption', limit: 5 });
|
|
34
|
-
if (Array.isArray(result) && result.length > 0) {
|
|
35
|
-
console.log(` โ
Found ${result.length} results for "encryption"`);
|
|
36
|
-
console.log(` Sample: ${result[0].section} - ${result[0].title?.substring(0, 50)}...`);
|
|
37
|
-
passed++;
|
|
38
|
-
} else {
|
|
39
|
-
console.log(` โ No results returned (got: ${JSON.stringify(result).substring(0, 100)})`);
|
|
40
|
-
failed++;
|
|
41
|
-
}
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.log(` โ Error: ${error}`);
|
|
44
|
-
failed++;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Test 2: Get Section
|
|
48
|
-
console.log('\n2๏ธโฃ Testing get_section...');
|
|
49
|
-
try {
|
|
50
|
-
const result = await getSection(db, { regulation: 'HIPAA', section: '164.308' });
|
|
51
|
-
if (result && result.section_number && result.text) {
|
|
52
|
-
console.log(` โ
Retrieved section ${result.section_number}`);
|
|
53
|
-
console.log(` Title: ${result.title}`);
|
|
54
|
-
console.log(` Text length: ${result.text.length} chars`);
|
|
55
|
-
passed++;
|
|
56
|
-
} else {
|
|
57
|
-
console.log(` โ Section not found or incomplete (got: ${JSON.stringify(result)?.substring(0, 100)})`);
|
|
58
|
-
failed++;
|
|
59
|
-
}
|
|
60
|
-
} catch (error) {
|
|
61
|
-
console.log(` โ Error: ${error}`);
|
|
62
|
-
failed++;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Test 3: List Regulations
|
|
66
|
-
console.log('\n3๏ธโฃ Testing list_regulations...');
|
|
67
|
-
try {
|
|
68
|
-
const result = await listRegulations(db, {});
|
|
69
|
-
if (result.regulations && result.regulations.length > 0) {
|
|
70
|
-
console.log(` โ
Found ${result.regulations.length} regulations`);
|
|
71
|
-
console.log(` Regulations: ${result.regulations.map((r: any) => r.id).join(', ')}`);
|
|
72
|
-
passed++;
|
|
73
|
-
} else {
|
|
74
|
-
console.log(' โ No regulations returned');
|
|
75
|
-
failed++;
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.log(` โ Error: ${error}`);
|
|
79
|
-
failed++;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Test 4: Map Controls
|
|
83
|
-
console.log('\n4๏ธโฃ Testing map_controls...');
|
|
84
|
-
try {
|
|
85
|
-
const result = await mapControls(db, { framework: 'NIST_800_53_R5', regulation: 'HIPAA' });
|
|
86
|
-
if (result.mappings && result.mappings.length > 0) {
|
|
87
|
-
console.log(` โ
Found ${result.mappings.length} control mappings`);
|
|
88
|
-
console.log(` Sample: ${result.mappings[0].control_id} - ${result.mappings[0].control_name}`);
|
|
89
|
-
console.log(` Coverage: ${result.mappings[0].coverage}, Confidence: ${result.mappings[0].confidence}%`);
|
|
90
|
-
passed++;
|
|
91
|
-
} else {
|
|
92
|
-
console.log(' โ No mappings returned');
|
|
93
|
-
failed++;
|
|
94
|
-
}
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.log(` โ Error: ${error}`);
|
|
97
|
-
failed++;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Test 5: Check Applicability
|
|
101
|
-
console.log('\n5๏ธโฃ Testing check_applicability...');
|
|
102
|
-
try {
|
|
103
|
-
const result = await checkApplicability(db, { sector: 'healthcare' });
|
|
104
|
-
if (result.applicable_regulations && result.applicable_regulations.length > 0) {
|
|
105
|
-
console.log(` โ
Found ${result.applicable_regulations.length} applicable regulations for healthcare`);
|
|
106
|
-
console.log(` Sample: ${result.applicable_regulations[0].regulation} - ${result.applicable_regulations[0].confidence}`);
|
|
107
|
-
passed++;
|
|
108
|
-
} else {
|
|
109
|
-
console.log(` โ No applicability rules returned (got: ${JSON.stringify(result).substring(0, 100)})`);
|
|
110
|
-
failed++;
|
|
111
|
-
}
|
|
112
|
-
} catch (error) {
|
|
113
|
-
console.log(` โ Error: ${error}`);
|
|
114
|
-
failed++;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Test 6: Get Definitions
|
|
118
|
-
console.log('\n6๏ธโฃ Testing get_definitions...');
|
|
119
|
-
try {
|
|
120
|
-
const result = await getDefinitions(db, { term: 'health' });
|
|
121
|
-
// Definitions might be empty if not yet extracted
|
|
122
|
-
console.log(` โน๏ธ Found ${result.definitions?.length || 0} definitions (expected 0 for MVP)`);
|
|
123
|
-
passed++;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.log(` โ Error: ${error}`);
|
|
126
|
-
failed++;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Test 7: Compare Requirements
|
|
130
|
-
console.log('\n7๏ธโฃ Testing compare_requirements...');
|
|
131
|
-
try {
|
|
132
|
-
const result = await compareRequirements(db, {
|
|
133
|
-
topic: 'data protection',
|
|
134
|
-
regulations: ['HIPAA', 'CCPA']
|
|
135
|
-
});
|
|
136
|
-
if (result.comparisons && result.comparisons.length > 0) {
|
|
137
|
-
console.log(` โ
Compared ${result.comparisons.length} regulations`);
|
|
138
|
-
for (const comp of result.comparisons) {
|
|
139
|
-
console.log(` - ${comp.regulation}: ${comp.matches?.length || 0} matches`);
|
|
140
|
-
}
|
|
141
|
-
passed++;
|
|
142
|
-
} else {
|
|
143
|
-
console.log(` โ No comparison results (got: ${JSON.stringify(result).substring(0, 100)})`);
|
|
144
|
-
failed++;
|
|
145
|
-
}
|
|
146
|
-
} catch (error) {
|
|
147
|
-
console.log(` โ Error: ${error}`);
|
|
148
|
-
failed++;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Test 8: List HIPAA Structure
|
|
152
|
-
console.log('\n8๏ธโฃ Testing list_regulations with HIPAA structure...');
|
|
153
|
-
try {
|
|
154
|
-
const result = await listRegulations(db, { regulation: 'HIPAA' });
|
|
155
|
-
if (result.structure && result.structure.chapters && result.structure.chapters.length > 0) {
|
|
156
|
-
const totalSections = result.structure.chapters.reduce((sum, ch) => sum + ch.sections.length, 0);
|
|
157
|
-
console.log(` โ
Found ${totalSections} HIPAA sections in ${result.structure.chapters.length} chapters`);
|
|
158
|
-
console.log(` Sample sections: ${result.structure.chapters[0].sections.slice(0, 3).join(', ')}`);
|
|
159
|
-
passed++;
|
|
160
|
-
} else {
|
|
161
|
-
console.log(` โ No structure returned (got: ${JSON.stringify(result).substring(0, 150)})`);
|
|
162
|
-
failed++;
|
|
163
|
-
}
|
|
164
|
-
} catch (error) {
|
|
165
|
-
console.log(` โ Error: ${error}`);
|
|
166
|
-
failed++;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Summary
|
|
170
|
-
console.log('\n' + '='.repeat(50));
|
|
171
|
-
console.log(`๐ Test Results: ${passed} passed, ${failed} failed`);
|
|
172
|
-
console.log('='.repeat(50));
|
|
173
|
-
|
|
174
|
-
if (failed === 0) {
|
|
175
|
-
console.log('๐ All tests passed! MCP server is 100% ready.\n');
|
|
176
|
-
} else {
|
|
177
|
-
console.log('โ ๏ธ Some tests failed. Review errors above.\n');
|
|
178
|
-
process.exit(1);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
db.close();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
runTests().catch(error => {
|
|
185
|
-
console.error('Fatal error:', error);
|
|
186
|
-
process.exit(1);
|
|
187
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env npx tsx
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Test remaining MCP tools
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import Database from 'better-sqlite3';
|
|
8
|
-
import { join, dirname } from 'path';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
import { getEvidenceRequirements } from '../src/tools/evidence.js';
|
|
11
|
-
import { getComplianceActionItems } from '../src/tools/action-items.js';
|
|
12
|
-
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
-
const __dirname = dirname(__filename);
|
|
15
|
-
const DB_PATH = join(__dirname, '..', 'data', 'regulations.db');
|
|
16
|
-
|
|
17
|
-
const db = new Database(DB_PATH, { readonly: true });
|
|
18
|
-
|
|
19
|
-
async function testRemainingTools() {
|
|
20
|
-
console.log('๐งช Testing Remaining MCP Tools\n');
|
|
21
|
-
let passed = 0;
|
|
22
|
-
let failed = 0;
|
|
23
|
-
|
|
24
|
-
// Test 1: Get Evidence Requirements
|
|
25
|
-
console.log('1๏ธโฃ Testing get_evidence_requirements...');
|
|
26
|
-
try {
|
|
27
|
-
const result = await getEvidenceRequirements(db, {
|
|
28
|
-
regulation: 'HIPAA',
|
|
29
|
-
section: '164.308'
|
|
30
|
-
});
|
|
31
|
-
if (result && result.section) {
|
|
32
|
-
console.log(` โ
Retrieved evidence requirements for ${result.section}`);
|
|
33
|
-
console.log(` ๐ Requirements count: ${result.requirements?.length || 0}`);
|
|
34
|
-
if (result.requirements && result.requirements.length > 0) {
|
|
35
|
-
console.log(` ๐ Sample: ${result.requirements[0].category}`);
|
|
36
|
-
}
|
|
37
|
-
passed++;
|
|
38
|
-
} else {
|
|
39
|
-
console.log(` โ No evidence requirements returned`);
|
|
40
|
-
failed++;
|
|
41
|
-
}
|
|
42
|
-
} catch (error: any) {
|
|
43
|
-
console.log(` โ Error: ${error.message}`);
|
|
44
|
-
failed++;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Test 2: Get Compliance Action Items
|
|
48
|
-
console.log('\n2๏ธโฃ Testing get_compliance_action_items...');
|
|
49
|
-
try {
|
|
50
|
-
const result = await getComplianceActionItems(db, {
|
|
51
|
-
regulation: 'HIPAA',
|
|
52
|
-
sections: ['164.312', '164.308']
|
|
53
|
-
});
|
|
54
|
-
if (result && result.action_items) {
|
|
55
|
-
console.log(` โ
Retrieved ${result.action_items.length} action items`);
|
|
56
|
-
if (result.action_items.length > 0) {
|
|
57
|
-
console.log(` ๐ Sample: ${result.action_items[0].title}`);
|
|
58
|
-
console.log(` ๐ฏ Priority: ${result.action_items[0].priority}`);
|
|
59
|
-
}
|
|
60
|
-
passed++;
|
|
61
|
-
} else {
|
|
62
|
-
console.log(` โ No action items returned`);
|
|
63
|
-
failed++;
|
|
64
|
-
}
|
|
65
|
-
} catch (error: any) {
|
|
66
|
-
console.log(` โ Error: ${error.message}`);
|
|
67
|
-
failed++;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Test 3: Test with non-existent section
|
|
71
|
-
console.log('\n3๏ธโฃ Testing with non-existent section...');
|
|
72
|
-
try {
|
|
73
|
-
const result = await getEvidenceRequirements(db, {
|
|
74
|
-
regulation: 'HIPAA',
|
|
75
|
-
section: '999.999'
|
|
76
|
-
});
|
|
77
|
-
console.log(` โ
Handled non-existent section gracefully`);
|
|
78
|
-
passed++;
|
|
79
|
-
} catch (error: any) {
|
|
80
|
-
if (error.message.includes('not found')) {
|
|
81
|
-
console.log(` โ
Correctly returned error for non-existent section`);
|
|
82
|
-
passed++;
|
|
83
|
-
} else {
|
|
84
|
-
console.log(` โ Unexpected error: ${error.message}`);
|
|
85
|
-
failed++;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Summary
|
|
90
|
-
console.log('\n' + '='.repeat(50));
|
|
91
|
-
console.log(`๐ Test Results: ${passed} passed, ${failed} failed`);
|
|
92
|
-
console.log('='.repeat(50));
|
|
93
|
-
|
|
94
|
-
if (failed === 0) {
|
|
95
|
-
console.log('๐ All remaining tools tested successfully!\n');
|
|
96
|
-
} else {
|
|
97
|
-
console.log('โ ๏ธ Some tests failed. Review errors above.\n');
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
db.close();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
testRemainingTools().catch(error => {
|
|
105
|
-
console.error('Fatal error:', error);
|
|
106
|
-
process.exit(1);
|
|
107
|
-
});
|