Skip to main content
Glama
ry-ops

Cloudflare MCP Server

by ry-ops

update_dns_record

Modify existing DNS records to change type, name, content, TTL, or proxy settings for domain management and configuration updates.

Instructions

Update an existing DNS record. Can modify type, name, content, TTL, proxy status, etc.

Input Schema

NameRequiredDescriptionDefault
zone_idYesThe zone ID
record_idYesThe DNS record ID to update
typeYesDNS record type
nameYesDNS record name
contentYesDNS record content
ttlNoTime to live
proxiedNoWhether the record is proxied through Cloudflare
priorityNoPriority (for MX, SRV records)
commentNoComment for the DNS record

Input Schema (JSON Schema)

{ "properties": { "comment": { "description": "Comment for the DNS record", "type": "string" }, "content": { "description": "DNS record content", "type": "string" }, "name": { "description": "DNS record name", "type": "string" }, "priority": { "description": "Priority (for MX, SRV records)", "type": "number" }, "proxied": { "description": "Whether the record is proxied through Cloudflare", "type": "boolean" }, "record_id": { "description": "The DNS record ID to update", "type": "string" }, "ttl": { "description": "Time to live", "type": "number" }, "type": { "description": "DNS record type", "type": "string" }, "zone_id": { "description": "The zone ID", "type": "string" } }, "required": [ "zone_id", "record_id", "type", "name", "content" ], "type": "object" }

Implementation Reference

  • The primary handler function for the 'update_dns_record' tool. It constructs a data payload from the input arguments and sends a PUT request to the Cloudflare API endpoint to update the specified DNS record.
    async def _update_dns_record(self, args: dict) -> Any: """Update DNS record.""" data = { "type": args["type"], "name": args["name"], "content": args["content"], } if "ttl" in args: data["ttl"] = args["ttl"] 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/{args['record_id']}", method="PUT", data=data, )
  • The input schema/JSON Schema for the 'update_dns_record' tool, defining properties and required fields for validation.
    inputSchema={ "type": "object", "properties": { "zone_id": {"type": "string", "description": "The zone ID"}, "record_id": { "type": "string", "description": "The DNS record ID to update", }, "type": {"type": "string", "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"}, "proxied": { "type": "boolean", "description": "Whether the record is proxied through Cloudflare", }, "priority": { "type": "number", "description": "Priority (for MX, SRV records)", }, "comment": { "type": "string", "description": "Comment for the DNS record", }, }, "required": ["zone_id", "record_id", "type", "name", "content"], },
  • The registration of the 'update_dns_record' tool in the MCP server's list_tools() method, including its name, description, and input schema.
    Tool( name="update_dns_record", description="Update an existing DNS record. Can modify type, name, content, TTL, proxy status, etc.", inputSchema={ "type": "object", "properties": { "zone_id": {"type": "string", "description": "The zone ID"}, "record_id": { "type": "string", "description": "The DNS record ID to update", }, "type": {"type": "string", "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"}, "proxied": { "type": "boolean", "description": "Whether the record is proxied through Cloudflare", }, "priority": { "type": "number", "description": "Priority (for MX, SRV records)", }, "comment": { "type": "string", "description": "Comment for the DNS record", }, }, "required": ["zone_id", "record_id", "type", "name", "content"], }, ),
  • The dispatch/registration logic in the call_tool handler that routes calls to the _update_dns_record method.
    elif name == "update_dns_record": result = await self._update_dns_record(arguments)
  • Helper method used by the handler to make authenticated HTTP requests to the Cloudflare API, handling errors and parsing responses.
    async def _make_request( self, endpoint: str, method: str = "GET", data: Optional[dict] = None, params: Optional[dict] = None, ) -> Any: """Make a request to the Cloudflare API.""" url = f"{CLOUDFLARE_API_BASE}{endpoint}" headers = { "Authorization": f"Bearer {self.api_token}", "Content-Type": "application/json", } try: response = await self.client.request( method=method, url=url, json=data, params=params, headers=headers, ) response.raise_for_status() result = response.json() if not result.get("success"): errors = result.get("errors", []) raise Exception(f"Cloudflare API error: {json.dumps(errors)}") return result.get("result") except httpx.HTTPError as e: raise Exception(f"HTTP error occurred: {str(e)}") def _setup_handlers(self):

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