reverse_dns
Resolve IP addresses to hostnames using reverse DNS lookup. Identify domain names associated with specific IPs for network diagnostics or verification. Ensure accurate results with configurable query timeouts.
Instructions
Perform reverse DNS lookup to find the hostname for an IP address
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ipAddress | Yes | The IP address to perform reverse lookup on | |
| timeout | No | Query timeout in milliseconds |
Input Schema (JSON Schema)
{
"properties": {
"ipAddress": {
"description": "The IP address to perform reverse lookup on",
"type": "string"
},
"timeout": {
"description": "Query timeout in milliseconds",
"type": "number"
}
},
"required": [
"ipAddress"
],
"type": "object"
}
Implementation Reference
- src/index.ts:184-201 (handler)MCP tool handler for reverse_dns: parses input schema, performs reverse lookup via DnsResolver, formats and returns result as JSON text contentcase 'reverse_dns': { const input = ReverseDnsSchema.parse(args) as ReverseDnsInput; logger.info(`Reverse DNS lookup for ${input.ipAddress}`); const hostnames = await dnsResolver.reverseLookup(input.ipAddress); logger.debug('Reverse DNS result', hostnames); return { content: [ { type: 'text', text: JSON.stringify({ ipAddress: input.ipAddress, hostnames, timestamp: new Date().toISOString() }, null, 2) } ] }; }
- src/dns-resolver.ts:149-159 (helper)Core implementation of reverse DNS lookup using Node.js dns.resolver.reverse() method with error handlingasync reverseLookup(ipAddress: string): Promise<string[]> { try { return await this.resolver.reverse(ipAddress); } catch (error: any) { throw { code: error.code || 'REVERSE_LOOKUP_FAILED', message: error.message || 'Reverse lookup failed', domain: ipAddress } as DnsError; } }
- src/tools/schemas.ts:14-17 (schema)Zod schema for validating ReverseDnsInput (ipAddress required as IP string, optional timeout)export const ReverseDnsSchema = z.object({ ipAddress: z.string().ip().describe('The IP address to perform reverse lookup on'), timeout: z.number().min(100).max(30000).optional().describe('Query timeout in milliseconds') });
- src/index.ts:75-92 (registration)Registers the reverse_dns tool in the TOOLS array for MCP server, providing name, description, and JSON input schema{ name: 'reverse_dns', description: 'Perform reverse DNS lookup to find the hostname for an IP address', inputSchema: { type: 'object', properties: { ipAddress: { type: 'string', description: 'The IP address to perform reverse lookup on' }, timeout: { type: 'number', description: 'Query timeout in milliseconds' } }, required: ['ipAddress'] } },