create_cname_record
Create DNS CNAME records in Infoblox to map alias domain names to canonical targets, enabling domain redirection and alias management.
Instructions
Create a DNS CNAME record in Infoblox
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Alias FQDN for the CNAME record | |
| canonical | Yes | Canonical name (target FQDN) | |
| view | No | DNS view | |
| ttl | No | TTL in seconds | |
| comment | No | Comment for the record |
Implementation Reference
- src/tools/dns.ts:235-255 (handler)The handler function that executes the create_cname_record tool logic. It accepts parameters (name, canonical, view, ttl, comment), builds a data object, calls client.create('record:cname', data) to create the CNAME record in Infoblox, and returns a success message or error.
async ({ name, canonical, view, ttl, comment }) => { const data: Record<string, unknown> = { name, canonical }; if (view) data.view = view; if (ttl !== undefined) { data.ttl = ttl; data.use_ttl = true; } if (comment) data.comment = comment; try { const ref = await client.create("record:cname", data); return toolResult( `CNAME record created successfully.\nReference: ${ref}`, ); } catch (error) { return toolResult( `Error creating CNAME record: ${error}`, true, ); } }, - src/tools/dns.ts:224-234 (schema)Zod schema definition for the create_cname_record tool inputs. Defines and validates the parameters: name (string, FQDN alias), canonical (string, target FQDN), view (optional string), ttl (optional number), and comment (optional string).
{ name: z .string() .describe("Alias FQDN for the CNAME record"), canonical: z .string() .describe("Canonical name (target FQDN)"), view: z.string().optional().describe("DNS view"), ttl: z.number().optional().describe("TTL in seconds"), comment: z.string().optional().describe("Comment for the record"), }, - src/tools/dns.ts:221-256 (registration)Complete registration of the create_cname_record tool with the MCP server using server.tool(). Includes the tool name, description, schema, and handler function.
server.tool( "create_cname_record", "Create a DNS CNAME record in Infoblox", { name: z .string() .describe("Alias FQDN for the CNAME record"), canonical: z .string() .describe("Canonical name (target FQDN)"), view: z.string().optional().describe("DNS view"), ttl: z.number().optional().describe("TTL in seconds"), comment: z.string().optional().describe("Comment for the record"), }, async ({ name, canonical, view, ttl, comment }) => { const data: Record<string, unknown> = { name, canonical }; if (view) data.view = view; if (ttl !== undefined) { data.ttl = ttl; data.use_ttl = true; } if (comment) data.comment = comment; try { const ref = await client.create("record:cname", data); return toolResult( `CNAME record created successfully.\nReference: ${ref}`, ); } catch (error) { return toolResult( `Error creating CNAME record: ${error}`, true, ); } }, ); - src/tools/dns.ts:30-32 (helper)Helper function toolResult() used to format the response from the tool handler. Creates a standardized response object with content and error status.
function toolResult(text: string, isError = false) { return { content: [{ type: "text" as const, text }], isError }; } - src/index.ts:42-42 (registration)Calls registerDnsTools(server, client) to register all DNS tools including create_cname_record with the MCP server instance.
registerDnsTools(server, client);