check_domain
Check domain availability for registration using DNS and WHOIS lookups to verify if a specific domain name is free to register.
Instructions
Check if a single domain name is available for registration. Uses both DNS and WHOIS lookups for reliability.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | The full domain to check (e.g., 'example.com') |
Implementation Reference
- src/domain-checker.ts:199-276 (handler)Main implementation of checkDomain function that checks domain availability using both DNS and WHOIS lookups in parallel, returns confidence levels and detailed results.export async function checkDomain(domain: string): Promise<DomainCheckResult> { const { name, tld } = parseDomain(domain); const fullDomain = `${name}.${tld}`; // Run both checks in parallel const [dnsResult, whoisResult] = await Promise.all([ checkDns(fullDomain), checkWhois(fullDomain), ]); // Determine availability based on combined results let available: boolean; let confidence: "high" | "medium" | "low"; let method: "dns" | "whois" | "both"; let details: string | undefined; if (dnsResult.error && whoisResult.error) { // Both methods failed return { domain: fullDomain, tld, available: false, method: "both", confidence: "low", details: "Both DNS and WHOIS checks failed", error: `DNS: ${dnsResult.error}, WHOIS: ${whoisResult.error}`, }; } if (!dnsResult.error && !whoisResult.error) { // Both methods succeeded method = "both"; if (!dnsResult.exists && whoisResult.available) { available = true; confidence = "high"; details = "No DNS records and WHOIS shows available"; } else if (dnsResult.exists && !whoisResult.available) { available = false; confidence = "high"; details = "DNS records exist and WHOIS shows registered"; } else if (dnsResult.exists) { available = false; confidence = "high"; details = "DNS records exist (domain is active)"; } else if (!whoisResult.available) { available = false; confidence = "medium"; details = "No DNS but WHOIS shows registered (domain may be parked)"; } else { available = true; confidence = "medium"; details = whoisResult.details; } } else if (dnsResult.error) { // Only WHOIS worked method = "whois"; available = whoisResult.available; confidence = "medium"; details = whoisResult.details; } else { // Only DNS worked method = "dns"; available = !dnsResult.exists; confidence = dnsResult.exists ? "high" : "medium"; details = dnsResult.exists ? "DNS records exist" : "No DNS records found (may still be registered but inactive)"; } return { domain: fullDomain, tld, available, method, confidence, details, }; }
- src/index.ts:23-37 (registration)Tool registration for 'check_domain' with name, description, and inputSchema defining the domain parameter.{ name: "check_domain", description: "Check if a single domain name is available for registration. Uses both DNS and WHOIS lookups for reliability.", inputSchema: { type: "object" as const, properties: { domain: { type: "string", description: "The full domain to check (e.g., 'example.com')", }, }, required: ["domain"], }, },
- src/index.ts:146-160 (handler)MCP tool handler that extracts the domain parameter, validates it, calls checkDomain, and returns formatted JSON response.case "check_domain": { const domain = args?.domain as string; if (!domain) { throw new Error("Domain is required"); } const result = await checkDomain(domain); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- src/domain-checker.ts:17-25 (schema)Type definition for DomainCheckResult interface defining the structure of domain check responses including availability status, method, confidence, and details.export interface DomainCheckResult { domain: string; tld: string; available: boolean; method: "dns" | "whois" | "both"; confidence: "high" | "medium" | "low"; details?: string; error?: string; }
- src/types/whois.d.ts:1-28 (helper)TypeScript type definitions for the 'whois' npm module used by the check_domain implementation for WHOIS lookups.declare module "whois" { interface WhoisOptions { server?: string; follow?: number; timeout?: number; verbose?: boolean; bind?: string; proxy?: { ipaddress: string; port: number; type?: number; }; } type WhoisCallback = (err: Error | null, data: string) => void; function lookup( domain: string, callback: WhoisCallback ): void; function lookup( domain: string, options: WhoisOptions, callback: WhoisCallback ): void; export { lookup, WhoisOptions, WhoisCallback }; }