Skip to main content
Glama
Telegram Contacts MCP Server

Telegram Contacts MCP Server

by RubenSorrow

Telegram Contacts MCP Server

A Model Context Protocol (MCP) server that allows AI assistants like Claude to manage and categorize your Telegram contacts. Built specifically for crypto/DeFi professionals to organize their network.

Features

  • Connect to Telegram: Authenticate and access your Telegram account

  • Load Contacts: Batch-load contacts with progress tracking

  • View Chat History: Read recent messages with any contact

  • Categorize Contacts: Assign professional categories (Founder, Developer, Investor, etc.)

  • Bulk Operations: Categorize multiple contacts at once

  • Export to Excel: Generate organized spreadsheets of categorized contacts

  • Search: Find contacts by name, username, or bio

Related MCP server: telegram-mcp-server

Prerequisites

  • Python 3.11 or higher

  • A Telegram account

  • Telegram API credentials (API ID and API Hash)

Installation

1. Clone the Repository

git clone https://github.com/yourusername/telegram-contacts-mcp.git
cd telegram-contacts-mcp
python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Get Telegram API Credentials

  1. Go to https://my.telegram.org/apps

  2. Log in with your phone number

  3. Create a new application (if you don't have one)

  4. Copy your API ID and API Hash

5. Configure Environment Variables

Copy the example environment file and add your credentials:

cp .env.example .env

Edit .env with your credentials:

TELEGRAM_API_ID=your_api_id_here
TELEGRAM_API_HASH=your_api_hash_here

6. First-Time Authentication

Run the server once to authenticate with Telegram:

python telegram_mcp_server.py

You'll be prompted to:

  1. Enter your phone number

  2. Enter the verification code sent to your Telegram

This creates a session file (telegram_session.session) that stores your authentication.

Usage with Claude Code

Configure Claude Code

Add this MCP server to your Claude Code configuration. Edit your Claude Code settings to include:

{
  "mcpServers": {
    "telegram-contacts": {
      "command": "python",
      "args": ["path/to/telegram_mcp_server.py"]
    }
  }
}

Or if using uv:

{
  "mcpServers": {
    "telegram-contacts": {
      "command": "uv",
      "args": ["run", "path/to/telegram_mcp_server.py"]
    }
  }
}

Available Tools

Once configured, Claude can use these tools:

Tool

Description

telegram_connect

Connect to Telegram

telegram_disconnect

Disconnect from Telegram

telegram_count_contacts

Count total contacts

telegram_load_contacts_batch

Load contacts in batches

telegram_get_all_contacts

List all cached contacts

telegram_get_chat_messages

View chat history with a contact

telegram_search_contacts

Search contacts by name/username/bio

telegram_categorize_contact

Assign category to a contact

telegram_bulk_categorize

Categorize multiple contacts at once

telegram_export_to_excel

Export categorized contacts to Excel

telegram_get_uncategorized

List contacts without categories

telegram_get_contact_details

View full details of a contact

telegram_get_valid_categories

List all valid categories

Example Workflow

  1. Connect: "Connect to my Telegram account"

  2. Count: "How many contacts do I have?"

  3. Load: "Load the first 30 contacts"

  4. Categorize: "Categorize John Doe as a Founder at Acme Protocol"

  5. Export: "Export all categorized contacts to Excel"

Contact Categories

The following categories are available for organizing contacts:

  • Founder/Co-founder - Project founders

  • Developer - Developers, CTOs, tech leads

  • Investor/VC - VCs, angel investors, family offices

  • Business Development - BD, partnerships, sales

  • Auditor/Security - Security researchers, auditors

  • Marketing/Growth - Marketing, growth, PR

  • Exchange/CEX/DEX - Exchange employees

  • Community Manager - Community managers, moderators

  • Infrastructure/Node Operator - Validators, node operators

  • Market Maker - Market makers, liquidity providers

  • Media/KOL/Influencer - Crypto journalists, influencers

  • Researcher/Analyst - Researchers, analysts

  • Trader - Professional traders

  • Designer/Product - UI/UX designers, product managers

  • Legal/Compliance - Lawyers, compliance officers

Running Tests

Install test dependencies:

pip install -r test/requirements-test.txt

Run the test suite:

pytest

Run with coverage:

pytest --cov=telegram_mcp_server --cov-report=html

Project Structure

telegram-contacts-mcp/
├── telegram_mcp_server.py   # Main MCP server
├── requirements.txt         # Production dependencies
├── .env.example            # Environment template
├── .gitignore              # Git ignore rules
├── pytest.ini              # Pytest configuration
├── .coveragerc             # Coverage configuration
├── README.md               # This file
└── test/                   # Test suite
    ├── conftest.py         # Test fixtures
    ├── requirements-test.txt
    └── test_*.py           # Test modules

Security Notes

  • Never commit your .env file - It contains your API credentials

  • Never commit telegram_session.session - It contains your authentication

  • Never commit exported Excel files - They contain your personal contacts

All these files are already in .gitignore.

Troubleshooting

"Session not authorized" Error

Run the server directly to re-authenticate:

python telegram_mcp_server.py

"API_ID or API_HASH not found" Error

Make sure your .env file exists and contains valid credentials.

Connection Issues

Telegram may rate-limit requests. The server includes delays between API calls, but if you're loading many contacts, consider using smaller batch sizes.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      F
      maintenance
      Enables Claude to interact with your Telegram account, including reading messages, searching conversations, and sending messages.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to interact with Telegram, including listing chats, reading messages, sending messages, searching, and managing contacts.
      1
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants like Claude to read, search, and send messages through your personal Telegram account via MCP tools.
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables AI assistants to read Telegram conversations, search messages, retrieve chat context, resolve recipients, and send messages with delivery status.
      1
      -