Skip to main content
Glama
DLHellMe
by DLHellMe

scrape_group

Extract posts from Telegram groups and convert them to markdown format for analysis or archiving. Use authenticated sessions to access content with configurable post limits.

Instructions

Scrape a Telegram group and return posts in markdown format. Uses authenticated session if logged in.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe Telegram group URL (e.g., https://t.me/groupname)
max_postsNoMaximum number of posts to scrape (default: 100)

Implementation Reference

  • The handler function that executes the 'scrape_group' tool. It delegates to handleScrapeChannel since groups are handled identically to channels.
    private async handleScrapeGroup(args: any): Promise<any> {
      // Groups are handled the same way as channels
      return this.handleScrapeChannel(args);
    }
  • src/server.ts:166-184 (registration)
    Registration of the 'scrape_group' tool in the getTools() method, including name, description, and input schema.
    {
      name: 'scrape_group',
      description: 'Scrape a Telegram group and return posts in markdown format. Uses authenticated session if logged in.',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'The Telegram group URL (e.g., https://t.me/groupname)'
          },
          max_posts: {
            type: 'number',
            description: 'Maximum number of posts to scrape (default: 100)',
            default: 100
          }
        },
        required: ['url']
      }
    },
  • Core helper function called by scrape_group handler, performing the actual scraping logic using TelegramScraper instance and formatting the result as markdown.
    private async handleScrapeChannel(args: any): Promise<any> {
      // Check if authenticated and use authenticated scraper by default
      const isAuthenticated = await this.auth.isAuthenticated();
      const scraperToUse = isAuthenticated ? this.authScraper : this.scraper;
      
      if (isAuthenticated) {
        logger.info('Using authenticated scraper (logged in)');
      } else {
        logger.info('Using unauthenticated scraper (not logged in)');
      }
    
      const options: ScrapeOptions = {
        url: args.url,
        maxPosts: args.max_posts === undefined ? 0 : args.max_posts, // 0 means no limit
        includeReactions: args.include_reactions !== false
      };
    
      const result = await scraperToUse.scrape(options);
      const markdown = this.formatter.format(result);
    
      return {
        content: [
          {
            type: 'text',
            text: isAuthenticated 
              ? `${markdown}\n\n✅ *Scraped using authenticated session*`
              : markdown
          }
        ]
      };
    }

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/DLHellMe/telegram-mcp-server'

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