Skip to main content
Glama
jeffgolden

Cloudflare MCP Server

by jeffgolden

cloudflare-dns-mcp_update_dns_record

Modify DNS records in Cloudflare by updating zone name, record ID, type, name, content, TTL, and other parameters directly through structured API tools.

Instructions

Update an existing DNS record by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNo
nameNo
portNo
priorityNo
proxiedNo
record_idYes
targetNo
ttlNo
typeNo
weightNo
zone_nameYes

Implementation Reference

  • Executes the tool logic: parses input, resolves zone ID, fetches existing record for partial updates, validates special record types (MX, SRV), merges parameters, ensures TXT quoting, performs Cloudflare PUT API call to update the record, returns MCP-formatted response with updated record details.
    handler: async (params: z.infer<typeof UpdateDnsRecordInputSchema>) => {
      const { zone_name, record_id, ...rest } = UpdateDnsRecordInputSchema.parse(params);
      const zones = await client.get<Array<{ id: string; name: string }>>('/zones', { name: zone_name });
      if (zones.length === 0) throw new Error(`Zone ${zone_name} not found`);
      const zoneId = zones[0].id;
      // Cloudflare requires all mandatory fields; fetch current record if partial update
      const existing = await client.get<typeof DNSRecordSchema['_type']>(`/zones/${zoneId}/dns_records/${record_id}`);
      // Validate edge-cases again on update
      if ((rest.type ?? existing.type) === 'MX' && (rest.priority ?? existing.priority) === undefined) {
        throw new Error('MX record update requires "priority"');
      }
      if ((rest.type ?? existing.type) === 'SRV') {
        const required = ['priority', 'weight', 'port', 'target'];
        for (const f of required) {
          if ((rest as any)[f] === undefined && (existing as any)[f] === undefined) {
            throw new Error(`SRV record update requires "${f}"`);
          }
        }
      }
      const merged = { ...existing, ...rest } as any;
      if ((merged.type ?? existing.type) === 'TXT' && merged.content) {
        merged.content = ensureTxtQuotes(merged.content);
      }
      const payload = merged;
      const record = await client.put<typeof DNSRecordSchema['_type']>(`/zones/${zoneId}/dns_records/${record_id}`, payload);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({ ...record, zone_name }, null, 2)
          }
        ]
      };
    },
  • Input schema (Zod) defining parameters for updating a DNS record: zone_name (required), record_id (required), and optional fields like type, name, content, ttl, priority, etc. Tool definition includes input/output schemas converted to JSON Schema.
    const UpdateDnsRecordInputSchema = z.object({
      zone_name: z.string(),
      record_id: z.string(),
      type: z.string().optional(),
      name: z.string().optional(),
      content: z.string().optional(),
      ttl: z.number().optional(),
      priority: z.number().optional(),
      weight: z.number().optional(),
      port: z.number().optional(),
      target: z.string().optional(),
      proxied: z.boolean().optional(),
    });
    const updateDnsRecordTool: Tool = {
      name: 'cloudflare-dns-mcp/update_dns_record',
      description: 'Update an existing DNS record by ID',
      inputSchema: zodToJsonSchema(UpdateDnsRecordInputSchema) as any,
      outputSchema: zodToJsonSchema(DnsRecordOutputSchema) as any,
  • Registration of the update_dns_record tool within the getDnsTools function's returned tools object.
    return {
      tools: {
        'cloudflare-dns-mcp/echo': echoTool,
        'cloudflare-dns-mcp/list_dns_records': listDnsRecordsTool,
        // create DNS record
        'cloudflare-dns-mcp/create_dns_record': createDnsRecordTool,
        'cloudflare-dns-mcp/list_zones': listZonesTool,
        'cloudflare-dns-mcp/list_zone_settings': listZoneSettingsTool,
        'cloudflare-dns-mcp/list_ssl_certs': listSslCertsTool,
        'cloudflare-dns-mcp/update_dns_record': updateDnsRecordTool,
        'cloudflare-dns-mcp/delete_dns_record': deleteDnsRecordTool,
      },
  • src/index.ts:18-32 (registration)
    Main server registration: imports getDnsTools (line 5), calls it to get dnsTools, spreads dnsTools.tools into allTools aggregate.
    const dnsTools = getDnsTools(cfClient);
    const securityTools = getSecurityTools(cfClient);
    const sslCertTools = getSslCertTools(cfClient);
    const zoneTools = getZoneManagementTools(cfClient);
    const echoTools = getEchoTools();
    const redirectTools = getRedirectTools(cfClient);
    
    const allTools = {
      ...dnsTools.tools,
      ...securityTools.tools,
      ...sslCertTools.tools,
      ...echoTools.tools,
      ...redirectTools.tools,
      ...zoneTools.tools,
    } as Record<string, any>;
  • Sanitizes tool names by replacing non-alphanumeric chars (like '/') with '_', creating 'cloudflare-dns-mcp_update_dns_record' from 'cloudflare-dns-mcp/update_dns_record' for client use.
    const toolsMap: Record<string, any> = {};
    for (const tool of Object.values(allTools)) {
      const safeName = tool.name.replace(/[^a-zA-Z0-9_-]/g, '_');
      toolsMap[safeName] = tool;
    }
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. 'Update' implies a mutation operation, but the description doesn't specify required permissions, whether changes are reversible, rate limits, error conditions, or what happens to unspecified fields (partial vs full updates). This leaves critical behavioral aspects undocumented for a mutation tool.

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 that gets straight to the point with zero wasted words. It's appropriately sized for a basic tool description and front-loads the essential information (update DNS record).

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 11 parameters, 0% schema coverage, no annotations, and no output schema, the description is severely incomplete. It doesn't explain what fields can be updated, what the operation returns, error handling, or dependencies. The agent lacks sufficient context to use this tool effectively beyond the basic purpose.

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

Parameters2/5

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

Schema description coverage is 0%, so all 11 parameters are undocumented in the schema. The description mentions only 'by ID' (hinting at record_id) but doesn't explain any other parameters like content, name, type, ttl, proxied, etc. This fails to compensate for the complete lack of schema documentation, leaving most parameters semantically unclear.

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 action ('Update') and resource ('existing DNS record by ID'), making the purpose immediately understandable. It distinguishes from creation tools like 'create_dns_record' by specifying 'existing', but doesn't explicitly differentiate from other update tools like 'update_security_rule' or 'update_zone_settings' beyond the DNS record focus.

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. It doesn't mention prerequisites (like needing to know the record ID), when not to use it, or how it differs from similar tools like 'list_dns_records' for finding IDs or 'delete_dns_record' for removal. The agent must infer usage from the name 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

Related 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/jeffgolden/cloudflare_mcp'

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