opnsense_dns_cache_search
Search the Unbound DNS cache for a domain to diagnose cached SERVFAIL, stale records, or verify cache state.
Instructions
Search the Unbound DNS cache for entries matching a domain. Useful for diagnosing cached SERVFAIL, stale records, or verifying cache state.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain to search for in cache (e.g. 'example.com') |
Implementation Reference
- src/tools/dns.ts:405-426 (handler)Handler case for 'opnsense_dns_cache_search' in the handleDnsTool switch. Parses args via DnsCacheSearchSchema, calls GET /unbound/diagnostics/dumpcache, filters lines for the domain, and returns matching cache entries.
case "opnsense_dns_cache_search": { const { domain } = DnsCacheSearchSchema.parse(args); const cache = await client.get("/unbound/diagnostics/dumpcache"); const cacheStr = typeof cache === "string" ? cache : JSON.stringify(cache); // Filter cache lines matching the domain const lines = cacheStr.split("\n").filter((line: string) => line.toLowerCase().includes(domain.toLowerCase()), ); if (lines.length === 0) { return { content: [{ type: "text", text: `No cache entries found matching '${domain}'` }], }; } return { content: [ { type: "text", text: `Cache entries matching '${domain}' (${lines.length} found):\n${lines.join("\n")}`, }, ], }; } - src/tools/dns.ts:70-72 (schema)Zod schema DnsCacheSearchSchema defining the input: a required 'domain' string.
const DnsCacheSearchSchema = z.object({ domain: z.string().min(1, "Domain filter is required"), }); - src/index.ts:39-40 (registration)Tool definition included in allToolDefinitions (spread from dnsToolDefinitions).
const allToolDefinitions = [ ...dnsToolDefinitions, - src/index.ts:59-59 (registration)Handler registration: maps each DNS tool definition name to handleDnsTool.
for (const def of dnsToolDefinitions) toolHandlers.set(def.name, handleDnsTool); - src/tools/dns.ts:211-220 (registration)Tool definition entry for 'opnsense_dns_cache_search' in dnsToolDefinitions array, with description and inputSchema.
{ name: "opnsense_dns_cache_search", description: "Search the Unbound DNS cache for entries matching a domain. Useful for diagnosing cached SERVFAIL, stale records, or verifying cache state.", inputSchema: { type: "object" as const, properties: { domain: { type: "string", description: "Domain to search for in cache (e.g. 'example.com')" }, }, required: ["domain"],