create_host_record
Create DNS host records in Infoblox by combining A and PTR records, with options for auto-assigning IP addresses and configuring DHCP settings.
Instructions
Create a DNS Host record in Infoblox. Host records combine A and PTR records. Use 'func:nextavailableip:<network_ref>' as ipv4addr to auto-assign the next available IP.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | FQDN for the host record | |
| ipv4addrs | No | IPv4 addresses for the host | |
| ipv6addrs | No | IPv6 addresses for the host | |
| view | No | DNS view | |
| ttl | No | TTL in seconds | |
| comment | No | Comment for the record | |
| configure_for_dns | No | Configure for DNS |
Implementation Reference
- src/tools/dns.ts:301-333 (handler)The handler function for 'create_host_record' tool that builds a data object from input parameters and calls client.create('record:host', data) to create the DNS host record in Infoblox. Returns success message with reference or error message.
async ({ name, ipv4addrs, ipv6addrs, view, ttl, comment, configure_for_dns, }) => { const data: Record<string, unknown> = { name }; if (ipv4addrs) data.ipv4addrs = ipv4addrs; if (ipv6addrs) data.ipv6addrs = ipv6addrs; if (view) data.view = view; if (ttl !== undefined) { data.ttl = ttl; data.use_ttl = true; } if (comment) data.comment = comment; if (configure_for_dns !== undefined) data.configure_for_dns = configure_for_dns; try { const ref = await client.create("record:host", data); return toolResult( `Host record created successfully.\nReference: ${ref}`, ); } catch (error) { return toolResult( `Error creating host record: ${error}`, true, ); } }, - src/tools/dns.ts:262-300 (schema)Zod schema definition for 'create_host_record' tool inputs including name (FQDN), ipv4addrs array (with ipv4addr, optional mac, configure_for_dhcp), ipv6addrs array, view, ttl, comment, and configure_for_dns parameters.
{ name: z.string().describe("FQDN for the host record"), ipv4addrs: z .array( z.object({ ipv4addr: z .string() .describe( "IPv4 address, or 'func:nextavailableip:<network_ref>' for auto-assign", ), mac: z .string() .optional() .describe("MAC address for DHCP"), configure_for_dhcp: z .boolean() .optional() .describe("Enable DHCP for this address"), }), ) .optional() .describe("IPv4 addresses for the host"), ipv6addrs: z .array( z.object({ ipv6addr: z.string().describe("IPv6 address"), }), ) .optional() .describe("IPv6 addresses for the host"), view: z.string().optional().describe("DNS view"), ttl: z.number().optional().describe("TTL in seconds"), comment: z.string().optional().describe("Comment for the record"), configure_for_dns: z .boolean() .optional() .default(true) .describe("Configure for DNS"), }, - src/tools/dns.ts:259-334 (registration)Complete registration of 'create_host_record' tool using server.tool() with name, description, Zod schema, and async handler function.
server.tool( "create_host_record", "Create a DNS Host record in Infoblox. Host records combine A and PTR records. Use 'func:nextavailableip:<network_ref>' as ipv4addr to auto-assign the next available IP.", { name: z.string().describe("FQDN for the host record"), ipv4addrs: z .array( z.object({ ipv4addr: z .string() .describe( "IPv4 address, or 'func:nextavailableip:<network_ref>' for auto-assign", ), mac: z .string() .optional() .describe("MAC address for DHCP"), configure_for_dhcp: z .boolean() .optional() .describe("Enable DHCP for this address"), }), ) .optional() .describe("IPv4 addresses for the host"), ipv6addrs: z .array( z.object({ ipv6addr: z.string().describe("IPv6 address"), }), ) .optional() .describe("IPv6 addresses for the host"), view: z.string().optional().describe("DNS view"), ttl: z.number().optional().describe("TTL in seconds"), comment: z.string().optional().describe("Comment for the record"), configure_for_dns: z .boolean() .optional() .default(true) .describe("Configure for DNS"), }, async ({ name, ipv4addrs, ipv6addrs, view, ttl, comment, configure_for_dns, }) => { const data: Record<string, unknown> = { name }; if (ipv4addrs) data.ipv4addrs = ipv4addrs; if (ipv6addrs) data.ipv6addrs = ipv6addrs; if (view) data.view = view; if (ttl !== undefined) { data.ttl = ttl; data.use_ttl = true; } if (comment) data.comment = comment; if (configure_for_dns !== undefined) data.configure_for_dns = configure_for_dns; try { const ref = await client.create("record:host", data); return toolResult( `Host record created successfully.\nReference: ${ref}`, ); } catch (error) { return toolResult( `Error creating host record: ${error}`, true, ); } }, ); - src/tools/dns.ts:30-32 (helper)Helper function toolResult() that formats the tool response with content array and optional error flag.
function toolResult(text: string, isError = false) { return { content: [{ type: "text" as const, text }], isError }; }