Skip to main content
Glama
fredriksknese

mcp-infoblox

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
NameRequiredDescriptionDefault
nameYesAlias FQDN for the CNAME record
canonicalYesCanonical name (target FQDN)
viewNoDNS view
ttlNoTTL in seconds
commentNoComment for the record

Implementation Reference

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

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