Skip to main content
Glama
DLHellMe

Telegram MCP Server

by DLHellMe

telegram_auth_status

Verify Telegram authentication status to determine if the user is logged in and can access channels and groups through the MCP server.

Instructions

Check if authenticated with Telegram

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Executes the telegram_auth_status tool by calling this.auth.isAuthenticated() and returning a formatted text response indicating authentication status.
    private async handleAuthStatus(): Promise<any> {
      const isAuthenticated = await this.auth.isAuthenticated();
      
      return {
        content: [
          {
            type: 'text',
            text: isAuthenticated 
              ? '✅ Authenticated with Telegram. You can access restricted content.'
              : '❌ Not authenticated. Use telegram_login to authenticate.'
          }
        ]
      };
    }
  • Defines the tool schema with name, description, and empty input schema.
      name: 'telegram_auth_status',
      description: 'Check if authenticated with Telegram',
      inputSchema: {
        type: 'object',
        properties: {},
        required: []
      }
    },
  • src/server.ts:86-87 (registration)
    Switch case that routes calls to telegram_auth_status to the handleAuthStatus handler.
    case 'telegram_auth_status':
      return await this.handleAuthStatus();
  • Checks authentication by verifying if cookie manager has stored cookies/auth data.
    async isAuthenticated(): Promise<boolean> {
      // For Telegram Web K, we just check if auth data exists
      // The actual verification happens when we try to use it
      const hasCookies = await this.cookieManager.hasCookies();
      
      if (hasCookies) {
        logger.debug('Authentication data found');
        return true;
      }
      
      return false;
    }
  • Implements the core check for existence of authentication data files (cookies, localStorage, auth_data).
    async hasCookies(): Promise<boolean> {
      try {
        // Check for auth data file (Telegram Web K)
        const authPath = this.cookieFilePath.replace('telegram_cookies.json', 'telegram_auth_data.json');
        logger.debug(`Checking auth path: ${authPath}`);
        try {
          await access(authPath);
          const authData = await readFile(authPath, 'utf8');
          const auth = JSON.parse(authData);
          if (Object.keys(auth).length > 0) {
            logger.info(`Found auth_data.json with ${Object.keys(auth).length} keys`);
            return true;
          }
        } catch (error) {
          logger.debug(`Auth file check failed: ${error}`);
          // Continue to check cookies
        }
        
        // Check traditional cookies
        await access(this.cookieFilePath);
        const cookieData = await readFile(this.cookieFilePath, 'utf8');
        const cookies = JSON.parse(cookieData);
        
        // Also check localStorage file
        if (Array.isArray(cookies) && cookies.length === 0) {
          const localStoragePath = this.cookieFilePath.replace('.json', '_localStorage.json');
          try {
            await access(localStoragePath);
            const lsData = await readFile(localStoragePath, 'utf8');
            const localStorage = JSON.parse(lsData);
            return Object.keys(localStorage).length > 0;
          } catch {
            // No localStorage file
          }
        }
        
        return Array.isArray(cookies) && cookies.length > 0;
      } catch {
        return false;
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.2/5.0
Behavior1/5

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

With no annotations available, the description carries the full burden of behavioral disclosure. It only states 'Check if authenticated with Telegram' without revealing what the tool actually does when called, what it returns, or whether it makes a network request. This is a significant transparency gap.

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 a single, focused sentence with no redundant words. It states the exact purpose without elaboration.

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?

The tool is simple but the description lacks context that would help an agent understand the behavior and result. There is no output schema, so the description should indicate what 'authenticated' means or what kind of response to expect, but it does not.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, and the input schema is empty. There is nothing to document, so the description does not need to add parameter semantics. The baseline of 4 applies because the schema already covers everything.

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 uses the clear verb 'Check' with the resource 'authenticated with Telegram,' defining exactly what the tool does. Among sibling tools like telegram_login and telegram_logout, this status check is distinct and unambiguous.

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 such as telegram_login or telegram_logout. It does not mention prerequisites, typical scenarios, or exclusions.

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