index-restore
Restore notes from a JSON backup file to the MCP Index Notes server. Imports data and returns the count of successfully restored notes for efficient backup recovery.
Instructions
Restore notes from a JSON backup file. Returns imported count.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes |
Implementation Reference
- src/mcp.ts:1255-1259 (handler)The core handler logic for the 'index-restore' tool. Parses the input arguments using RestoreSchema, reads the backup file using readBackup function, imports the notes into the database store via importMany, and returns the count of imported notes.
case 'index-restore': { const parsed = RestoreSchema.parse(args); const notes = readBackup(parsed.file); db.importMany(notes); return { content: [{ type: 'text', text: JSON.stringify({ imported: notes.length }) }] }; - src/types.ts:41-45 (schema)Zod schema defining the input for 'index-restore' tool, requiring a 'file' string path to the JSON backup.
export const RestoreSchema = z.object({ file: z.string(), }); export type RestoreInput = z.infer<typeof RestoreSchema>; - src/mcp.ts:144-153 (registration)MCP tool registration object defining the name, description, and input schema for 'index-restore' in the tools array.
name: 'index-restore', description: 'Restore notes from a JSON backup file. Returns imported count.', inputSchema: { type: 'object', properties: { file: { type: 'string' }, }, required: ['file'], }, }, - src/backup.ts:20-26 (helper)Helper function readBackup that reads and parses the JSON backup file provided to index-restore, returning an array of notes.
export function readBackup(file: string): Note[] { logger.info({ file }, 'Reading JSON backup'); const raw = fs.readFileSync(file, 'utf8'); const data = JSON.parse(raw) as { notes?: Note[] } | Note[]; if (Array.isArray(data)) return data; return data.notes ?? []; }