telegraph_get_views
Retrieve view count statistics for Telegraph pages, with optional filtering by year, month, day, or hour to analyze traffic patterns.
Instructions
Get the number of views for a Telegraph page. Can filter by year, month, day, or hour.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the Telegraph page | |
| year | No | Year (2000-2100, required if month is passed) | |
| month | No | Month (1-12, required if day is passed) | |
| day | No | Day (1-31, required if hour is passed) | |
| hour | No | Hour (0-24) |
Implementation Reference
- src/tools/pages.ts:303-318 (handler)Tool handler case that validates input using GetViewsSchema, calls telegraph.getViews API wrapper, and returns JSON-formatted result as MCP content.case 'telegraph_get_views': { const input = GetViewsSchema.parse(args); const result = await telegraph.getViews( input.path, input.year, input.month, input.day, input.hour ); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2), }], }; }
- src/tools/pages.ts:192-230 (registration)Tool registration in pageTools array, including name, description, and inputSchema for MCP tool registry.{ name: 'telegraph_get_views', description: 'Get the number of views for a Telegraph page. Can filter by year, month, day, or hour.', inputSchema: { type: 'object' as const, properties: { path: { type: 'string', description: 'Path to the Telegraph page', }, year: { type: 'integer', description: 'Year (2000-2100, required if month is passed)', minimum: 2000, maximum: 2100, }, month: { type: 'integer', description: 'Month (1-12, required if day is passed)', minimum: 1, maximum: 12, }, day: { type: 'integer', description: 'Day (1-31, required if hour is passed)', minimum: 1, maximum: 31, }, hour: { type: 'integer', description: 'Hour (0-24)', minimum: 0, maximum: 24, }, }, required: ['path'], }, }, ];
- src/tools/pages.ts:42-48 (schema)Zod schema for input validation used in the tool handler.export const GetViewsSchema = z.object({ path: z.string().describe('Path to the Telegraph page'), year: z.number().int().min(2000).max(2100).optional().describe('Year (required if month is passed)'), month: z.number().int().min(1).max(12).optional().describe('Month (required if day is passed)'), day: z.number().int().min(1).max(31).optional().describe('Day (required if hour is passed)'), hour: z.number().int().min(0).max(24).optional().describe('Hour (0-24)'), });
- src/telegraph-client.ts:227-241 (helper)API wrapper function that makes the HTTP request to Telegraph's getViews endpoint using the shared apiRequest helper.export async function getViews( path: string, year?: number, month?: number, day?: number, hour?: number ): Promise<PageViews> { return apiRequest<PageViews>('getViews', { path, year, month, day, hour, }); }