AI Trading MCP scrapes a Telegram channel and pipes its posts — including chart screenshots — into theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/ai-trading-mcp/llms.txt
Use this file to discover all available pages before exploring further.
get_status MCP feed. That requires a user session, not a bot token: the GramJS client logs in as your real Telegram account and reads exactly the channels you can read. Bots cannot access arbitrary channels they have not been invited to, and the Telegram Bot API has no equivalent to fetching message history with photo attachments. The trade-off is that the session grants broad account access, which is why the security steps below matter.
Why a User Session
Full channel access
A user session reads any channel you are a member of — public, private, or invite-only — including full message history and photo attachments, exactly as they appear in the Telegram app.
Image blocks in get_status
Chart screenshots from the feed arrive as MCP image blocks because GramJS can download Telegram media directly. The scraper picks the smallest photo size with width ≥ 800 px to keep payloads lean.
No bot invite required
You do not need to add a bot to the channel or get admin approval. If your account can read it, the scraper can read it.
Session survives restarts
The session string is saved to
session.txt and loaded at startup. The trading process reconnects automatically without re-scanning the QR code.Authorization Steps
Get API credentials from my.telegram.org
Open https://my.telegram.org and log in with your Telegram account.Navigate to API Development Tools and create an application if you have not already. Copy the App api_id (a number) and App api_hash (a hex string) — you will need both in the next step.
Set credentials in your environment
Export the values before running the auth command, or add them to your Or in
.env:.env:Run the session command
From the Both commands invoke the same
packages/main directory, run the session authorizer:session.ts entrypoint — npm run auth just ensures .env is sourced before the process starts.Scan the QR code
A QR code renders directly in the terminal. On your phone, open Telegram and navigate to:Settings → Devices → Link Desktop DevicePoint the camera at the terminal QR code. Telegram will confirm the link on your phone.
Enter your 2FA password (if prompted)
If your Telegram account has Two-Step Verification enabled, the terminal will prompt:Type your cloud password and press Enter. The prompt is handled via readline and never echoed to the shell history.
Confirm session.txt is written
On success the process prints:The session string is written to If you ran the auth command from
session.txt in the current working directory — wherever you ran the command. At runtime, the trading process reads it from the strategy’s working folder:packages/main, move or copy the file to that path:How the QR Auth Flow Works
The session command runsclient.signInUserWithQrCode() from GramJS. The qrCode callback converts the login token to a tg:// deep-link URL and renders it as a QR code in the terminal using qrcode-terminal. The password callback pauses for 2FA input over readline before the session string is saved:
How the Session Is Loaded at Runtime
The trading process usesgetTelegram() from packages/agent/src/config/telegram.ts to connect. The function is wrapped in singleshot() from functools-kit, which memoizes the result — the first call reads session.txt, creates the TelegramClient, and connects; every subsequent call returns the same client instance without re-reading the file:
If
session.txt is missing or unreadable, the catch block in getTelegram logs: "No session found. Please run 'npm start -- --auth' to create a session." The flag --auth in this error message is a bug in the source — the actual CLI flag parsed by getArgs.ts is --session. Use npm start -- --session or the npm run auth convenience script (which runs dotenv -e .env -- npm start -- --session) to create the session file.Securing session.txt
Keep it out of version control
The repository’s
.gitignore already excludes session.txt. Verify that the exclusion is in place before your first commit, especially if you initialize a new repo from this template.Restrict file permissions
On Linux/macOS, set restrictive permissions so only the process owner can read the file:
Don't run on shared machines
Anyone with read access to the filesystem — including other users on the same host — can extract the session string and use it to access your Telegram account. Run the trading process on a machine you control exclusively.
Revoke if compromised
If
session.txt is ever exposed, revoke the session immediately from Telegram: Settings → Devices → find the authorized device → Terminate Session.