cloudflare-dns-mcp_update_zone_settings
Modify DNS zone settings by providing a zone name and updated configuration. This tool enables direct management of Cloudflare DNS, security, and redirects for optimized domain performance.
Instructions
Update settings for a zone (destructive operation)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| settings | Yes | ||
| zone_name | Yes |
Implementation Reference
- src/tools/zone-management.ts:83-109 (handler)The main handler function that performs the Cloudflare zone settings update by finding the zone ID, preparing the settings items, and making a PATCH request to the Cloudflare API.handler: async (params: any) => { const { zone_name, settings } = UpdateZoneSettingsInputSchema.parse(params); const zones = await client.get<any[]>('/zones', { name: zone_name }); if (zones.length === 0) throw new Error(`Zone ${zone_name} not found`); const zoneId = zones[0].id; const items = Object.entries(settings).map(([id, value]) => ({ id, value })); const body = { items }; const cfClient: any = client as any; if (typeof cfClient.patch === 'function') { return { content: [ { type: "text", text: JSON.stringify(await cfClient.patch(`/zones/${zoneId}/settings`, body), null, 2) } ] }; } return { content: [ { type: "text", text: JSON.stringify(await cfClient.request("PATCH", `/zones/${zoneId}/settings`, body), null, 2) } ] }; },
- src/tools/zone-management.ts:72-76 (schema)Zod input schema for the tool, extending the base zone_name schema with a settings object. Base schema defined earlier at lines 46-48.// update_zone_settings const UpdateZoneSettingsInputSchema = GetZoneSettingsInputSchema.extend({ settings: z.record(z.any()), });
- src/tools/zone-management.ts:152-159 (registration)Local registration of the update_zone_settings tool within the zone-management tools module.return { tools: { 'cloudflare-dns-mcp/list_zones': listZonesTool, 'cloudflare-dns-mcp/get_zone_settings': getZoneSettingsTool, 'cloudflare-dns-mcp/update_zone_settings': updateZoneSettingsTool, 'cloudflare-dns-mcp/purge_cache': purgeCacheTool, }, };
- src/index.ts:25-32 (registration)Global aggregation of all tools including zoneTools (which contains update_zone_settings) into allTools object.const allTools = { ...dnsTools.tools, ...securityTools.tools, ...sslCertTools.tools, ...echoTools.tools, ...redirectTools.tools, ...zoneTools.tools, } as Record<string, any>;
- src/index.ts:48-52 (registration)Registration under sanitized tool name 'cloudflare-dns-mcp_update_zone_settings' by replacing '/' with '_' for MCP server compatibility.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; }