UNPKG

@pimzino/agentic-tools-mcp

Version:

A comprehensive MCP server for task management and agent memories with JSON file storage

84 lines (81 loc) 3.17 kB
import { z } from 'zod'; /** * Delete a project and all associated tasks and subtasks * * @param storage - Storage instance * @returns MCP tool handler for deleting projects */ export function createDeleteProjectTool(storage) { return { name: 'delete_project', description: 'Delete a project and all its associated tasks and subtasks. This action cannot be undone.', inputSchema: { id: z.string(), confirm: z.boolean() }, handler: async ({ id, confirm }) => { try { // Validate inputs if (!id || id.trim().length === 0) { return { content: [{ type: 'text', text: 'Error: Project ID is required.' }], isError: true }; } if (confirm !== true) { return { content: [{ type: 'text', text: 'Error: You must set confirm to true to delete a project.' }], isError: true }; } const project = await storage.getProject(id.trim()); if (!project) { return { content: [{ type: 'text', text: `Error: Project with ID "${id}" not found. Use list_projects to see all available projects.` }], isError: true }; } // Get counts for confirmation message const tasks = await storage.getTasks(project.id); const subtasks = await storage.getSubtasks(undefined, project.id); const deleted = await storage.deleteProject(id); if (!deleted) { return { content: [{ type: 'text', text: `Error: Failed to delete project with ID "${id}".` }], isError: true }; } return { content: [{ type: 'text', text: `✅ Project deleted successfully! **Deleted:** "${project.name}" (ID: ${project.id}) **Also deleted:** ${tasks.length} task(s) and ${subtasks.length} subtask(s) This action cannot be undone. All data associated with this project has been permanently removed.` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error deleting project: ${error instanceof Error ? error.message : 'Unknown error'}` }], isError: true }; } } }; }