check_domain
Verify domain availability and explore alternatives. Check exact domains or search across popular TLDs with clear, actionable results. Ideal for finding and securing the right web address.
Instructions
Check domain availability.
Usage examples:
- "mysite.com --domain" - checks exact domain
- "mysite --domain" - checks mysite across all popular TLDs
- "test.io --domain" - checks test.io exactly, plus test across all TLDs
Args:
domain_query (str): Domain to check with --domain flag
Returns:
Dict containing availability results for the domain and suggested alternatives
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain_query | Yes |
Implementation Reference
- The main MCP tool handler for 'check_domain', decorated with @mcp.tool(). It parses the domain_query, validates input, and delegates to run_domain_checks for availability checking.@mcp.tool() async def check_domain(domain_query: str) -> Dict: if '--domain' not in domain_query: return { "error": "Please use --domain flag. Example: 'mysite.com --domain' or 'mysite --domain'" } domain_part = domain_query.replace('--domain', '').strip() if not domain_part: return { "error": "Please provide a domain name. Example: 'mysite.com --domain'" } base_name, existing_tld = extract_domain_parts(domain_part) if not base_name: return { "error": "Invalid domain format. Example: 'mysite.com --domain'" } try: return await run_domain_checks(domain_part) except Exception as e: return { "error": f"Failed to check domain: {str(e)}" }
- Core helper function that performs comprehensive domain availability checks for the input base name across multiple TLDs, categorizing results into available, unavailable, and invalid.async def run_domain_checks(domain_part: str) -> Dict: base_name, existing_tld = extract_domain_parts(domain_part) results = { "requested_domain": None, "available_domains": [], "unavailable_domains": [], "invalid_domains": [], "total_checked": 0, "check_summary": {} } invalid_for_tlds = [] for tld in ALL_TLDS: if not is_valid_domain_name(base_name, tld): min_length = get_min_length_for_tld(tld) invalid_for_tlds.append({ 'tld': tld, 'reason': f'Minimum length: {min_length} chars' }) if invalid_for_tlds: results["invalid_domains"] = { 'base_name': base_name, 'length': len(base_name), 'invalid_for': invalid_for_tlds[:10] } if existing_tld: exact_result = await check_domain_availability(f"{base_name}.{existing_tld}") results["requested_domain"] = exact_result other_tlds = [tld for tld in ALL_TLDS if tld != existing_tld] all_results = await check_multiple_domains(base_name, other_tlds) if exact_result.get('valid', True): all_results.append(exact_result) else: all_results = await check_multiple_domains(base_name, ALL_TLDS) for result in all_results: if result.get('available'): results["available_domains"].append(result) else: results["unavailable_domains"].append(result) results["total_checked"] = len(all_results) results["available_domains"].sort(key=lambda x: x['domain']) results["unavailable_domains"].sort(key=lambda x: x['domain']) popular_available = [r for r in results["available_domains"] if any(r['domain'].endswith(f'.{tld}') for tld in POPULAR_TLDS)] results["check_summary"] = { "total_available": len(results["available_domains"]), "total_unavailable": len(results["unavailable_domains"]), "total_invalid": len(invalid_for_tlds), "popular_available": len(popular_available), "country_available": len([r for r in results["available_domains"] if any(r['domain'].endswith(f'.{tld}') for tld in COUNTRY_TLDS)]), "new_tlds_available": len([r for r in results["available_domains"] if any(r['domain'].endswith(f'.{tld}') for tld in NEW_TLDS)]) } return results
- Helper function to check availability of a single domain using DNS, WHOIS (fallback to socket), and socket checks, returning detailed availability status.async def check_domain_availability(domain: str) -> Dict: start_time = time.time() base_name, tld = extract_domain_parts(domain) if not is_valid_domain_name(base_name, tld): return { 'domain': domain, 'available': False, 'error': f'Invalid domain: "{base_name}" does not meet requirements for .{tld} (min length: {get_min_length_for_tld(tld)})', 'valid': False, 'check_time': "0s" } dns_available = await check_domain_dns(domain) whois_available = await check_domain_whois(domain) is_available = dns_available and whois_available end_time = time.time() check_time = round(end_time - start_time, 2) return { 'domain': domain, 'available': is_available, 'dns_available': dns_available, 'whois_available': whois_available, 'valid': True, 'check_time': f"{check_time}s" }