Skip to main content
Glama
DLHellMe

Telegram MCP Server

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
          }
        ]
      };
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It does disclose that posts are returned in markdown format and that it uses an authenticated session if logged in, which is useful. However, it omits other behavioral traits such as whether login is required, failure behavior without a session, or read-only nature, leaving significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long, directly states the action and output format, and contains no redundant or irrelevant information. It is appropriately front-loaded and concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has only two parameters, but it sits among many related scraping tools with no differentiation. The description does not explain when to use this tool versus siblings, nor does it cover authentication failure scenarios. For a tool with no annotations or output schema, this leaves important context missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already documents both parameters (url and max_posts) with descriptions, achieving 100% coverage. The description adds no parameter-specific meaning beyond what the schema provides, so the baseline score of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses the verb 'Scrape' with resource 'Telegram group' and specifies output as 'posts in markdown format', making the core function clear. However, it does not explicitly distinguish from sibling tools like scrape_channel or scrape_channel_authenticated beyond the word 'group', so it is clear but lacks explicit differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like scrape_channel, scrape_channel_full, or scrape_manual. The only contextual hint is 'Uses authenticated session if logged in', which implies auth behavior but does not explain selection criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.