Skip to main content
Glama

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
NameRequiredDescriptionDefault
include_reactionsNoInclude reaction data in the output
max_postsNoMaximum number of posts to scrape (default: 100)
urlYesThe Telegram channel URL (e.g., https://t.me/channelname)

Implementation Reference

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

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