create_mx_record
Create a DNS MX record in Infoblox to direct email traffic to the correct mail server by specifying domain, mail exchanger, and priority.
Instructions
Create a DNS MX (mail exchange) record in Infoblox
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | FQDN for the MX record (usually the domain) | |
| mail_exchanger | Yes | FQDN of the mail server | |
| preference | Yes | MX preference/priority value | |
| view | No | DNS view | |
| ttl | No | TTL in seconds | |
| comment | No | Comment for the record |
Implementation Reference
- src/tools/dns.ts:404-435 (handler)Handler function for create_mx_record tool. Takes parameters (name, mail_exchanger, preference, view, ttl, comment), builds a data object, calls client.create('record:mx', data) to create the MX record in Infoblox, and returns success/error message.
async ({ name, mail_exchanger, preference, view, ttl, comment, }) => { const data: Record<string, unknown> = { name, mail_exchanger, preference, }; 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:mx", data); return toolResult( `MX record created successfully.\nReference: ${ref}`, ); } catch (error) { return toolResult( `Error creating MX record: ${error}`, true, ); } }, - src/tools/dns.ts:392-403 (schema)Zod schema definition for create_mx_record tool input validation. Defines parameters: name (FQDN), mail_exchanger (mail server FQDN), preference (MX priority), and optional view, ttl, comment fields.
{ name: z .string() .describe("FQDN for the MX record (usually the domain)"), mail_exchanger: z .string() .describe("FQDN of the mail server"), preference: z.number().describe("MX preference/priority value"), 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:389-436 (registration)Registration of create_mx_record tool using server.tool(). Includes tool name, description, schema, and handler function. Part of registerDnsTools function that registers all DNS-related tools.
server.tool( "create_mx_record", "Create a DNS MX (mail exchange) record in Infoblox", { name: z .string() .describe("FQDN for the MX record (usually the domain)"), mail_exchanger: z .string() .describe("FQDN of the mail server"), preference: z.number().describe("MX preference/priority value"), 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, mail_exchanger, preference, view, ttl, comment, }) => { const data: Record<string, unknown> = { name, mail_exchanger, preference, }; 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:mx", data); return toolResult( `MX record created successfully.\nReference: ${ref}`, ); } catch (error) { return toolResult( `Error creating MX record: ${error}`, true, ); } }, ); - src/tools/dns.ts:30-32 (helper)toolResult helper function that formats the response for MCP tools. Returns an object with content array and optional error flag.
function toolResult(text: string, isError = false) { return { content: [{ type: "text" as const, text }], isError }; } - src/infoblox-client.ts:79-84 (helper)InfobloxClient.create method that makes POST request to Infoblox API. Used by create_mx_record handler to create the MX record via 'record:mx' endpoint.
async create( objectType: string, data: Record<string, unknown>, ): Promise<string> { return this.request("POST", objectType, data) as Promise<string>; }