telegraph_create_from_template
Create Telegraph pages using predefined templates for blog posts, documentation, articles, changelogs, or tutorials with structured data input.
Instructions
Create a new Telegraph page using a template
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | Yes | Access token of the Telegraph account | |
| template | Yes | Template to use | |
| title | Yes | Page title | |
| data | Yes | Template data (fields depend on template type) | |
| author_name | No | Author name | |
| author_url | No | Author URL | |
| return_content | No |
Implementation Reference
- src/tools/templates.ts:84-110 (handler)Handler logic for 'telegraph_create_from_template': validates input with schema, retrieves and generates template content, creates Telegraph page using telegraph.createPage, and returns the result as JSON.if (name === 'telegraph_create_from_template') { const input = CreateFromTemplateSchema.parse(args); const template = getTemplate(input.template); if (!template) { throw new Error(`Unknown template: ${input.template}`); } const htmlContent = template.generate(input.data); const content = telegraph.parseContent(htmlContent); const result = await telegraph.createPage( input.access_token, 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/templates.ts:11-20 (schema)Zod schema defining the input parameters for the telegraph_create_from_template tool, used for validation in the handler.export const CreateFromTemplateSchema = z.object({ access_token: z.string().describe('Access token of the Telegraph account'), template: z.enum(['blog_post', 'documentation', 'article', 'changelog', 'tutorial']) .describe('Template to use'), title: z.string().min(1).max(256).describe('Page title'), data: z.record(z.unknown()).describe('Template data fields'), author_name: z.string().max(128).optional(), author_url: z.string().max(512).optional(), return_content: z.boolean().optional(), });
- src/tools/templates.ts:32-70 (registration)Tool registration object defining name, description, and inputSchema for 'telegraph_create_from_template', included in templateTools array exported and combined into allTools.{ name: 'telegraph_create_from_template', description: 'Create a new Telegraph page using a template', inputSchema: { type: 'object' as const, properties: { access_token: { type: 'string', description: 'Access token of the Telegraph account', }, template: { type: 'string', enum: ['blog_post', 'documentation', 'article', 'changelog', 'tutorial'], description: 'Template to use', }, title: { type: 'string', description: 'Page title', }, data: { type: 'object', description: 'Template data (fields depend on template type)', }, author_name: { type: 'string', description: 'Author name', }, author_url: { type: 'string', description: 'Author URL', }, return_content: { type: 'boolean', default: false, }, }, required: ['access_token', 'template', 'title', 'data'], }, },
- src/tools/index.ts:12-12 (registration)Combines templateTools (including telegraph_create_from_template) into allTools, which is used by the MCP server for tool listing.export const allTools = [...accountTools, ...pageTools, ...templateTools, ...exportTools];
- src/index.ts:137-141 (registration)MCP server handler for listing tools, returns allTools including the telegraph_create_from_template tool.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: allTools, }; });