delete_note
Delete a markdown note by providing an exact path and confirmation path. This action is irreversible and requires both paths to match.
Instructions
Deletes a note. Pass { path, confirmPath } where both must match exactly. Returns { root, path, success }. This is irreversible.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/note-tools.ts:186-219 (handler)The tool handler for delete_note. Parses input with DeleteNoteSchema, calls services.file.deleteNote(), and returns success/error response.
function makeDeleteNoteTool(container: ServiceContainer): ToolHandler { return { name: "delete_note", description: "Deletes a note. Pass `{ path, confirmPath }` where both must match exactly. Returns `{ root, path, success }`. This is irreversible.", inputSchema: DeleteNoteSchema, async handler(args): Promise<ToolResponse> { const services = requireServices(container); const { path, confirmPath } = DeleteNoteSchema.parse(args); log.info({ path }, "delete_note called"); try { await services.file.deleteNote(path, confirmPath); log.info({ path }, "delete_note complete"); return { content: [ { type: "text", text: JSON.stringify({ root: getRoot(container), path, success: true }), }, ], }; } catch (err) { log.error({ err, path }, "delete_note failed"); return { content: [{ type: "text", text: JSON.stringify({ root: getRoot(container), error: err instanceof Error ? err.message : String(err), possibleSolutions: ["Verify the path exists with read_note", "Ensure confirmPath exactly matches path"], }) }], isError: true, }; } }, }; } - src/tools/note-tools.ts:181-184 (schema)Input validation schema requiring path and confirmPath (both non-empty strings).
const DeleteNoteSchema = z.object({ path: z.string().min(1, "path is required"), confirmPath: z.string().min(1, "confirmPath is required"), }); - src/tools/note-tools.ts:345-360 (registration)Registers delete_note tool (via makeDeleteNoteTool) into the global tool registry.
export function registerNoteTools( registry: Map<string, ToolHandler>, container: ServiceContainer, ): void { const tools = [ makeReadNoteTool(container), makeWriteNoteTool(container), makePatchNoteTool(container), makeDeleteNoteTool(container), makeMoveNoteTool(container), makeReadMultipleNotesTool(container), ]; for (const tool of tools) { registry.set(tool.name, tool); } - src/services/file-service.ts:148-159 (helper)The underlying file service implementation. Validates confirmPath matches path, resolves to full path, then performs fs.unlink to delete.
async deleteNote(relativePath: string, confirmPath: string): Promise<void> { log.info({ path: relativePath }, "deleteNote"); if (relativePath !== confirmPath) { throw new Error( `deleteNote: confirmPath "${confirmPath}" does not match path "${relativePath}"`, ); } const fullPath = this.resolvePath(relativePath); await fs.unlink(fullPath); } - src/types.ts:171-172 (schema)TypeScript interface declaration for the deleteNote method in FileService.
deleteNote(path: string, confirmPath: string): Promise<void>;