Skip to main content
Glama
DLHellMe
by DLHellMe

telegram_api_login

Authenticate with Telegram using API credentials to enable data collection and interaction through the Telegram MCP Server.

Instructions

Login to Telegram using API credentials for fast, efficient scraping

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_idNoYour Telegram API ID (get from https://my.telegram.org)
api_hashNoYour Telegram API Hash

Implementation Reference

  • The handler function for 'telegram_api_login' that initializes TelegramApiScraper with API credentials (from args or env), performs login, stores the scraper instance, and returns success/error messages.
      async handleApiLogin(this: any, args: any): Promise<any> {
        try {
          // Get API credentials from environment or args
          const apiId = parseInt(process.env.TELEGRAM_API_ID || args.api_id || '0');
          const apiHash = process.env.TELEGRAM_API_HASH || args.api_hash || '';
          
          if (!apiId || !apiHash) {
            return {
              content: [{
                type: 'text',
                text: `❌ API credentials not provided.
    
    Please either:
    1. Set environment variables TELEGRAM_API_ID and TELEGRAM_API_HASH
    2. Pass api_id and api_hash as parameters
    3. See API_SETUP.md for instructions on getting your API credentials from https://my.telegram.org`
              }]
            };
          }
          
          const config: TelegramApiConfig = { apiId, apiHash };
          const scraper = new TelegramApiScraper(config);
          
          await scraper.initialize();
          
          // Store the scraper instance for reuse
          this._apiScraper = scraper;
          
          return {
            content: [{
              type: 'text',
              text: `✅ Successfully authenticated with Telegram API!
    
    You can now use the API-based tools:
    - api_scrape_channel - Fast channel scraping
    - api_search_channel - Search within channels
    - api_get_channel_info - Get channel details
    
    Your session has been saved for future use.`
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: 'text',
              text: `❌ API authentication failed: ${error instanceof Error ? error.message : 'Unknown error'}
    
    Please check:
    - Your API credentials are correct
    - Your phone number includes country code (e.g., +1234567890)
    - You entered the verification code correctly`
            }]
          };
        }
      },
  • The MCP tool schema definition including name, description, and input schema for api_id and api_hash parameters.
    {
      name: 'telegram_api_login',
      description: 'Login to Telegram using API credentials for fast, efficient scraping',
      inputSchema: {
        type: 'object',
        properties: {
          api_id: {
            type: 'string',
            description: 'Your Telegram API ID (get from https://my.telegram.org)'
          },
          api_hash: {
            type: 'string',
            description: 'Your Telegram API Hash'
          }
        },
        required: []
      }
    },
  • src/server.ts:95-96 (registration)
    The dispatch case in the tool call handler that routes 'telegram_api_login' calls to the handleApiLogin method.
    case 'telegram_api_login':
      return await this.handleApiLogin(args);
  • src/server.ts:763-763 (registration)
    The method binding that connects the server instance to the apiHandlers.handleApiLogin function.
    private handleApiLogin = apiHandlers.handleApiLogin.bind(this);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'fast, efficient scraping' which hints at performance characteristics, but doesn't describe what the login actually does (e.g., establishes a session, returns authentication tokens, handles 2FA), what happens on failure, rate limits, or security implications. For a login tool with zero annotation coverage, this is insufficient.

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

Conciseness4/5

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

The description is a single, efficient sentence that communicates the core purpose. It's appropriately sized for a login tool, though it could be slightly more front-loaded by moving the purpose ('for fast, efficient scraping') to a separate sentence for better structure.

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?

For a login tool with no annotations and no output schema, the description is incomplete. It doesn't explain what successful login returns (e.g., session token, status), what authentication method is used, error handling, or how the login state integrates with other tools. Given the complexity of authentication and the lack of structured data, more context is needed.

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 description coverage is 100%, so the schema already fully documents both parameters (api_id and api_hash). The description doesn't add any parameter-specific information beyond what's in the schema. The baseline of 3 is appropriate when the schema does all the parameter documentation work.

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 clearly states the action ('Login to Telegram') and the method ('using API credentials'), and mentions the purpose ('for fast, efficient scraping'). It distinguishes from sibling 'telegram_login' by specifying the API method, but doesn't fully differentiate from all authentication-related siblings like 'telegram_auth_status' in terms of when to use each.

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 'telegram_login' or 'scrape_channel_authenticated'. It mentions the purpose ('for fast, efficient scraping') but doesn't specify prerequisites, timing, or exclusions for this login method compared to others available.

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

Install Server

Other Tools

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