Skip to main content
Glama

scrape_group

Extract and convert Telegram group posts into markdown format using an authenticated session. Specify the group URL and optionally limit the number of posts to retrieve.

Instructions

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

Input Schema

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

Implementation Reference

  • The handler function for the 'scrape_group' tool. It delegates the scraping logic to the shared handleScrapeChannel method.
    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 definition.
    { 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'] } },
  • Shared helper function handleScrapeChannel that contains the core logic for scraping Telegram channels/groups, called by the scrape_group handler.
    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:71-72 (registration)
    Dispatch case in the main tool handler switch statement that routes 'scrape_group' calls to its handler.
    case 'scrape_group': return await this.handleScrapeGroup(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