npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@benjapieres/mcp-telegram-listener

v2.0.0

Published

Minimal MCP server to listen and respond to Telegram messages

Readme

@benjapieres/mcp-telegram-listener

Minimal MCP server that listens to Telegram messages and exposes them to AI agents. No third-party AI sampling, no magic — you control what happens with each message.

Setup

1. Create a Telegram bot

Talk to @BotFather and get your bot token.

2. Get your chat/group ID

Add the bot to your group, send a message, and check the logs — the chat ID will appear there. Group IDs are negative numbers (e.g. -1001234567890).

3. Configure your MCP client

Add this to your Claude Desktop or Claude Code MCP config:

{
  "mcpServers": {
    "telegram": {
      "command": "npx",
      "args": ["-y", "@benjapieres/mcp-telegram-listener"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "your_bot_token",
        "ALLOWED_CHAT_IDS": "-1001234567890,-1009876543210",
        "REQUIRE_MENTION": "false",
        "QUEUE_PATH": "/path/to/your/workspace/.meta/telegram-queue.json"
      }
    }
  }
}

Multiple bots (e.g. separate bots for different groups):

{
  "mcpServers": {
    "telegram-pm": {
      "command": "npx",
      "args": ["-y", "@benjapieres/mcp-telegram-listener"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "pm_bot_token",
        "ALLOWED_CHAT_IDS": "-1001234567890",
        "REQUIRE_MENTION": "false",
        "QUEUE_PATH": "/workspace/.meta/telegram-pm-queue.json"
      }
    },
    "telegram-leads": {
      "command": "npx",
      "args": ["-y", "@benjapieres/mcp-telegram-listener"],
      "env": {
        "TELEGRAM_BOT_TOKEN": "leads_bot_token",
        "ALLOWED_CHAT_IDS": "-1009876543210",
        "REQUIRE_MENTION": "false",
        "QUEUE_PATH": "/workspace/.meta/telegram-leads-queue.json"
      }
    }
  }
}

Environment variables

| Variable | Required | Default | Description | |---|---|---|---| | TELEGRAM_BOT_TOKEN | Yes | — | Bot token from @BotFather | | ALLOWED_CHAT_IDS | No | (all) | Comma-separated chat/group IDs. Empty = accept all | | REQUIRE_MENTION | No | true | Set to false to receive all group messages without needing a bot mention | | QUEUE_PATH | No | ./telegram-queue.json | Absolute path for queue persistence across restarts |

Tools

| Tool | Description | |---|---| | get_messages | Returns pending messages and removes them from the queue | | peek_messages | Shows how many messages are queued without consuming them | | send_message | Sends a text message to a Telegram chat | | get_bot_info | Returns bot info and current configuration — useful to verify setup |

get_messages

Returns pending messages with sender info, username, chat ID, topic ID, reply_to ID, and timestamp.

| Parameter | Type | Required | Description | |---|---|---|---| | chat_id | string | No | Filter messages from a specific chat. Messages from other chats stay in queue. | | max_messages | number | No | Maximum messages to return (1–100). Default: all pending. | | format | string | No | "text" (default, human-readable) or "json" (structured array). |

peek_messages

Returns the current queue size without consuming messages. Also starts polling if not already running.

| Parameter | Type | Required | Description | |---|---|---|---| | chat_id | string | No | Count only messages from a specific chat. |

send_message

| Parameter | Type | Required | Description | |---|---|---|---| | text | string | Yes | Message text to send | | chat_id | string | No | Target chat ID. Defaults to first ALLOWED_CHAT_IDS | | topic_id | number | No | Topic/thread ID for forum supergroups (message_thread_id) | | reply_to_message_id | number | No | Reply to a specific message within the chat | | parse_mode | string | No | HTML, Markdown, or MarkdownV2 |

get_bot_info

No parameters. Returns bot id, username, name, and current config (allowed chats, require_mention, queue path).

How it works

Telegram  ←→  Bot (polling)  ←→  MCP server (stdio)  ←→  AI agent
  • Polling starts lazily on the first get_messages or peek_messages call — not at initialization. This avoids token conflicts when multiple processes use the same bot.
  • Incoming messages are stored in a FIFO queue (max 200)
  • The agent reads messages on demand via get_messages
  • Queue is persisted to disk and survives process restarts
  • Everything runs locally — no external servers needed

License

MIT