Skip to main content
Glama
Steph-ux

telegram-mcp-server

by Steph-ux

telegram-mcp-server

Telegram MCP 서버 — Telethon 기반, 영구 클라이언트, 플러드 안전, 9개의 그룹화된 도구.

코드에 API 키 없음. 세션 파일은 로컬에 저장됩니다. 사용자 계정(2FA) 및 봇과 함께 작동합니다.


1. 설치

git clone <this-repo> telegram-mcp-server
cd telegram-mcp-server

python -m venv .venv
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate

pip install -e .

API 자격 증명 가져오기

  1. my.telegram.org로 이동

  2. 전화번호로 로그인

  3. 앱 생성 → API ID 및 API Hash 받기

일회성 인증

# User account (with 2FA support)
export TG_API_ID=12345
export TG_API_HASH="your_hash_here"
telegram-mcp-server --auth --phone +33612345678

# Or via MCP tool: tg_session(action="auth", api_id=12345, api_hash="...", phone="+33612345678")

Related MCP server: telegram-mcp

2. MCP 클라이언트에 등록

Claude Desktop / OpenCode

{
  "mcpServers": {
    "telegram": {
      "command": "telegram-mcp-server",
      "env": {
        "TG_API_ID": "12345",
        "TG_API_HASH": "your_hash_here"
      }
    }
  }
}

PATH에 없는 경우:

{
  "mcpServers": {
    "telegram": {
      "command": "/path/to/.venv/bin/python",
      "args": ["-m", "telegram_mcp_server"],
      "env": {
        "TG_API_ID": "12345",
        "TG_API_HASH": "your_hash_here"
      }
    }
  }
}

Docker

docker build -t telegram-mcp .
docker run -i --rm \
  -v ~/.telegram-mcp/sessions:/root/.telegram-mcp/sessions \
  -e TG_API_ID=12345 \
  -e TG_API_HASH="your_hash" \
  telegram-mcp

3. 도구 카탈로그 (9개 도구, 8개 작업)

tg_session — 세션 관리

action

Required args

Description

auth

api_id, api_hash, phone 또는 bot_token

인증 (2FA 지원)

check

—

로그인 상태 확인

logout

—

세션 삭제

tg_message — 보내기, 전달, 삭제, 답장

action

Required args

Description

send

target, text

메시지 보내기

forward

target, message_id, to_target

메시지 전달

delete

target, message_id

메시지 삭제

reply

target, message_id, text

메시지에 답장

tg_chat — 채팅 작업

action

Required args

Description

list

—

최근 채팅 목록

info

target

채팅 정보 가져오기

members

target

채팅 멤버 목록

leave

target

채팅 나가기

action

Required args

Description

messages

query

메시지 검색 (선택적으로 target 내에서)

users

query

연락처/사용자 검색

channels

query

채널 검색

tg_history — 채팅 기록

action

Required args

Description

messages

target

메시지 기록 가져오기

media

target

미디어 전용 기록 가져오기

files

target

파일 전용 기록 가져오기

tg_user — 사용자 작업

action

Required args

Description

me

—

자신의 정보 가져오기

info

target

사용자 정보 가져오기

block

target

사용자 차단

unblock

target

사용자 차단 해제

tg_media — 미디어 보내기

action

Required args

Description

send_photo

target, file_path

사진 보내기

send_video

target, file_path

동영상 보내기

send_file

target, file_path

문서 보내기

send_voice

target, file_path

음성 메모 보내기

tg_channel — 채널 관리

action

Required args

Description

create

title

슈퍼그룹/채널 만들기

join

target

채널 가입

leave

target

채널 나가기

info

target

채널 정보 가져오기

tg_draft — 임시 메시지

action

Required args

Description

save

target, text

임시 저장

list

—

모든 임시 메시지 목록

delete

target

임시 메시지 삭제


4. 환경 변수

Variable

Default

Description

TG_API_ID

0

Telegram API ID (my.telegram.org에서)

TG_API_HASH

""

Telegram API Hash

TG_SESSION_DIR

~/.telegram-mcp/sessions

세션 파일 위치


5. 안전

  • 속도 제한: 보내기 작업은 분당 5회로 제한됩니다. 읽기 작업은 무제한입니다.

  • FloodWaitError 자동 재시도: 필요한 시간만큼 대기합니다 (최대 5분).

  • 세션 파일: 로컬 전용, git에 커밋되지 않습니다.

  • 2FA 지원: 2단계 인증 계정 완전 지원.


6. MCP 리소스

  • tg://version — 서버 버전

  • tg://session/status — 로그인 상태


라이선스

MIT

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Connects AI agents to Telegram via the official TDLib library, enabling tools like getting user info, listing dialogs, and searching messages.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with Telegram Bot API for sending messages, photos, editing messages, answering callbacks, and fetching updates.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents to interact with a user's Telegram account: list chats, read history, search, and send messages through Telegram's MTProto API.
    1
    MIT