Skip to main content
Glama
gilberth

MCP Cloudflare DNS Server

create_dns_record

Add a new DNS record to Cloudflare domains by specifying type, name, content, TTL, priority, and proxy settings. Simplifies DNS management for automated setups.

Instructions

Create a new DNS record

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesDNS record content
nameYesDNS record name
priorityNoPriority (for MX records)
proxiedNoWhether the record should be proxied through Cloudflare
ttlNoTime to live (TTL) in seconds (default: 1 for auto)
typeYesDNS record type

Implementation Reference

  • MCP tool handler for create_dns_record: handles tool call dispatch, input processing, API configuration check, calls CloudflareApi.createDnsRecord, and returns formatted response.
      const handleCreateDnsRecord = async (args: { 
        type: string; 
        name: string; 
        content: string; 
        ttl?: number; 
        priority?: number; 
        proxied?: boolean 
      }) => {
        try {
          if (!configureApiIfNeeded()) {
            return {
              content: [{ type: "text", text: "āŒ Configuration incomplete. Please configure Cloudflare API Token and Zone ID first." }],
            };
          }
          
          const recordData: any = {
            type: DnsRecordType.parse(args.type),
            name: args.name,
            content: args.content,
          };
          
          if (args.ttl !== undefined) recordData.ttl = args.ttl;
          if (args.priority !== undefined) recordData.priority = args.priority;
          if (args.proxied !== undefined) recordData.proxied = args.proxied;
          
          const record = await CloudflareApi.createDnsRecord(recordData);
          
          return {
            content: [{ 
              type: "text", 
              text: `āœ… DNS record created successfully!
    šŸ”¹ Name: ${record.name}
    šŸ”¹ Type: ${record.type}
    šŸ”¹ Content: ${record.content}
    šŸ”¹ ID: ${record.id}
    ${record.proxied ? '🟠 Proxied through Cloudflare' : ''}`
            }],
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `āŒ Error creating DNS record: ${error instanceof Error ? error.message : 'Unknown error'}` }],
          };
        }
      };
  • Core implementation: validates input with Zod schema, performs POST request to Cloudflare /dns_records endpoint, parses and returns the created DnsRecord.
    createDnsRecord: async (record: CreateDnsRecord): Promise<DnsRecord> => {
      const validatedRecord = CreateDnsRecordRequest.parse(record);
      const response = await api('dns_records', 'POST', validatedRecord);
      const data = CloudflareApiResponse.parse(await response.json());
      
      if (!data.success) {
        throw new Error(`API Error: ${data.errors.map(e => e.message).join(', ')}`);
      }
      
      if (!data.result || Array.isArray(data.result)) {
        throw new Error('Failed to create DNS record');
      }
      
      return data.result;
    },
  • Zod schema defining input shape and validation for create_dns_record parameters.
    export const CreateDnsRecordRequest = z.object({
      type: DnsRecordType,
      name: z.string(),
      content: z.string(),
      ttl: z.number().optional().default(1),
      priority: z.number().optional(),
      proxied: z.boolean().optional(),
    });
  • src/index.ts:81-116 (registration)
    Tool registration in ListTools response: defines name, description, and JSON inputSchema matching the Zod schema.
    {
      name: "create_dns_record",
      description: "Create a new DNS record",
      inputSchema: {
        type: "object",
        properties: {
          type: {
            type: "string",
            enum: ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV", "CAA", "PTR"],
            description: "DNS record type",
          },
          name: {
            type: "string",
            description: "DNS record name",
          },
          content: {
            type: "string",
            description: "DNS record content",
          },
          ttl: {
            type: "number",
            description: "Time to live (TTL) in seconds (default: 1 for auto)",
            minimum: 1,
          },
          priority: {
            type: "number",
            description: "Priority (for MX records)",
          },
          proxied: {
            type: "boolean",
            description: "Whether the record should be proxied through Cloudflare",
          },
        },
        required: ["type", "name", "content"],
      },
    },
  • Zod enum schema for valid DNS record types, used in CreateDnsRecordRequest.
    export const DnsRecordType = z.enum([
      "A", "AAAA", "CNAME", "MX", "TXT", "NS", "SRV", "CAA", "PTR"
    ]);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. 'Create a new DNS record' implies a write operation but doesn't specify permissions needed, whether changes are reversible, rate limits, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a straightforward creation tool and gets directly to the point without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after creation, error conditions, or system behavior. The agent must rely entirely on the input schema for understanding this tool's operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 6 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema, meeting the baseline expectation but not providing extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Create' and the resource 'DNS record', making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'update_dns_record' or 'delete_dns_record' beyond the obvious difference in action verbs.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'update_dns_record' or 'list_dns_records'. It doesn't mention prerequisites, constraints, or typical use cases, leaving the agent to infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/gilberth/mcp-cloudflare'

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