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
| 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 |
Input Schema (JSON Schema)
{
"properties": {
"comment": {
"description": "Comment for the DNS record",
"type": "string"
},
"content": {
"description": "DNS record content (e.g., IP address, hostname)",
"type": "string"
},
"name": {
"description": "DNS record name (e.g., 'www' or '@' for root)",
"type": "string"
},
"priority": {
"description": "Priority (for MX, SRV records)",
"type": "number"
},
"proxied": {
"default": false,
"description": "Whether the record is proxied through Cloudflare (only for A, AAAA, CNAME)",
"type": "boolean"
},
"ttl": {
"default": 1,
"description": "Time to live (1 = automatic, or 120-86400 seconds)",
"type": "number"
},
"type": {
"description": "DNS record type (A, AAAA, CNAME, TXT, MX, etc.)",
"type": "string"
},
"zone_id": {
"description": "The zone ID",
"type": "string"
}
},
"required": [
"zone_id",
"type",
"name",
"content"
],
"type": "object"
}
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 )
- src/cloudflare_mcp_server/__init__.py:144-187 (registration)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"], },