tg-mcp-tools

tg-mcp-tools

A local MCP server for Cursor and Claude Desktop that reads Telegram subscriptions over MTProto and exposes channel posts for digests and natural-language queries.

Category
访问服务器

README

tg-mcp-tools

npm version

A local MCP server for Cursor and Claude Desktop. It reads your Telegram subscriptions over MTProto (personal account, not a bot) and exposes channel posts to the agent for digests and natural-language questions like “what’s new in my Travel folder this week?”

Install

npm install -g tg-mcp-tools

Or run without installing (recommended for MCP):

npx tg-mcp-tools-auth   # one-time login
npx tg-mcp-tools        # MCP server (stdio)

Features

  • 13 MCP tools: channels (create/rename), folders (create/edit), dialogs, messages, digests, send message, archive/unarchive
  • Post links — every message includes a url field (https://t.me/...)
  • Archived channels — included when listing subscriptions
  • QR login — scan from the terminal, no SMS or in-app codes

Requirements

Quick start

Create a project directory, add credentials, authorize, then connect MCP.

mkdir my-telegram-mcp && cd my-telegram-mcp
cp path/to/node_modules/tg-mcp-tools/.env.example .env
# or from a git clone: cp .env.example .env

Fill in .env:

TELEGRAM_API_ID=12345678
TELEGRAM_API_HASH=your_api_hash

Authorize (scan QR in terminal; session is saved to .env in the current directory):

npx tg-mcp-tools-auth
# or, from a git clone: npm run auth

Verify the MCP server starts:

npx tg-mcp-tools
# or, from a git clone: npm run mcp

Cursor setup

Add to .cursor/mcp.json in your project (where .env lives):

{
  "mcpServers": {
    "telegram": {
      "command": "npx",
      "args": ["-y", "tg-mcp-tools"]
    }
  }
}

The server loads .env from the current working directory (your project root). You don't need to duplicate env vars in mcp.json if .env is present.

For local development from a git clone, use:

{
  "mcpServers": {
    "telegram": {
      "command": "npm",
      "args": ["run", "mcp"]
    }
  }
}

After changing the config, reload Cursor (Developer: Reload Window).

MCP Inspector

Use the MCP Inspector to call tg_* tools in the browser and inspect JSON-RPC traffic before wiring Cursor.

From the project root (where .env lives):

npm run inspect

This builds the server, starts it via npm run mcp over stdio, and opens the Inspector UI (usually http://localhost:6274). Use the full URL printed in the terminal if an auth token is required.

Links

CLI mode (no browser):

npx -y @modelcontextprotocol/inspector --cli npm run mcp

MCP tools

Tool Purpose
tg_create_channel Create a new broadcast channel (title and optional description)
tg_set_channel_title Rename a channel or group (requires admin rights)
tg_get_folders Telegram chat folders (tabs) with id and name
tg_create_folder Create a folder with channels and filter rules
tg_edit_folder Update an existing folder: replace included chats or rename it
tg_get_dialogs List channels, groups, and chats; optional folder filter
tg_get_messages Posts from one channel (@username or numeric id)
tg_get_recent_from_channels Digest from multiple channels, sorted by date
tg_get_recent_from_folder Digest from all channels/groups in a folder
tg_send_message Send formatted text to a user (@username), chat id, or "me" (Markdown/HTML)
tg_archive_chats Move chats/channels to Archive
tg_unarchive_chats Restore chats/channels from Archive

Example prompts in Cursor:

What’s new in my Travel folder this week?

Authorization

  1. Run npx tg-mcp-tools-auth from the directory where .env should live
  2. On your phone: Telegram → Settings → Devices → Link Desktop Device
  3. Scan the QR code in the terminal
  4. Enter your 2FA password if prompted
  5. TELEGRAM_SESSION is written to .env automatically

Scripts

Command Description
npx tg-mcp-tools-auth One-time login; saves TELEGRAM_SESSION to .env in cwd
npx tg-mcp-tools Start the MCP server (stdio)
npm run auth / npm run mcp Start auth or MCP server (npm run build first when developing from a git clone)
npm run inspect Build and launch MCP Inspector for this server
npm run build Compile TypeScript → dist/

Security

  • Do not commit .env — it contains your Telegram session (full account access)
  • Never share TELEGRAM_SESSION in logs, issues, or chats
  • Revoke API credentials or sessions at my.telegram.org

Project layout

src/
├── config.ts           # load .env from repo root
├── env-file.ts         # update .env values after auth
├── telegram-client.ts  # mtcute: dialogs, history, post URLs
├── index.ts            # MCP server and tool registration
└── auth.ts             # CLI auth (QR)

Stack

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选