UNPKG

@ironclads/namecheap-mcp

Version:

MCP server for Namecheap API integration - domain management, DNS, and domain suggestions

183 lines 7.61 kB
// Domain name generation utilities export class DomainGenerator { // Common prefixes for domain names static PREFIXES = [ 'get', 'my', 'the', 'best', 'top', 'super', 'ultra', 'mega', 'pro', 'smart', 'fast', 'quick', 'easy', 'simple', 'instant', 'auto', 'digital', 'online', 'web', 'net', 'cloud', 'tech', 'cyber', 'virtual', 'rapid', 'secure', 'premium', 'elite', 'advanced', 'modern', 'innovative', 'creative', 'global' ]; // Common suffixes for domain names static SUFFIXES = [ 'hub', 'zone', 'spot', 'place', 'space', 'world', 'land', 'city', 'town', 'center', 'core', 'base', 'lab', 'studio', 'works', 'solutions', 'systems', 'services', 'group', 'team', 'network', 'platform', 'engine', 'toolkit', 'suite', 'portal', 'gateway', 'nexus', 'connect', 'link', 'bridge', 'path' ]; // Alternative words for keyword replacement static ALTERNATIVES = { 'tech': ['technology', 'digital', 'cyber', 'web', 'net', 'smart', 'ai'], 'shop': ['store', 'market', 'mall', 'bazaar', 'outlet', 'retail', 'commerce'], 'blog': ['journal', 'diary', 'news', 'post', 'write', 'story', 'article'], 'app': ['application', 'software', 'tool', 'program', 'system', 'platform'], 'game': ['gaming', 'play', 'fun', 'entertainment', 'arcade', 'sport'], 'food': ['kitchen', 'recipe', 'cook', 'dining', 'meal', 'taste', 'flavor'], 'travel': ['journey', 'trip', 'adventure', 'explore', 'vacation', 'tour'], 'health': ['wellness', 'fitness', 'medical', 'care', 'healthy', 'vital'], 'music': ['sound', 'audio', 'melody', 'tune', 'beat', 'rhythm', 'song'], 'photo': ['picture', 'image', 'camera', 'visual', 'gallery', 'snap'], }; // Numbers to append/prepend static NUMBERS = ['1', '2', '3', '24', '365', '2024', '2025']; // Generate domain suggestions based on keyword static generateSuggestions(keyword, options = {}) { const { includeHyphens = false, includeNumbers = false, minLength = 3, maxLength = 15, } = options; const suggestions = []; const keywordLower = keyword.toLowerCase().replace(/[^a-z0-9]/g, ''); // 1. Exact keyword if (keywordLower.length >= minLength && keywordLower.length <= maxLength) { suggestions.push(keywordLower); } // 2. Prefix combinations for (const prefix of this.PREFIXES) { const combined = prefix + keywordLower; if (combined.length >= minLength && combined.length <= maxLength) { suggestions.push(combined); } // With hyphen if (includeHyphens) { const hyphenated = prefix + '-' + keywordLower; if (hyphenated.length >= minLength && hyphenated.length <= maxLength) { suggestions.push(hyphenated); } } } // 3. Suffix combinations for (const suffix of this.SUFFIXES) { const combined = keywordLower + suffix; if (combined.length >= minLength && combined.length <= maxLength) { suggestions.push(combined); } // With hyphen if (includeHyphens) { const hyphenated = keywordLower + '-' + suffix; if (hyphenated.length >= minLength && hyphenated.length <= maxLength) { suggestions.push(hyphenated); } } } // 4. Alternative words const alternatives = this.ALTERNATIVES[keywordLower] || []; for (const alt of alternatives) { if (alt.length >= minLength && alt.length <= maxLength) { suggestions.push(alt); } } // 5. Number combinations if (includeNumbers) { for (const num of this.NUMBERS) { // Prefix with number const prefixed = num + keywordLower; if (prefixed.length >= minLength && prefixed.length <= maxLength) { suggestions.push(prefixed); } // Suffix with number const suffixed = keywordLower + num; if (suffixed.length >= minLength && suffixed.length <= maxLength) { suggestions.push(suffixed); } } } // 6. Creative combinations (first 3 letters + last 3 letters of alternatives) for (const alt of alternatives.slice(0, 3)) { if (alt.length >= 6) { const creative = alt.substring(0, 3) + alt.substring(alt.length - 3); if (creative.length >= minLength && creative.length <= maxLength) { suggestions.push(creative); } } } // Remove duplicates and return return [...new Set(suggestions)]; } // Score domain suggestions based on various factors static scoreDomain(domain, keyword) { let score = 50; // Base score // Exact match gets highest bonus if (domain.toLowerCase() === keyword.toLowerCase()) { score += 50; } // Keyword inclusion else if (domain.includes(keyword.toLowerCase())) { score += 30; } // Length scoring (shorter is generally better, but not too short) if (domain.length >= 5 && domain.length <= 10) { score += 20; } else if (domain.length >= 11 && domain.length <= 15) { score += 10; } else if (domain.length < 5) { score += 5; } else { score -= 10; } // Avoid numbers and hyphens (they're less brandable) if (!/\d/.test(domain)) { score += 10; } else { score -= 5; } if (!domain.includes('-')) { score += 10; } else { score -= 5; } // Pronounceability (simple heuristic) const vowels = (domain.match(/[aeiou]/g) || []).length; const vowelRatio = vowels / domain.length; if (vowelRatio >= 0.3 && vowelRatio <= 0.5) { score += 10; } // Penalize consecutive consonants if (/[bcdfghjklmnpqrstvwxyz]{3,}/.test(domain)) { score -= 10; } // Bonus for common prefixes/suffixes const hasGoodPrefix = this.PREFIXES.some(p => domain.startsWith(p)); const hasGoodSuffix = this.SUFFIXES.some(s => domain.endsWith(s)); if (hasGoodPrefix) score += 5; if (hasGoodSuffix) score += 5; return Math.max(0, Math.min(100, score)); } // Determine suggestion type based on how it was generated static getSuggestionType(domain, keyword) { const keywordLower = keyword.toLowerCase(); const domainLower = domain.toLowerCase(); if (domainLower === keywordLower) { return 'exact'; } if (domainLower.startsWith(keywordLower)) { return 'suffix'; } if (domainLower.endsWith(keywordLower)) { return 'prefix'; } if (domainLower.includes(keywordLower)) { return 'related'; } // Check if it's an alternative word const alternatives = this.ALTERNATIVES[keywordLower] || []; if (alternatives.includes(domainLower)) { return 'alternate'; } return 'related'; } } //# sourceMappingURL=domain-generator.js.map