api_get_channel_info
Retrieve detailed information about any Telegram channel by providing its URL, enabling users to access channel data through API integration.
Instructions
Get detailed information about a Telegram channel using the API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The Telegram channel URL |
Implementation Reference
- src/server-api-handlers.ts:203-251 (handler)The handler function that implements the core logic of the 'api_get_channel_info' tool: checks API connection, parses channel URL, retrieves channel information using the Telegram API client, and returns formatted details.async handleApiGetChannelInfo(this: any, args: any): Promise<any> { if (!this._apiScraper || !this._apiScraper.isConnected()) { return { content: [{ type: 'text', text: '❌ Not connected to Telegram API. Please use telegram_api_login first.' }] }; } try { const channelUrl = args.url || args.channel; const channelUsername = channelUrl.match(/(?:t\.me\/|@)([^/?]+)/)?.[1]; if (!channelUsername) { return { content: [{ type: 'text', text: '❌ Invalid channel URL or username' }] }; } const client = (this._apiScraper as any).client; const info = await client.getChannelInfo(channelUsername); return { content: [{ type: 'text', text: `# Channel Information **Name:** ${info.title} **Username:** @${info.username} **Type:** ${info.about} **Members:** ${info.participantsCount?.toLocaleString() || 'N/A'} **ID:** ${info.id} ✅ Retrieved using Telegram API` }] }; } catch (error) { return { content: [{ type: 'text', text: `❌ Failed to get channel info: ${error instanceof Error ? error.message : 'Unknown error'}` }] }; } },
- src/server.ts:359-372 (registration)Registers the 'api_get_channel_info' tool with the MCP server, including its description and input schema requiring a 'url' parameter.{ name: 'api_get_channel_info', description: 'Get detailed information about a Telegram channel using the API', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The Telegram channel URL' } }, required: ['url'] } },
- src/server.ts:104-105 (registration)Switch case in the tool call handler that dispatches 'api_get_channel_info' calls to the bound handler method.case 'api_get_channel_info': return await this.handleApiGetChannelInfo(args);
- src/server.ts:766-766 (registration)Binds the handler function from apiHandlers to the server class instance for use in tool dispatching.private handleApiGetChannelInfo = apiHandlers.handleApiGetChannelInfo.bind(this);