Skip to main content
Glama
DLHellMe

Telegram MCP Server

by DLHellMe

scrape_channel_full

Extract all posts from a Telegram channel and save them to files for analysis or archiving.

Instructions

Scrape ALL posts from a Telegram channel and save to file. Uses authenticated session if logged in. Returns file location.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe Telegram channel URL (e.g., https://t.me/channelname)
save_to_fileNoSave results to MD and JSON files

Implementation Reference

  • Main handler function that executes the scrape_channel_full tool logic: determines scraper based on auth, scrapes all posts (maxPosts:0), formats sample, reports file save locations.
      private async handleScrapeChannelFull(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 for full channel scrape (logged in)');
        } else {
          logger.info('Using unauthenticated scraper for full channel scrape (not logged in)');
        }
    
        const options: ScrapeOptions = {
          url: args.url,
          maxPosts: 0, // No limit - get ALL posts
          includeReactions: true
        };
    
        const result = await scraperToUse.scrape(options);
        
        // The scraper already saves to file, so we just need to inform about it
        const channelName = result.channel.username;
        const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
        const windowsPath = `C:\\Users\\User\\AppData\\Roaming\\Claude\\telegram_scraped_data\\${channelName}_${timestamp}_full.md`;
        
        // Also return a sample of the content for immediate analysis
        const samplePosts = result.posts.slice(0, 5); // First 5 posts as sample
        const sampleResult = { ...result, posts: samplePosts };
        const sampleMarkdown = this.formatter.format(sampleResult);
        
        return {
          content: [
            {
              type: 'text',
              text: `Successfully scraped ${result.totalPosts} posts from @${channelName}
    
    Files saved to:
    - Markdown: ${windowsPath}
    - JSON: ${windowsPath.replace('.md', '.json')}
    
    Total posts: ${result.totalPosts}
    Date range: ${result.posts.length > 0 ? `${result.posts[result.posts.length - 1]?.date.toISOString().split('T')[0]} to ${result.posts[0]?.date.toISOString().split('T')[0]}` : 'N/A'}
    
    The full channel history has been saved. Here's a sample of the first 5 posts:
    
    ${sampleMarkdown}
    
    To analyze all ${result.totalPosts} posts, open the saved markdown file and copy its contents to Claude.
    
    ${isAuthenticated ? '✅ Scraped using authenticated session - all content including restricted posts should be accessible.' : '⚠️ Scraped without authentication - some restricted content may not be accessible.'}`
            }
          ]
        };
      }
  • src/server.ts:148-165 (registration)
    Tool registration in getTools() method, defining name, description, and input schema for scrape_channel_full.
      name: 'scrape_channel_full',
      description: 'Scrape ALL posts from a Telegram channel and save to file. Uses authenticated session if logged in. Returns file location.',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'The Telegram channel URL (e.g., https://t.me/channelname)'
          },
          save_to_file: {
            type: 'boolean',
            description: 'Save results to MD and JSON files',
            default: true
          }
        },
        required: ['url']
      }
    },
  • Input schema definition for the scrape_channel_full tool, specifying parameters like url and save_to_file.
    inputSchema: {
      type: 'object',
      properties: {
        url: {
          type: 'string',
          description: 'The Telegram channel URL (e.g., https://t.me/channelname)'
        },
        save_to_file: {
          type: 'boolean',
          description: 'Save results to MD and JSON files',
          default: true
        }
      },
      required: ['url']
    }
  • Dispatcher case in the CallToolRequestSchema handler that routes to the specific tool handler.
    case 'scrape_channel_full':
      return await this.handleScrapeChannelFull(args);

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description must carry the burden of behavioral disclosure. It mentions using an authenticated session if logged in and returning the file location, which adds context. However, it omits side effects like file creation details, rate limits, or whether authentication is required, so transparency is partial.

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 concise sentences, front-loaded with the main action and resource, and contains no redundant or extraneous information.

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

Completeness3/5

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

Given the tool's scale (scraping all posts) and the lack of an output schema or annotations, the description provides the core action and return value but misses important context such as potential volume, prerequisites, limitations, and what 'ALL' includes. It is adequate but not fully complete.

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?

Schema coverage is 100% with both parameters having descriptions. The tool description adds limited extra meaning—chiefly clarifying that 'ALL posts' means the full history and that saving is involved—but does not substantially enhance understanding beyond the schema.

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

Purpose5/5

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

The description clearly states the action ('Scrape ALL posts') and the resource ('Telegram channel'), and the inclusion of 'ALL' distinguishes it from date-range or limited scrape tools. It also specifies the output behavior (save to file), making the purpose unambiguous.

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

Usage Guidelines3/5

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

The word 'ALL' implies use when a full archive is needed, but there is no explicit guidance on when to choose this tool over alternatives like scrape_date_range or scrape_channel. No exclusions or alternative recommendations are provided.

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