Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesPath to the Telegraph page
yearNoYear (2000-2100, required if month is passed)
monthNoMonth (1-12, required if day is passed)
dayNoDay (1-31, required if hour is passed)
hourNoHour (0-24)

Implementation Reference

  • 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),
        }],
      };
    }
  • 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'],
        },
      },
    ];
  • 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)'),
    });
  • 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,
      });
    }

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/NehoraiHadad/telegraph-mcp'

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