Telemcp — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Telemcp (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
An MCP server that gives AI assistants read-only access to your personal Telegram account. It connects via MTProto (as a regular client, not a bot), enforces a whitelist of allowed chats, and never marks messages as read.
Typical use cases:
Using pipx (recommended for end users):
pipx installs CLI tools into isolated environments and makes them available globally.
pipx install git+https://github.com/ashtokalo/telemcp.gitAfter this, telemcp, telemcp-auth, and telemcp-test are available system-wide. To upgrade to the latest version:
pipx upgrade telemcpUsing pip:
pip install git+https://github.com/ashtokalo/telemcp.gitOn most modern Linux distributions and macOS, system Python is managed externally and pip install into the system environment is blocked. Use a virtual environment or pipx.
From source (for development):
git clone https://github.com/ashtokalo/telemcp.git
cd telemcp
make configureThis creates .venv and installs the package in editable mode including dev tools.
Telegram requires an api_id and api_hash to identify the client application. You can get your own for free at https://my.telegram.org - go to "API development tools" and create an application. The name and platform do not matter.
If you leave api_id and api_hash empty in the config, the server falls back to Telegram Desktop's public credentials. This works but carries a small risk: Telegram may flag or restrict the session if its behavior does not match the real Desktop client. For low-volume personal use the risk is minimal. The server prints a warning on startup when using the fallback credentials.
1. Create a config file.
Copy config.example.json from the repository, or create ~/.telemcp/config.json manually using the template from the Configuration reference section below.
2. Authenticate once. This connects to Telegram and saves the session to disk. After this step, the session file handles all authentication automatically.
Two login methods are available:
Phone + code - Telegram sends a confirmation code to your other devices:
telemcp authEnter your phone number with country code (e.g. +79001234567) and the code that arrives in Telegram. If two-factor authentication is enabled, it also asks for the password.
QR code - no SMS or code needed; scan with an existing Telegram client:
telemcp auth --qrA QR code is printed to the terminal. On your phone or desktop Telegram, go to Settings -> Devices -> Link Desktop Device, then scan the code. If two-factor authentication is enabled, it prompts for the password after scanning.
Use telemcp auth --qr if codes sent to your devices are not arriving, or to avoid phone-based verification.
To see full Telethon protocol logs during auth (useful for debugging):
telemcp auth --verbose3. Verify the connection. After authentication, run the smoke test to confirm everything works:
telemcp connectionIt connects to Telegram, prints all folders and the first 15 dialogs, and if a whitelist is configured, also shows dialogs passing the whitelist filter. A successful run looks like:
Connecting to Telegram...
OK
Folders:
2 Family
5 Work
First 15 dialogs (no whitelist filter):
-1001234567890 supergroup Team Chat [3 unread]
9876543 user John Smith
...4. Configure the whitelist. Start the server and use tg_list_folders and tg_list_dialogs to find the IDs of the folders and chats you want to allow, then add them to config.json.
5. Register the server in your MCP client.
Via Claude Code CLI (simplest):
claude mcp add telegram -- telemcp --config config.jsonOr manually in .mcp.json:
{
"mcpServers": {
"telegram": {
"command": "telemcp",
"args": ["--config", "~/.telemcp/config.json"]
}
}
}When --config is a relative path (or omitted, defaulting to config.json), the server resolves it in this order:
<telemcp dir>/config.json~/.telemcp/config.jsonIf neither location has the file, the server exits with an error. Absolute paths bypass this lookup and are used as-is.
All fields are optional except as noted.
{
"api_id": 12345,
"api_hash": "abcdef1234567890abcdef1234567890",
"session_file": "~/.telemcp/session",
"whitelist": {
"folders": [2, 5],
"groups": [-1001234567890, "@some_channel"],
"accounts": [123456789, "@friend"]
},
"proxy": {
"type": "socks5",
"host": "127.0.0.1",
"port": 1080,
"username": null,
"password": null
}
}Your Telegram application credentials from https://my.telegram.org. Set to null or omit to use the Telegram Desktop fallback (see above).
Path to the Telethon session file. Created by telemcp auth. Supports ~ expansion. Default: ~/.telemcp/session.
Controls which chats the server will read from.
folders - list of Telegram folder IDs. All chats inside the folder are allowed.groups - list of group or channel identifiers (numeric IDs or @usernames).accounts - list of user identifiers for private conversations (numeric IDs or @usernames).Numeric group and channel IDs are negative (e.g. -1001234567890). Use tg_list_folders and tg_list_dialogs to find IDs.
When the whitelist is empty, tg_list_folders and tg_list_dialogs still work (so you can discover IDs), but tg_get_messages and tg_get_unread_summary will refuse all requests.
Optional. Supported types:
SOCKS5 or SOCKS4:
"proxy": {
"type": "socks5",
"host": "127.0.0.1",
"port": 1080,
"username": null,
"password": null
}HTTP:
"proxy": {
"type": "http",
"host": "proxy.example.com",
"port": 8080,
"username": null,
"password": null
}MTProto proxy:
"proxy": {
"type": "mtproto",
"host": "proxy.example.com",
"port": 443,
"secret": "dd1234abcdef..."
}Set to null to connect directly.
By default, the Telethon session is stored as a plain SQLite file on disk. To encrypt it, set the TELEMCP_PINCODE environment variable before running telemcp auth and the server.
export TELEMCP_PINCODE="your-passphrase"
telemcp auth # or telemcp auth --qrWhen the variable is set:
telemcp auth exports the session as a string, encrypts it with Fernet (AES-128-CBC + HMAC-SHA256,key derived via PBKDF2-HMAC-SHA256 with 200 000 iterations), and saves it to <session_file>.enc. The plain SQLite file is deleted.
The plain session file is never written to disk.
The .enc file is useless without the passphrase.
If TELEMCP_PINCODE is not set, the server falls back to the plain SQLite session with no change in behavior.
In .mcp.json, use the env field:
{
"mcpServers": {
"telegram": {
"command": "/path/to/telemcp/telemcp.sh",
"args": ["--config", "/path/to/telemcp/config.json"],
"env": {
"TELEMCP_PINCODE": "your-passphrase"
}
}
}
}Via CLI (claude mcp add does not support env directly — edit .mcp.json after adding):
claude mcp add telegram telemcp --config ~/.telemcp/config.json
# then open .mcp.json and add the "env" block manuallyTests are intended for development. Clone the repo, then:
make configure
make testTests cover config loading and path resolution, whitelist filtering, session encryption round-trips, and URL/chat-ref parsing. They run without a Telegram connection.
To run a specific file or test:
.venv/bin/pytest tests/test_session.py -v
.venv/bin/pytest tests/ -k "wrong_pin" -vReturns all Telegram folder filters (the custom tabs in the sidebar) with their IDs and names. Use the IDs to populate whitelist.folders in the config.
Returns accessible dialogs (chats, groups, channels) with ID, name, type, unread count, and last message date. Respects the whitelist when configured; returns all dialogs when the whitelist is empty, which is useful for initial setup.
Optional parameter: folder_id - limit results to a specific folder.
Reads messages from a single chat. Never marks them as read. The chat must be in the whitelist.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
chat_ref | string | required | Numeric ID, @username, or t.me link |
limit | integer | 50 | Max messages to return (hard cap: 200) |
unread_only | boolean | false | Return only unread messages |
since_hours | number | - | Return only messages from the last N hours |
since_message_id | integer | - | Return only messages with ID greater than this value |
Accepted chat_ref formats:
-1001668839992 - numeric channel ID@username - public usernamehttps://t.me/c/1668839992/5699 - private channel link (message ID is ignored, only the channel ID is used)https://t.me/username - public channel linkReturns a digest of unread messages across all whitelisted chats. For each chat with unread messages, returns the most recent N messages. Does not mark anything as read.
Optional parameters:
folder_id - scope to a specific foldermax_messages_per_chat - messages per chat (default: 20)~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.