telegraph_backup_account
Export all pages from a Telegraph account in Markdown or HTML format for backup purposes using an access token.
Instructions
Backup all pages from a Telegraph account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | Yes | Access token of the Telegraph account | |
| format | No | Export format | markdown |
| limit | No | Maximum number of pages to export |
Implementation Reference
- src/tools/export.ts:194-225 (handler)Main execution logic for the 'telegraph_backup_account' tool: validates input with BackupAccountSchema, fetches account page list using telegraph.getPageList, iterates over pages to fetch full content and convert to markdown or HTML, collects into exportedPages array, returns structured JSON response with total and exported counts.if (name === 'telegraph_backup_account') { const input = BackupAccountSchema.parse(args); const pageList = await telegraph.getPageList(input.access_token, 0, input.limit); const exportedPages = []; for (const page of pageList.pages) { const fullPage = await telegraph.getPage(page.path, true); const content = fullPage.content ? (input.format === 'markdown' ? nodesToMarkdown(fullPage.content) : nodesToHtml(fullPage.content)) : ''; exportedPages.push({ title: fullPage.title, path: fullPage.path, url: fullPage.url, content, }); } return { content: [{ type: 'text' as const, text: JSON.stringify({ total_count: pageList.total_count, exported_count: exportedPages.length, format: input.format, pages: exportedPages, }, null, 2), }], }; }
- src/tools/export.ts:16-20 (schema)Zod schema for input validation of the 'telegraph_backup_account' tool, defining access_token (required), format, and optional limit.export const BackupAccountSchema = z.object({ access_token: z.string().describe('Access token of the Telegraph account'), format: z.enum(['markdown', 'html']).default('markdown').describe('Export format'), limit: z.number().int().min(1).max(200).default(50).optional(), });
- src/tools/export.ts:137-163 (registration)Tool registration entry in exportTools array, specifying name, description, and input schema for 'telegraph_backup_account'.{ name: 'telegraph_backup_account', description: 'Backup all pages from a Telegraph account', inputSchema: { type: 'object' as const, properties: { access_token: { type: 'string', description: 'Access token of the Telegraph account', }, format: { type: 'string', enum: ['markdown', 'html'], default: 'markdown', description: 'Export format', }, limit: { type: 'integer', minimum: 1, maximum: 200, default: 50, description: 'Maximum number of pages to export', }, }, required: ['access_token'], }, },