scrape_channel
Extract Telegram channel posts in markdown format, including reactions, by providing the channel URL and specifying the maximum number of posts to collect. Ideal for content analysis or archival purposes.
Instructions
Scrape a Telegram channel and return posts in markdown format. Uses authenticated session if logged in.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_reactions | No | Include reaction data in the output | |
| max_posts | No | Maximum number of posts to scrape (default: 100) | |
| url | Yes | The Telegram channel URL (e.g., https://t.me/channelname) |
Implementation Reference
- src/server.ts:385-415 (handler)The primary handler function for the 'scrape_channel' tool. Determines whether to use authenticated or unauthenticated scraper based on login status, invokes the scraper's scrape method with provided options, formats the result to markdown, and returns it structured for the MCP response.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 } ] }; }
- src/server.ts:123-146 (registration)Tool registration for 'scrape_channel' in the MCP server's tool list, including description and input schema definition.{ name: 'scrape_channel', description: 'Scrape a Telegram channel and return posts in markdown format. Uses authenticated session if logged in.', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The Telegram channel URL (e.g., https://t.me/channelname)' }, max_posts: { type: 'number', description: 'Maximum number of posts to scrape (default: 100)', default: 100 }, include_reactions: { type: 'boolean', description: 'Include reaction data in the output', default: true } }, required: ['url'] } },
- src/server.ts:126-144 (schema)Input schema definition for the 'scrape_channel' tool, specifying parameters like url (required), max_posts, and include_reactions.inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The Telegram channel URL (e.g., https://t.me/channelname)' }, max_posts: { type: 'number', description: 'Maximum number of posts to scrape (default: 100)', default: 100 }, include_reactions: { type: 'boolean', description: 'Include reaction data in the output', default: true } }, required: ['url']
- src/server.ts:65-66 (handler)Dispatch case in the main tool request handler that routes 'scrape_channel' calls to the specific handleScrapeChannel method.case 'scrape_channel': return await this.handleScrapeChannel(args);