create_dns_record
Create a new DNS record in a Cloudflare zone, supporting all record types like A, AAAA, CNAME, TXT, MX, and more.
Instructions
Create a new DNS record in a zone. Supports all DNS record types.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| zone_id | Yes | The zone ID | |
| type | Yes | DNS record type (A, AAAA, CNAME, TXT, MX, etc.) | |
| name | Yes | DNS record name (e.g., 'www' or '@' for root) | |
| content | Yes | DNS record content (e.g., IP address, hostname) | |
| ttl | No | Time to live (1 = automatic, or 120-86400 seconds) | |
| proxied | No | Whether the record is proxied through Cloudflare (only for A, AAAA, CNAME) | |
| priority | No | Priority (for MX, SRV records) | |
| comment | No | Comment for the DNS record |
Implementation Reference
- The handler function `_create_dns_record` that executes the create DNS record tool logic. It builds a data payload from required fields (type, name, content, ttl) and optional fields (proxied, priority, comment), then POSTs 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 ) - The input schema definition for the create_dns_record tool, listing required fields (zone_id, type, name, content) and optional fields (ttl, proxied, priority, comment) with their types and descriptions.
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"], }, - src/cloudflare_mcp_server/__init__.py:412-413 (registration)The tool registration in the call_tool handler dispatcher, routing the name 'create_dns_record' to the `_create_dns_record` method.
elif name == "create_dns_record": result = await self._create_dns_record(arguments)