index-delete
Remove indexed notes by ID or key from the MCP Index Notes server. Returns a count or boolean confirmation for deleted entries, ensuring precise note management.
Instructions
Delete notes by id or by key. Returns count/boolean.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| key | No |
Implementation Reference
- src/mcp.ts:1238-1248 (handler)Main handler for the 'index-delete' MCP tool. Parses arguments using DeleteSchema, then calls db.deleteById(id) or db.deleteByKey(key) accordingly, returning JSON result.case 'index-delete': { const parsed = DeleteSchema.parse(args ?? {}); if (parsed.id) { const ok = db.deleteById(parsed.id); return { content: [{ type: 'text', text: JSON.stringify({ ok }) }] }; } if (parsed.key) { const count = db.deleteByKey(parsed.key); return { content: [{ type: 'text', text: JSON.stringify({ deleted: count }) }] }; } return { content: [{ type: 'text', text: JSON.stringify({ error: 'Provide id or key' }) }] };
- src/mcp.ts:122-132 (registration)Tool registration in the tools array, defining name, description, and inputSchema for 'index-delete'.{ name: 'index-delete', description: 'Delete notes by id or by key. Returns count/boolean.', inputSchema: { type: 'object', properties: { id: { type: 'number' }, key: { type: 'string' }, }, }, },
- src/types.ts:34-37 (schema)Zod schema (DeleteSchema) used for input validation in the index-delete handler.export const DeleteSchema = z.object({ id: z.number().int().positive().optional(), key: z.string().optional(), });
- src/db.ts:144-148 (helper)Database helper method deleteById(id) called by the tool handler when deleting by note ID.deleteById(id: number) { logger.warn({ id }, 'Deleting note by id'); const info = this.db.prepare(`DELETE FROM notes WHERE id = ?`).run(id); return info.changes > 0; }
- src/db.ts:150-154 (helper)Database helper method deleteByKey(key) called by the tool handler when deleting by key.deleteByKey(key: string) { logger.warn({ key }, 'Deleting notes by key'); const info = this.db.prepare(`DELETE FROM notes WHERE key = ?`).run(key); return info.changes; }