delete_folder
Delete an empty folder by providing its folder ID. Removes a folder from your Dynadot account only if it has no domains assigned to it.
Instructions
Delete a folder. The folder must be empty (no domains assigned to it).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder_id | Yes | Folder ID to delete |
Implementation Reference
- src/tools/folder.ts:49-177 (registration)Registers the 'delete_folder' MCP tool with the server, defining its input schema (folder_id string) and handler.
server.tool( "delete_folder", "Delete a folder. The folder must be empty (no domains assigned to it).", { folder_id: z.string().describe("Folder ID to delete"), }, async ({ folder_id }) => { try { const result = await client.deleteFolder(folder_id); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: `Failed to delete folder: ${msg}` }, ], isError: true, }; } } ); // ─── list_folders ───────────────────────────────────────────── server.tool( "list_folders", "List all folders in the Dynadot account.", {}, async () => { try { const result = await client.listFolders(); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: `Failed to list folders: ${msg}` }, ], isError: true, }; } } ); // ─── set_folder_settings ────────────────────────────────────── server.tool( "set_folder_settings", "Apply default settings to a folder. All domains in the folder will " + "inherit these settings. Supports nameservers, DNS, forwarding, " + "parking, stealth, and renewal options. Pass the appropriate " + "Dynadot API parameters for the setting type.", { folder_id: z.string().describe("Folder ID to configure"), setting_type: z .enum(["whois", "ns", "dns", "dns2", "forwarding", "stealth", "parking", "hosting", "email_forward", "renew_option", "clear"]) .describe( "Type of setting to apply: 'whois' (WHOIS contacts), 'ns' (nameservers), " + "'dns' (basic DNS), 'dns2' (advanced DNS records), 'forwarding', 'stealth', " + "'parking', 'hosting', 'email_forward', 'renew_option', or 'clear' (remove settings)" ), params: z .record(z.string()) .optional() .describe("Setting parameters as key-value pairs (varies by setting type)"), }, async ({ folder_id, setting_type, params }) => { try { const command = setting_type === "clear" ? "set_clear_folder_setting" : `set_folder_${setting_type}`; const result = await client.call(command, { folder_id, ...(params || {}), }); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: `Failed to set folder settings: ${msg}` }, ], isError: true, }; } } ); // ─── rename_folder ──────────────────────────────────────────── server.tool( "rename_folder", "Rename an existing folder.", { folder_id: z.string().describe("Folder ID to rename"), folder_name: z.string().describe("New name for the folder"), }, async ({ folder_id, folder_name }) => { try { const result = await client.renameFolder(folder_id, folder_name); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: `Failed to rename folder: ${msg}` }, ], isError: true, }; } } ); - src/tools/folder.ts:55-73 (handler)Handler function that calls client.deleteFolder(folder_id) and returns JSON result or error message.
async ({ folder_id }) => { try { const result = await client.deleteFolder(folder_id); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: `Failed to delete folder: ${msg}` }, ], isError: true, }; } } ); - src/tools/folder.ts:52-54 (schema)Zod schema defining the input parameter: folder_id (string).
{ folder_id: z.string().describe("Folder ID to delete"), }, - Helper method on DynadotClient that calls the Dynadot API3 'delete_folder' command with the folder_id parameter.
async deleteFolder(folderId: string): Promise<DynadotResponse> { return this.call("delete_folder", { folder_id: folderId }); } - src/index.ts:55-57 (registration)Registration call in main entry point that wires up all folder tools including delete_folder.
registerFolderTools(server, client); registerAccountTools(server, client); registerMarketplaceTools(server, client);