dns_create_zone
Create a DNS zone for hosting records locally (Primary) or conditional forwarding (Forwarder).
Instructions
Create a new DNS zone. Use 'Primary' for hosting records locally, 'Forwarder' for conditional forwarding.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| zone | Yes | Zone domain name (e.g. example.com) | |
| type | No | Zone type (default: Primary) |
Implementation Reference
- src/tools/zones.ts:45-55 (handler)The handler function for dns_create_zone. Validates the domain name, optionally validates zone type (defaults to 'Primary'), and calls POST /api/zones/create on the Technitium server.
handler: async (args) => { const zone = validateDomain(args.zone as string); const type = args.type ? validateZoneType(args.type as string) : "Primary"; const data = await client.callOrThrow("/api/zones/create", { zone, type, }); return JSON.stringify(data, null, 2); }, - src/tools/zones.ts:28-42 (schema)Input schema for dns_create_zone. Accepts 'zone' (string, required) and 'type' (enum: Primary/Secondary/Stub/Forwarder, optional).
inputSchema: { type: "object", properties: { zone: { type: "string", description: "Zone domain name (e.g. example.com)", }, type: { type: "string", enum: ["Primary", "Secondary", "Stub", "Forwarder"], description: "Zone type (default: Primary)", }, }, required: ["zone"], }, - src/tools/index.ts:14-18 (registration)The zoneTools function is called inside getAllTools(), which collects all tool entries including dns_create_zone.
export function getAllTools(client: TechnitiumClient): ToolEntry[] { return [ ...dashboardTools(client), ...dnsClientTools(client), ...zoneTools(client), - src/index.ts:21-26 (registration)getAllTools() is invoked and tools are placed into toolMap for dispatch via CallToolRequestSchema handler.
const allTools = getAllTools(client); // Filter out write tools in readonly mode const tools = config.readonly ? allTools.filter((t) => t.readonly) : allTools; - src/validate.ts:5-17 (helper)validateDomain() helper used by the handler to sanitize the zone domain name.
export function validateDomain(domain: string): string { if (!domain || typeof domain !== "string") { throw new Error("Domain name is required"); } const trimmed = domain.trim().toLowerCase(); if (trimmed.length > 253) { throw new Error("Domain name exceeds maximum length of 253 characters"); } if (!DOMAIN_RE.test(trimmed)) { throw new Error("Invalid domain name format"); } return trimmed; } - src/validate.ts:84-89 (helper)validateZoneType() helper used by the handler to validate the zone type parameter.
export function validateZoneType(type: string): string { if (!VALID_ZONE_TYPES.has(type)) { throw new Error(`Invalid zone type: ${type}`); } return type; } - src/rate-limit.ts:32-39 (helper)Rate limit registration for dns_create_zone — it gets 10 requests per 60s window (mutateLimits).
for (const tool of [ "dns_create_zone", "dns_add_record", "dns_update_record", "dns_block_domain", "dns_allow_domain", "dns_remove_allowed", "dns_remove_blocked", "dns_delete_cached", "dns_enable_zone", "dns_disable_zone", "dns_set_zone_options", "dns_set_settings", "dns_install_app", ]) { this.toolLimits.set(tool, mutateLimits);