Skip to main content
Glama

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; } }

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