Skip to main content
Glama
ry-ops

Cloudflare MCP Server

by ry-ops

create_dns_record

Add DNS records to Cloudflare zones to direct traffic and manage domain routing. Supports A, AAAA, CNAME, TXT, MX records with configurable TTL and proxy settings.

Instructions

Create a new DNS record in a zone. Supports all DNS record types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
zone_idYesThe zone ID
typeYesDNS record type (A, AAAA, CNAME, TXT, MX, etc.)
nameYesDNS record name (e.g., 'www' or '@' for root)
contentYesDNS record content (e.g., IP address, hostname)
ttlNoTime to live (1 = automatic, or 120-86400 seconds)
proxiedNoWhether the record is proxied through Cloudflare (only for A, AAAA, CNAME)
priorityNoPriority (for MX, SRV records)
commentNoComment for the DNS record

Implementation Reference

  • The handler function `_create_dns_record` that implements the tool logic by preparing the DNS record data dictionary and calling the `_make_request` helper to POST to the Cloudflare API endpoint `/zones/{zone_id}/dns_records`.
    async def _create_dns_record(self, args: dict) -> Any:
        """Create DNS record."""
        data = {
            "type": args["type"],
            "name": args["name"],
            "content": args["content"],
            "ttl": args.get("ttl", 1),
        }
    
        if "proxied" in args:
            data["proxied"] = args["proxied"]
        if "priority" in args:
            data["priority"] = args["priority"]
        if "comment" in args:
            data["comment"] = args["comment"]
    
        return await self._make_request(
            f"/zones/{args['zone_id']}/dns_records", method="POST", data=data
        )
  • Registration of the 'create_dns_record' tool in the `list_tools` decorator, including its name, description, and detailed inputSchema defining required and optional parameters.
    Tool(
        name="create_dns_record",
        description="Create a new DNS record in a zone. Supports all DNS record types.",
        inputSchema={
            "type": "object",
            "properties": {
                "zone_id": {
                    "type": "string",
                    "description": "The zone ID",
                },
                "type": {
                    "type": "string",
                    "description": "DNS record type (A, AAAA, CNAME, TXT, MX, etc.)",
                },
                "name": {
                    "type": "string",
                    "description": "DNS record name (e.g., 'www' or '@' for root)",
                },
                "content": {
                    "type": "string",
                    "description": "DNS record content (e.g., IP address, hostname)",
                },
                "ttl": {
                    "type": "number",
                    "description": "Time to live (1 = automatic, or 120-86400 seconds)",
                    "default": 1,
                },
                "proxied": {
                    "type": "boolean",
                    "description": "Whether the record is proxied through Cloudflare (only for A, AAAA, CNAME)",
                    "default": False,
                },
                "priority": {
                    "type": "number",
                    "description": "Priority (for MX, SRV records)",
                },
                "comment": {
                    "type": "string",
                    "description": "Comment for the DNS record",
                },
            },
            "required": ["zone_id", "type", "name", "content"],
        },
    ),
  • The inputSchema JSON structure for the 'create_dns_record' tool, specifying properties like zone_id (required), type, name, content, ttl, proxied, priority, comment with types, descriptions, and defaults.
    inputSchema={
        "type": "object",
        "properties": {
            "zone_id": {
                "type": "string",
                "description": "The zone ID",
            },
            "type": {
                "type": "string",
                "description": "DNS record type (A, AAAA, CNAME, TXT, MX, etc.)",
            },
            "name": {
                "type": "string",
                "description": "DNS record name (e.g., 'www' or '@' for root)",
            },
            "content": {
                "type": "string",
                "description": "DNS record content (e.g., IP address, hostname)",
            },
            "ttl": {
                "type": "number",
                "description": "Time to live (1 = automatic, or 120-86400 seconds)",
                "default": 1,
            },
            "proxied": {
                "type": "boolean",
                "description": "Whether the record is proxied through Cloudflare (only for A, AAAA, CNAME)",
                "default": False,
            },
            "priority": {
                "type": "number",
                "description": "Priority (for MX, SRV records)",
            },
            "comment": {
                "type": "string",
                "description": "Comment for the DNS record",
            },
        },
        "required": ["zone_id", "type", "name", "content"],
    },

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/ry-ops/cloudflare-mcp-server'

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