Skip to main content
Glama
fredriksknese

mcp-infoblox

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
NameRequiredDescriptionDefault
nameYesFQDN for the MX record (usually the domain)
mail_exchangerYesFQDN of the mail server
preferenceYesMX preference/priority value
viewNoDNS view
ttlNoTTL in seconds
commentNoComment for the record

Implementation Reference

  • 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,
        );
      }
    },
  • 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"),
    },
  • 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,
          );
        }
      },
    );
  • 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 };
    }
  • 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>;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fredriksknese/mcp-infoblox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server