delete_package
Permanently remove a package and its files by ID. Requires MASV_ALLOW_DELETE=true environment variable; action cannot be undone.
Instructions
Delete a package by ID. This permanently removes the package and all its files and cannot be undone. Requires MASV_ALLOW_DELETE=true environment variable to be set.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| packageId | Yes | Id of the package to delete |
Implementation Reference
- src/api/packages.ts:320-342 (handler)The deletePackage function that executes the tool logic. It checks the MASV_ALLOW_DELETE env var, obtains a package token via getPackageToken, and sends a DELETE request to MASV_BASE_URL/v1/packages/{packageId}. Returns success on 204 status or the response data otherwise.
async function deletePackage({ packageId }: DeletePackageParams) { if (!MASV_ALLOW_DELETE) { throw new Error("Delete operations are not allowed. Set MASV_ALLOW_DELETE=true in environment variables to enable."); } const packageToken = await getPackageToken(packageId); const url = new URL(`${MASV_BASE_URL}/v1/packages/${packageId}`); const headers = { "content-type": "application/json", "x-package-token": packageToken, }; const r = await fetch(url.toString(), { method: "DELETE", headers }); if (r.status === 204) { return { success: true, message: "Package deleted successfully" }; } const data = await r.json(); return data; } - src/api/packages.ts:314-316 (schema)Zod schema for delete_package input: requires a packageId string field.
const DeletePackageSchema = z.object({ packageId: z.string().describe("Id of the package to delete"), }); - src/index.ts:174-190 (registration)Registration of the 'delete_package' tool with the MCP server, using DeletePackageSchema for input validation and calling deletePackage as the handler.
server.registerTool( "delete_package", { description: "Delete a package by ID. This permanently removes the package and all its files and cannot be undone. Requires MASV_ALLOW_DELETE=true environment variable to be set.", inputSchema: DeletePackageSchema.shape, }, async (args) => { try { const data = await deletePackage(args); return mcpOk(data); } catch (error) { return mcpError(error); } }, ); - src/api/packages.ts:194-197 (helper)getPackageToken helper: retrieves the access token for a package by calling getPackage and returning data.access_token.
async function getPackageToken(packageId: string) { const data = await getPackage({ packageId }); return data.access_token; }