telegraph_edit_page
Modify existing Telegraph pages by updating content, titles, or author information using HTML or Markdown formatting.
Instructions
Edit an existing Telegraph page. Returns the updated Page object.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | Yes | Access token of the Telegraph account | |
| path | Yes | Path to the page (e.g., "Sample-Page-12-15") | |
| title | Yes | Page title (1-256 characters) | |
| content | Yes | Page content - can be HTML string, Markdown string, or JSON array of Node objects | |
| format | No | Content format: "html" or "markdown" (default: "html") | html |
| author_name | No | Author name (0-128 characters) | |
| author_url | No | Profile link (0-512 characters) | |
| return_content | No | If true, content field will be returned in the Page object |
Implementation Reference
- src/tools/pages.ts:254-272 (handler)The handler logic for the 'telegraph_edit_page' tool. Validates input using EditPageSchema, parses the content into Telegraph Node format, calls the editPage API function, and returns the result as JSON-formatted text content.case 'telegraph_edit_page': { const input = EditPageSchema.parse(args); const content = telegraph.parseContent(input.content, input.format); const result = await telegraph.editPage( input.access_token, input.path, input.title, content, input.author_name, input.author_url, input.return_content ); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2), }], }; }
- src/tools/pages.ts:20-29 (schema)Zod schema defining the input parameters and validation rules for the telegraph_edit_page tool.export const EditPageSchema = z.object({ access_token: z.string().describe('Access token of the Telegraph account'), path: z.string().describe('Path to the page'), title: z.string().min(1).max(256).describe('Page title (1-256 characters)'), content: z.string().describe('Page content - can be HTML string, Markdown string, or JSON array of Node objects'), format: z.enum(['html', 'markdown']).optional().default('html').describe('Content format: "html" or "markdown" (default: "html")'), author_name: z.string().max(128).optional().describe('Author name (0-128 characters)'), author_url: z.string().max(512).optional().describe('Profile link (0-512 characters)'), return_content: z.boolean().optional().describe('If true, content field will be returned in the Page object'), });
- src/tools/pages.ts:97-145 (registration)Tool registration entry in the pageTools array, defining the name, description, and JSON input schema for 'telegraph_edit_page'. Included in allTools export.{ name: 'telegraph_edit_page', description: 'Edit an existing Telegraph page. Returns the updated Page object.', inputSchema: { type: 'object' as const, properties: { access_token: { type: 'string', description: 'Access token of the Telegraph account', }, path: { type: 'string', description: 'Path to the page (e.g., "Sample-Page-12-15")', }, title: { type: 'string', description: 'Page title (1-256 characters)', minLength: 1, maxLength: 256, }, content: { type: 'string', description: 'Page content - can be HTML string, Markdown string, or JSON array of Node objects', }, format: { type: 'string', description: 'Content format: "html" or "markdown" (default: "html")', enum: ['html', 'markdown'], default: 'html', }, author_name: { type: 'string', description: 'Author name (0-128 characters)', maxLength: 128, }, author_url: { type: 'string', description: 'Profile link (0-512 characters)', maxLength: 512, }, return_content: { type: 'boolean', description: 'If true, content field will be returned in the Page object', default: false, }, }, required: ['access_token', 'path', 'title', 'content'], }, },
- src/telegraph-client.ts:166-184 (helper)Helper function that performs the actual API request to Telegraph's editPage endpoint, wrapping the generic apiRequest call with typed parameters.export async function editPage( access_token: string, path: string, title: string, content: Node[], author_name?: string, author_url?: string, return_content?: boolean ): Promise<Page> { return apiRequest<Page>('editPage', { access_token, path, title, content, author_name, author_url, return_content, }); }