From 00f1584fe2ea213bba8b072eeab3f6dc97a7b748 Mon Sep 17 00:00:00 2001 From: hermes-agent Date: Sat, 14 Nov 2026 21:43:09 +0100 Subject: [PATCH] romm-mcp: add delete tools patch --- packages/romm-mcp/romm-mcp-delete.patch | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 packages/romm-mcp/romm-mcp-delete.patch diff --git a/packages/romm-mcp/romm-mcp-delete.patch b/packages/romm-mcp/romm-mcp-delete.patch new file mode 100644 index 0000000..60e8193 --- /dev/null +++ b/packages/romm-mcp/romm-mcp-delete.patch @@ -0,0 +1,66 @@ +--- a/dist/client.js 1985-10-26 09:15:00.000000000 +0100 ++++ b/dist/client.js 2026-11-14 21:42:42.155986145 +0100 +@@ -132,0 +133,11 @@ ++ async deleteRomsFromFs(ids, confirm = false) { ++ if (!confirm) ++ throw new Error("Delete requires confirm=true. NEVER delete without explicit confirmation."); ++ return this.request("/api/roms/delete", { ++ method: "POST", ++ body: JSON.stringify({ roms: ids, delete_from_fs: ids }), ++ }); ++ } ++ async deleteRomFile(romId, fileId) { ++ return this.request("/api/roms/" + romId + "/files/" + fileId, { method: "DELETE" }); ++ } +--- a/dist/server.js 1985-10-26 09:15:00.000000000 +0100 ++++ b/dist/server.js 2026-11-14 21:42:42.156429699 +0100 +@@ -481,0 +482,49 @@ ++ // ─── romm_delete_rom ───────────────────────────── ++ // RomM 5.x splits "drop the row" from "drop the file": POST /api/roms/delete takes ++ // roms[] plus delete_from_fs[]. Sending only roms[] leaves the file on disk and the ++ // next library scan resurrects the entry, which is the opposite of a cleanup. ++ server.tool("romm_delete_rom", "Delete ROMs from the library. delete_from_fs (default true) also removes the files on disk; without it RomM only drops the database rows and the next scan re-adds them. Requires confirm_delete=true.", { ++ ids: z.array(z.number()).describe("ROM ids to delete (from romm_browse_roms or romm_search_roms)"), ++ delete_from_fs: z.boolean().optional().describe("Also delete the files on disk (default true)"), ++ confirm_delete: z.boolean().optional().describe("Must be true: deletion cannot be undone"), ++ }, { readOnlyHint: false, destructiveHint: true, idempotentHint: true }, async (params) => { ++ requireWrite(); ++ if (!params.confirm_delete) ++ throw new Error("Delete requires confirm_delete=true. NEVER delete without explicit confirmation."); ++ const ids = params.ids || []; ++ if (ids.length === 0) ++ throw new Error("ids must contain at least one ROM id"); ++ if (params.delete_from_fs === false) { ++ await client.deleteRoms(ids, true); ++ } ++ else { ++ await client.deleteRomsFromFs(ids, true); ++ } ++ return { ++ content: [{ ++ type: "text", ++ text: "Deleted " + ids.length + " ROM(s): " + ids.join(", ") + "\n" + ++ (params.delete_from_fs === false ++ ? "Database rows only: the files are still on disk and a rescan brings them back." ++ : "Files removed from disk as well."), ++ }], ++ }; ++ }); ++ // ─── romm_delete_rom_file ─────────────────────────── ++ // For duplicates: remove one file of a ROM without touching the game entry itself. ++ server.tool("romm_delete_rom_file", "Delete ONE file belonging to a ROM, e.g. a duplicate copy, without removing the game entry. File ids come from romm_get_rom. Requires confirm_delete=true.", { ++ rom_id: z.number().describe("ROM id"), ++ file_id: z.number().describe("ROM file id"), ++ confirm_delete: z.boolean().optional().describe("Must be true: deletion cannot be undone"), ++ }, { readOnlyHint: false, destructiveHint: true, idempotentHint: true }, async (params) => { ++ requireWrite(); ++ if (!params.confirm_delete) ++ throw new Error("Delete requires confirm_delete=true."); ++ await client.deleteRomFile(params.rom_id, params.file_id); ++ return { ++ content: [{ ++ type: "text", ++ text: "Deleted file #" + params.file_id + " from ROM #" + params.rom_id, ++ }], ++ }; ++ });