Skip to main content
Glama

index-backup

Export all indexed notes to a JSON backup file, preserving full-text search data, tags, and semantic connections for easy retrieval and archiving.

Instructions

Export all notes to a JSON backup file and return the path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dirNo

Implementation Reference

  • src/mcp.ts:134-142 (registration)
    Registration of the 'index-backup' tool in the MCP server, including name, description, and input schema.
    name: 'index-backup', description: 'Export all notes to a JSON backup file and return the path.', inputSchema: { type: 'object', properties: { dir: { type: 'string' }, }, }, },
  • Handler for 'index-backup' tool call: parses args, calls writeBackup on all notes, returns the backup file path.
    case 'index-backup': { const parsed = z.object({ dir: z.string().optional() }).parse(args ?? {}); const file = writeBackup(db.exportAll(), parsed.dir); return { content: [{ type: 'text', text: JSON.stringify({ file }) }] }; }
  • Core helper function writeBackup that creates the JSON backup file in the specified or default directory and returns the file path.
    export function writeBackup(notes: Note[], dir?: string): string { const backupDir = dir || path.resolve(process.cwd(), 'backups'); if (!fs.existsSync(backupDir)) { fs.mkdirSync(backupDir, { recursive: true }); } const file = path.join( backupDir, `notes-backup-${new Date().toISOString().replace(/[:.]/g, '-')}.json` ); logger.info({ file, count: notes.length }, 'Writing JSON backup'); fs.writeFileSync(file, JSON.stringify({ generatedAt: new Date().toISOString(), notes }, null, 2), 'utf8'); return file; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vjsr007/mcp-index-notes'

If you have feedback or need assistance with the MCP directory API, please join our Discord server