Skip to main content
Glama
gilberth

MCP Cloudflare DNS Server

update_dns_record

Modify a DNS record in Cloudflare by updating its type, name, content, TTL, priority, or proxied status using the specified record ID.

Instructions

Update an existing DNS record

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNoDNS record content
nameNoDNS record name
priorityNoPriority (for MX records)
proxiedNoWhether the record should be proxied through Cloudflare
recordIdYesThe DNS record ID to update
ttlNoTime to live (TTL) in seconds
typeNoDNS record type

Implementation Reference

  • Main MCP tool handler for 'update_dns_record'. Processes input arguments, builds update object, calls CloudflareApi.updateDnsRecord, handles errors, and formats success/error responses.
      const handleUpdateDnsRecord = async (args: { 
        recordId: string; 
        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 updates: any = {};
          if (args.type) updates.type = DnsRecordType.parse(args.type);
          if (args.name) updates.name = args.name;
          if (args.content) updates.content = args.content;
          if (args.ttl !== undefined) updates.ttl = args.ttl;
          if (args.priority !== undefined) updates.priority = args.priority;
          if (args.proxied !== undefined) updates.proxied = args.proxied;
          
          const record = await CloudflareApi.updateDnsRecord(args.recordId, updates);
          
          return {
            content: [{ 
              type: "text", 
              text: `āœ… DNS record updated 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 updating DNS record: ${error instanceof Error ? error.message : 'Unknown error'}` }],
          };
        }
      };
  • src/index.ts:118-156 (registration)
    Tool registration in listTools handler, defining name 'update_dns_record', description, and detailed inputSchema matching the handler arguments.
      name: "update_dns_record",
      description: "Update an existing DNS record",
      inputSchema: {
        type: "object",
        properties: {
          recordId: {
            type: "string",
            description: "The DNS record ID to update",
          },
          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",
            minimum: 1,
          },
          priority: {
            type: "number",
            description: "Priority (for MX records)",
          },
          proxied: {
            type: "boolean",
            description: "Whether the record should be proxied through Cloudflare",
          },
        },
        required: ["recordId"],
      },
    },
  • CloudflareApi.updateDnsRecord helper function that validates updates with Zod, makes PATCH request to Cloudflare API endpoint `/zones/{zoneId}/dns_records/{recordId}`, parses response, and returns the updated DnsRecord.
    updateDnsRecord: async (recordId: string, updates: UpdateDnsRecord): Promise<DnsRecord> => {
      const validatedUpdates = UpdateDnsRecordRequest.parse(updates);
      const response = await api(`dns_records/${recordId}`, 'PATCH', validatedUpdates);
      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 update DNS record');
      }
      
      return data.result;
    },
  • Zod schema UpdateDnsRecordRequest for validating optional update fields (type, name, content, ttl, priority, proxied) and inferred TypeScript type UpdateDnsRecord, used in API layer.
    export const UpdateDnsRecordRequest = z.object({
      type: DnsRecordType.optional(),
      name: z.string().optional(),
      content: z.string().optional(),
      ttl: z.number().optional(),
      priority: z.number().optional(),
      proxied: z.boolean().optional(),
    });
    
    export type DnsRecord = z.infer<typeof CloudflareDnsRecord>;
    export type DnsRecordTypeEnum = z.infer<typeof DnsRecordType>;
    export type ApiResponse = z.infer<typeof CloudflareApiResponse>;
    export type CreateDnsRecord = z.infer<typeof CreateDnsRecordRequest>;
    export type UpdateDnsRecord = z.infer<typeof UpdateDnsRecordRequest>;
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('update') but doesn't mention critical details like required permissions, whether changes are reversible, potential side effects, or response format. 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 waste. It's front-loaded with the core action and resource, making it highly concise and well-structured for quick understanding.

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 7 parameters, no annotations, and no output schema, the description is incomplete. It lacks behavioral context (e.g., permissions, effects), usage guidance, and output details, making it insufficient for safe and effective tool invocation.

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 fully documents all 7 parameters. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't explain parameter interactions or constraints). Baseline 3 is appropriate when the schema does all the work.

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 ('update') and resource ('existing DNS record'), making the purpose unambiguous. However, it doesn't differentiate from sibling tools like 'create_dns_record' or 'get_dns_record' beyond the basic verb difference, missing explicit scope distinctions.

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?

No guidance is provided on when to use this tool versus alternatives like 'create_dns_record' or 'delete_dns_record'. The description lacks context about prerequisites (e.g., needing an existing record ID) or typical use cases, leaving usage unclear.

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