st_dns_history
Retrieve historical DNS records for domains to analyze past configurations, identify changes, and investigate security events using SecurityTrails data.
Instructions
Get historical DNS records for a domain via SecurityTrails. Shows first/last seen dates, values, and organizations. Requires ST_API_KEY.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain to get DNS history for | |
| type | Yes | DNS record type |
Implementation Reference
- src/securitytrails/index.ts:61-76 (handler)The handler function stDnsHistory in src/securitytrails/index.ts performs the actual API call to SecurityTrails and processes the response.
export async function stDnsHistory(domain: string, type: string, apiKey: string): Promise<StDnsHistoryResult> { const validTypes = ["a", "aaaa", "mx", "ns", "soa", "txt"]; const t = type.toLowerCase(); if (!validTypes.includes(t)) throw new Error(`Invalid DNS type: ${type}. Valid: ${validTypes.join(", ")}`); const data = await stFetch(`/history/${encodeURIComponent(domain)}/dns/${t}`, apiKey); const records: StDnsHistoryRecord[] = (data.records ?? []).map((r: any) => ({ values: (r.values ?? []).map((v: any) => v.ip ?? v.host ?? v.value ?? String(v)), type: r.type ?? t, firstSeen: r.first_seen ?? "", lastSeen: r.last_seen ?? "", organizations: r.organizations, })); return { domain, type: t, records, total: records.length }; } - src/protocol/tools.ts:247-258 (registration)The st_dns_history tool definition and registration logic, including input validation schema and API key handling.
const stDnsHistoryTool: ToolDef = { name: "st_dns_history", description: "Get historical DNS records for a domain via SecurityTrails. Shows first/last seen dates, values, and organizations. Requires ST_API_KEY.", schema: { domain: z.string().describe("Domain to get DNS history for"), type: z.enum(["a", "aaaa", "mx", "ns", "soa", "txt"]).describe("DNS record type"), }, execute: async (args, ctx) => { const key = requireApiKey(ctx.config.stApiKey, "SecurityTrails", "ST_API_KEY"); return json(await stDnsHistory(args.domain as string, args.type as string, key)); }, }; - src/securitytrails/index.ts:15-28 (schema)The interfaces defining the input and output structure for the DNS history records.
interface StDnsHistoryRecord { values: string[]; type: string; firstSeen: string; lastSeen: string; organizations?: string[]; } interface StDnsHistoryResult { domain: string; type: string; records: StDnsHistoryRecord[]; total: number; }