dns_lookup
Retrieve DNS records for domains to verify configurations, troubleshoot connectivity, or analyze domain settings. Supports A, MX, TXT, and other record types.
Instructions
Lookup DNS records for a domain ($0.001)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | ||
| types | No |
Implementation Reference
- index.js:42-42 (registration)Registration of the 'dns_lookup' tool in the TOOLS array, including its metadata, input schema, and associated API endpoint.
{ name: 'dns_lookup', description: 'Lookup DNS records for a domain', inputSchema: { type: 'object', properties: { domain: { type: 'string' }, types: { type: 'array', items: { type: 'string' }, default: ['A', 'MX', 'TXT'] } }, required: ['domain'] }, endpoint: '/dns/lookup', price: '$0.001' }, - index.js:94-115 (handler)General handler that processes tool calls (including 'dns_lookup') by retrieving the tool definition and calling the `callTool` function.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; if (!API_KEY) { return { content: [{ type: 'text', text: 'Error: ITERATOOLS_API_KEY environment variable not set. Get a key at https://iteratools.com' }], isError: true, }; } const tool = TOOLS.find(t => t.name === name); if (!tool) { return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true }; } try { const result = await callTool(tool.endpoint, args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (err) { return { content: [{ type: 'text', text: `Error: ${err.message}` }], isError: true }; } }); - index.js:50-79 (helper)Helper function that performs the network request to the IteraTools API based on the endpoint and parameters provided by the tool handler.
async function callTool(endpoint, params) { const fetch = (await import('node-fetch')).default; const isGet = ['GET'].includes((TOOLS.find(t => t.endpoint === endpoint) || {}).method); const url = isGet ? `${BASE_URL}${endpoint}?${new URLSearchParams(params)}` : `${BASE_URL}${endpoint}`; const res = await fetch(url, { method: isGet ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: isGet ? undefined : JSON.stringify(params), }); const text = await res.text(); let data; try { data = JSON.parse(text); } catch { data = { raw: text }; } if (!res.ok) { if (res.status === 402) { throw new Error(`Insufficient credits. Add credits at https://iteratools.com. Cost: ${TOOLS.find(t=>t.endpoint===endpoint)?.price || 'see docs'}`); } throw new Error(`API error ${res.status}: ${text.substring(0, 200)}`); } return data; }