UNPKG

@superadnim/osint-mcp-server

Version:

Professional OSINT MCP Server for intelligence gathering with privacy protection

487 lines 22.3 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OSINTMCPServer = void 0; const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js"); const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js"); const types_js_1 = require("@modelcontextprotocol/sdk/types.js"); const osint_engine_js_1 = require("./core/osint-engine.js"); const logger_js_1 = require("./utils/logger.js"); const config_manager_js_1 = require("./utils/config-manager.js"); const privacy_filter_js_1 = require("./utils/privacy-filter.js"); class OSINTMCPServer { server; osintEngine; logger; configManager; privacyFilter; constructor() { this.logger = new logger_js_1.Logger(); this.configManager = new config_manager_js_1.ConfigManager(); this.privacyFilter = new privacy_filter_js_1.PrivacyFilter(this.configManager); this.osintEngine = new osint_engine_js_1.OSINTEngine(this.configManager, this.logger); this.server = new index_js_1.Server({ name: '@superadnim/osint-mcp-server', version: '1.0.5', }, { capabilities: { tools: {}, }, }); this.setupHandlers(); } setupHandlers() { // Handle initialization this.server.setRequestHandler(types_js_1.InitializeRequestSchema, async (request) => { return { protocolVersion: '2024-11-05', capabilities: { tools: {}, }, serverInfo: { name: '@superadnim/osint-mcp-server', version: '1.0.5', }, }; }); this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => { const tools = [ { name: 'osint_people_search', description: 'Search for people using name, email, or phone across multiple sources', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Name, email, or phone number to search for', }, search_type: { type: 'string', enum: ['name', 'email', 'phone', 'auto'], description: 'Type of search to perform', default: 'auto', }, include_relatives: { type: 'boolean', description: 'Include family member information', default: false, }, include_addresses: { type: 'boolean', description: 'Include address history', default: true, }, include_phones: { type: 'boolean', description: 'Include phone numbers', default: true, }, include_emails: { type: 'boolean', description: 'Include email addresses', default: true, }, confidence_threshold: { type: 'number', description: 'Minimum confidence score (0-1)', default: 0.3, minimum: 0, maximum: 1, }, max_results: { type: 'number', description: 'Maximum results to return', default: 10, minimum: 1, maximum: 50, }, }, required: ['query'], }, }, { name: 'osint_phone_lookup', description: 'Lookup phone number information including carrier, location, and associated accounts', inputSchema: { type: 'object', properties: { phone: { type: 'string', description: 'Phone number with country code', }, include_carrier: { type: 'boolean', description: 'Include carrier information', default: true, }, include_location: { type: 'boolean', description: 'Include geographic data', default: true, }, include_spam_check: { type: 'boolean', description: 'Check spam databases', default: true, }, include_social_accounts: { type: 'boolean', description: 'Check social media registrations', default: false, }, format_international: { type: 'boolean', description: 'Format as international number', default: true, }, }, required: ['phone'], }, }, { name: 'osint_email_intel', description: 'Analyze email addresses for breaches, account enumeration, and intelligence', inputSchema: { type: 'object', properties: { email: { type: 'string', description: 'Target email address', }, check_breaches: { type: 'boolean', description: 'Query breach databases', default: true, }, enumerate_accounts: { type: 'boolean', description: 'Check account existence', default: false, }, analyze_domain: { type: 'boolean', description: 'Analyze email domain', default: true, }, check_deliverability: { type: 'boolean', description: 'Test email deliverability', default: false, }, include_metadata: { type: 'boolean', description: 'Include email metadata analysis', default: false, }, deep_scan: { type: 'boolean', description: 'Perform comprehensive analysis', default: false, }, }, required: ['email'], }, }, { name: 'osint_username_enum', description: 'Enumerate username across social media and online platforms', inputSchema: { type: 'object', properties: { username: { type: 'string', description: 'Target username', }, platforms: { type: 'array', items: { type: 'string' }, description: 'Specific platforms to check', default: [], }, include_variations: { type: 'boolean', description: 'Check username variations', default: false, }, include_profiles: { type: 'boolean', description: 'Fetch profile information', default: false, }, max_concurrent: { type: 'number', description: 'Concurrent request limit', default: 10, minimum: 1, maximum: 50, }, timeout_per_request: { type: 'number', description: 'Request timeout in seconds', default: 30, minimum: 5, maximum: 300, }, include_inactive: { type: 'boolean', description: 'Include inactive/suspended accounts', default: false, }, }, required: ['username'], }, }, { name: 'osint_domain_recon', description: 'Perform domain reconnaissance including DNS, WHOIS, and subdomain enumeration', inputSchema: { type: 'object', properties: { domain: { type: 'string', description: 'Target domain', }, include_subdomains: { type: 'boolean', description: 'Enumerate subdomains', default: false, }, include_dns_records: { type: 'boolean', description: 'Fetch all DNS records', default: true, }, include_whois: { type: 'boolean', description: 'Include WHOIS data', default: true, }, include_ssl_info: { type: 'boolean', description: 'Analyze SSL certificates', default: false, }, include_web_tech: { type: 'boolean', description: 'Identify web technologies', default: false, }, include_historical: { type: 'boolean', description: 'Historical domain data', default: false, }, subdomain_depth: { type: 'number', description: 'Subdomain enumeration depth', default: 2, minimum: 1, maximum: 5, }, }, required: ['domain'], }, }, { name: 'osint_google_dorking', description: 'Perform advanced Google dorking and search engine reconnaissance', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Base search query', }, dork_type: { type: 'string', enum: ['filetype', 'site', 'inurl', 'intitle', 'cache', 'related', 'custom'], description: 'Type of dork to perform', default: 'custom', }, operators: { type: 'array', items: { type: 'string' }, description: 'Additional search operators', default: [], }, search_engines: { type: 'array', items: { type: 'string' }, description: 'Search engines to use', default: ['google'], }, max_results: { type: 'number', description: 'Maximum results per engine', default: 10, minimum: 1, maximum: 100, }, file_types: { type: 'array', items: { type: 'string' }, description: 'File types for filetype dorks', default: [], }, time_range: { type: 'string', description: 'Time range filter', default: 'any', }, }, required: ['query'], }, }, { name: 'osint_create_mind_map', description: 'Create and manage investigation mind maps for organizing OSINT data', inputSchema: { type: 'object', properties: { investigation_id: { type: 'string', description: 'Unique investigation identifier', }, action: { type: 'string', enum: ['create', 'add_node', 'add_connection', 'view', 'export', 'search'], description: 'Action to perform', default: 'create', }, node_data: { type: 'object', properties: { type: { type: 'string' }, content: { type: 'string' }, metadata: { type: 'object' }, confidence: { type: 'number', minimum: 0, maximum: 1 }, source: { type: 'string' }, }, description: 'Node data for add_node action', }, connection_data: { type: 'object', properties: { from_node: { type: 'string' }, to_node: { type: 'string' }, relationship: { type: 'string' }, strength: { type: 'number', minimum: 0, maximum: 1 }, evidence: { type: 'array', items: { type: 'string' } }, }, description: 'Connection data for add_connection action', }, export_format: { type: 'string', enum: ['json', 'graphml', 'csv', 'markdown'], description: 'Export format', default: 'json', }, }, required: ['investigation_id'], }, }, ]; return { tools }; }); this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { this.logger.info(`Executing tool: ${name}`, { args }); let result; switch (name) { case 'osint_people_search': result = await this.osintEngine.searchPeople(args || {}); break; case 'osint_phone_lookup': result = await this.osintEngine.lookupPhone(args || {}); break; case 'osint_email_intel': result = await this.osintEngine.analyzeEmail(args || {}); break; case 'osint_username_enum': result = await this.osintEngine.enumerateUsername(args || {}); break; case 'osint_domain_recon': result = await this.osintEngine.reconDomain(args || {}); break; case 'osint_google_dorking': result = await this.osintEngine.performGoogleDorking(args || {}); break; case 'osint_create_mind_map': result = await this.osintEngine.manageMindMap(args || {}); break; default: throw new Error(`Unknown tool: ${name}`); } const filteredResult = this.privacyFilter.filter(result); this.logger.info(`Tool executed successfully: ${name}`); return { content: [ { type: 'text', text: JSON.stringify(filteredResult, null, 2), }, ], }; } catch (error) { this.logger.error(`Tool execution failed: ${name}`, { error }); return { content: [ { type: 'text', text: JSON.stringify({ error: 'Tool execution failed', message: error instanceof Error ? error.message : String(error), tool: name, }, null, 2), }, ], isError: true, }; } }); } async start() { try { const transport = new stdio_js_1.StdioServerTransport(); // Add error handlers process.on('uncaughtException', (error) => { this.logger.error('Uncaught exception:', { error: error.message, stack: error.stack }); }); process.on('unhandledRejection', (reason, promise) => { this.logger.error('Unhandled rejection:', { reason, promise }); }); // Keep the process alive process.stdin.resume(); await this.server.connect(transport); this.logger.info('OSINT MCP Server started successfully'); // Keep server running process.on('SIGINT', () => { this.logger.info('SIGINT received, shutting down gracefully'); process.exit(0); }); process.on('SIGTERM', () => { this.logger.info('SIGTERM received, shutting down gracefully'); process.exit(0); }); } catch (error) { this.logger.error('Failed to start MCP server:', { error }); throw error; } } } exports.OSINTMCPServer = OSINTMCPServer; async function main() { const server = new OSINTMCPServer(); await server.start(); } if (require.main === module) { main().catch((error) => { console.error('Failed to start OSINT MCP Server:', error); process.exit(1); }); } //# sourceMappingURL=index.js.map