#!/usr/bin/env node
import { OWASPSource } from "./sources/owasp.js";
import { NISTSource } from "./sources/nist.js";
import { AWSSource } from "./sources/aws.js";
import { GoogleSource } from "./sources/google.js";
import { SANSSource } from "./sources/sans.js";
import { CISSource } from "./sources/cis.js";
import { MITRESource } from "./sources/mitre.js";
import { AzureSource } from "./sources/azure.js";
import { ComplianceSource } from "./sources/compliance.js";
import { SimpleVectorStore } from "./vector/simple-store.js";
import { SecurityDocument } from "./types.js";
async function main() {
console.log("Security Documentation Fetcher");
console.log("==============================\n");
const sources = [
new OWASPSource(),
new NISTSource(),
new AWSSource(),
new AzureSource(),
new GoogleSource(),
new SANSSource(),
new CISSource(),
new MITRESource(),
new ComplianceSource(),
];
const allDocuments: SecurityDocument[] = [];
// Fetch documents from all sources
for (const source of sources) {
console.log(`\nFetching documents from ${source.name}...`);
try {
const docs = await source.fetchDocuments();
allDocuments.push(...docs);
console.log(`✓ Fetched ${docs.length} documents from ${source.name}`);
} catch (error) {
console.error(`✗ Error fetching from ${source.name}:`, error);
}
}
console.log(`\n\nTotal documents fetched: ${allDocuments.length}`);
// Initialize vector store and add documents
console.log("\nIndexing documents...");
const vectorStore = new SimpleVectorStore();
await vectorStore.initialize();
await vectorStore.addDocuments(allDocuments);
console.log("✓ Documents indexed successfully!");
console.log("\nBreakdown by source:");
const bySources = allDocuments.reduce(
(acc, doc) => {
acc[doc.source] = (acc[doc.source] || 0) + 1;
return acc;
},
{} as Record<string, number>
);
for (const [source, count] of Object.entries(bySources)) {
console.log(` ${source}: ${count} documents`);
}
console.log("\n✓ Done! You can now start the MCP server.");
console.log("Run: npm start");
}
main().catch((error) => {
console.error("Fatal error:", error);
process.exit(1);
});