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

alpha-claude-telegram-ask-user

v0.1.0

Published

MCP bridge: Claude Agent SDK ask_user tool -> Telegram inline keyboards

Readme

alpha-claude-telegram-ask-user

Alpha / WIP -- bugs expected. MCP bridge that lets Claude agents ask Telegram users questions via inline keyboards.

Extracted from ClaudeClaw. No other open source project does this bridge: Claude Agent SDK ask_user tool -> Telegram inline keyboard -> promise resolves with user's answer.

How it works

Claude agent calls ask_user tool
  -> MCP server sends Telegram message with inline keyboard
  -> User taps a button (or types free text via ForceReply)
  -> Bot callback_query handler resolves the promise
  -> Claude agent receives the answer and continues

5-minute timeout built in. Double-tap protection. Multi-select support.

Install

npm install alpha-claude-telegram-ask-user
# peer dep -- pick one:
npm install grammy        # grammY adapter
npm install telegraf      # Telegraf adapter

Usage (grammY)

import { Bot } from 'grammy'
import { query } from '@anthropic-ai/claude-agent-sdk'
import {
  createTelegramUiServer,
  createGrammyAdapter,
} from 'alpha-claude-telegram-ask-user'

const bot = new Bot(process.env.TELEGRAM_BOT_TOKEN!)
const chatId = process.env.TELEGRAM_CHAT_ID!

const adapter = createGrammyAdapter(bot)
const ui = createTelegramUiServer(adapter, chatId, { timeoutMs: 5 * 60_000 })

// Hook into callback queries (button taps)
bot.on('callback_query:data', async (ctx) => {
  await ui.handleCallbackQuery(ctx.callbackQuery.data, ctx.callbackQuery.id)
})

// Hook into ForceReply (free text via "Autre")
bot.on('message:text', async (ctx) => {
  if (ctx.message.reply_to_message) {
    await ui.handleForceReplyMessage(ctx.message.reply_to_message.message_id, ctx.message.text)
  }
})

bot.start()

// Attach MCP server to Claude queries
const response = await query({
  prompt: 'Ask the user what they prefer.',
  options: {
    model: 'claude-opus-4-5',
    mcpServers: { 'telegram-ui': ui.server },
  },
})

// Cleanup on exit
process.on('SIGTERM', () => ui.destroy())

Usage (Telegraf)

import { Telegraf } from 'telegraf'
import { createTelegramUiServer, createTelegrafAdapter } from 'alpha-claude-telegram-ask-user'

const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN!)
const adapter = createTelegrafAdapter(bot)
const ui = createTelegramUiServer(adapter, chatId)

bot.on('callback_query', async (ctx) => {
  if ('data' in ctx.callbackQuery) {
    await ui.handleCallbackQuery(ctx.callbackQuery.data, ctx.callbackQuery.id)
  }
})

Custom store (Redis, SQLite, etc.)

Inject your own store via the store option:

import type { QuestionStore, PendingQuestion } from 'alpha-claude-telegram-ask-user'

class MyStore implements QuestionStore {
  async set(id: string, q: PendingQuestion) { /* ... */ }
  async get(id: string) { /* ... */ }
  async delete(id: string) { /* ... */ }
  async getExpired(now: number) { /* ... */ }
}

const ui = createTelegramUiServer(adapter, chatId, { store: new MyStore() })

See examples/custom-store-example.ts for a full SQLite implementation.

API

createTelegramUiServer(adapter, chatId, options?)

Returns { server, handleCallbackQuery, handleForceReplyMessage, destroy }.

  • server -- MCP server to pass to query({ options: { mcpServers } })
  • handleCallbackQuery(data, callbackQueryId) -- call from your bot's callback_query handler
  • handleForceReplyMessage(replyToMessageId, text) -- call from your bot's message handler
  • destroy() -- clears timers and in-flight state on shutdown

createGrammyAdapter(bot) / createTelegrafAdapter(bot)

Wrap your bot instance into the framework-agnostic TelegramAdapter.

InMemoryStore

Default store. No external dependencies.

Known issues (alpha)

  • One createTelegramUiServer instance per process (module-level resolver maps)
  • ask_user blocks the agent turn until the user responds (or timeout)
  • No built-in retry on Telegram API errors
  • ForceReply ("Autre") requires the user to explicitly reply to the bot message

License

MIT