Telegram命令行工具

一个支持后台同步和可选MCP服务器的Telegram命令行界面工具,适用于个人账户管理。

  • by kfastov
  • JavaScript
  • 本地部署
  • 44 星标
  • 更新于
在 GitHub 查看 kfastov/telegram-mcp-server

使用说明

tgcli

Telegram CLI,带有后台同步和可选的MCP服务器,用于您的个人帐户(MTProto,而不是bot API)。

安装

npm install -g @kfastov/tgcli
brew install kfastov/tap/tgcli

认证

获取Telegram API证书:

  1. 首选https://my.telegram.org/apps
  2. 使用您的电话号码登录
  3. 创建新应用程序
  4. 复制 api_id 和 api_hash

然后进行身份验证:

tgcli auth

快速开始

tgcli auth
tgcli sync --follow
tgcli messages list --chat @username --limit 20
tgcli messages search "course" --chat @channel --source archive
tgcli send text --to @username --message "hello"
tgcli server

命令

tgcli auth           Authentication and session setup
tgcli config         View and edit config
tgcli sync           Archive backfill and realtime sync
tgcli server         Run background sync service (MCP optional)
tgcli service        Install/start/stop/status/logs for background service
tgcli channels       List/search channels
tgcli messages       List/search messages
tgcli send           Send text or files
tgcli media          Download media
tgcli topics         Forum topics
tgcli tags           Channel tags
tgcli metadata       Channel metadata cache
tgcli contacts       Contacts and people
tgcli groups         Group management
tgcli doctor         Diagnostics and sanity checks

使用 tgcli [command] --help 了解详情。添加 --json 用于机器可读输出。

MCP(可选)

通过配置启用它:

tgcli config set mcp.enabled true

默认情况下,服务器绑定到 http://127.0.0.1:8080/mcp。要更改它,请执行以下操作:

tgcli config set mcp.host 127.0.0.1
tgcli config set mcp.port 8080

然后运行 tgcli server 并将您的客户端指向配置的地址。

配置和存储

tgcli存储位于操作系统应用程序数据目录中,包含 config.json、会议和 messages.db. 用以下内容覆盖位置 TGCLI_STORE.

旧版本:请参阅 MIGRATION.md.