get_domain_info
Retrieve domain registration details including expiration date and remaining validity period through WHOIS/RDAP lookup for security monitoring.
Instructions
Get domain registration, expiration, and daysUntilExpiry using WHOIS/RDAP.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | The top-level domain to check (e.g., sslmon.dev) |
Implementation Reference
- src/index.ts:100-139 (handler)Core handler function implementing the tool logic: queries RDAP for domain info, falls back to WHOIS parsing, and returns formatted JSON response.private async getDomainInfo(domain: string): Promise<any> { try { // First try RDAP protocol const rdapInfo = await this.queryRDAP(domain); if (rdapInfo) { return { content: [ { type: "text", text: JSON.stringify(rdapInfo, null, 2), }, ], }; } } catch (rdapError) { console.error(`RDAP query failed for ${domain}:`, rdapError); } try { // Fallback to whois protocol const whoisInfo = await this.queryWhois(domain); return { content: [ { type: "text", text: JSON.stringify(whoisInfo, null, 2), }, ], }; } catch (whoisError) { return { content: [ { type: "text", text: `Domain info lookup failed for ${domain}: ${whoisError instanceof Error ? whoisError.message : String(whoisError)}`, }, ], }; } }
- src/index.ts:57-75 (registration)Tool registration including input schema validation and thin error-handling wrapper that delegates to getDomainInfo method."get_domain_info", { title: "Get domain info", description: "Get domain registration, expiration, and daysUntilExpiry using WHOIS/RDAP.", inputSchema: { domain: z.string().describe("The top-level domain to check (e.g., sslmon.dev)"), }, }, async ({ domain }) => { try { return await this.getDomainInfo(domain); } catch (error) { return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true, }; } } );
- src/index.ts:14-22 (schema)TypeScript interface defining the structure of domain information output used by the handler.interface DomainInfo { domain: string; registrationDate?: string; expirationDate?: string; registrar?: string; registrant?: string; status?: string; daysUntilExpiry?: number; }
- src/index.ts:141-162 (helper)Helper function to query the appropriate RDAP server for domain registration information.async queryRDAP(domain: string): Promise<DomainInfo | null> { const tld = domain.split('.').pop()?.toLowerCase(); if (!tld) { throw new Error('Invalid domain format'); } // Get RDAP bootstrap data to find the right RDAP server let rdapServer = await this.getRDAPServer(tld); if (!rdapServer) { return null; } if (!rdapServer.endsWith('/')) { rdapServer = rdapServer+'/'; } const url = `${rdapServer}domain/${domain}`; console.log(`Querying RDAP server: ${url}`); const response = await this.httpRequest(url); const data = JSON.parse(response); return this.parseRDAPData(data, domain); }
- src/index.ts:235-249 (helper)Fallback helper function to query WHOIS server for domain information.async queryWhois(domain: string): Promise<DomainInfo> { const tld = domain.split('.').pop()?.toLowerCase(); if (!tld) { throw new Error('Invalid domain format'); } // Get whois server for the TLD const whoisServer = await this.getWhoisServer(tld); if (!whoisServer) { throw new Error(`No whois server found for TLD: ${tld}`); } const whoisData = await this.performWhoisQuery(domain, whoisServer); return this.parseWhoisData(whoisData, domain); }