MCP 通信器(Telegram)是一个 MCP 服务器,可借助 Telegram 与用户展开通信。它提供了丰富工具,能通过 Telegram 机器人与用户互动,涵盖提问、发送通知、共享文件以及创建项目存档等功能。
在使用 MCP 通信器(Telegram)之前,你需要满足以下先决条件:
npm install -g mcp-communicator-telegram
npx mcptelegram
获取你的 Telegram 聊天 ID:
npx mcptelegram-chatid
git clone https://github.com/qpd-v/mcp-communicator-telegram.git
cd mcp-communicator-telegram
npm install
创建 Telegram 机器人并获取令牌。
使用以下命令获取你的 Telegram 聊天 ID:
npx mcptelegram-chatid
将服务器添加到 MCP 设置文件中:
在 config/mcp.json 中添加以下内容:
{
"telegram": {
"botToken": "your_bot_token",
"chatId": "your_chat_id"
}
}
通过 Telegram 提问。
{
"type": "question",
"question": "你的问题?",
"messageId": "string" // 可选的Telegram消息ID,用于关联答案
}
await useMCP({
server: 'telegram',
tool: 'ask_user',
arguments: {
question: '你最喜欢的颜色是什么?',
messageId: '12345'
}
});
通过 Telegram 发送通知。
{
"type": "notification",
"message": "你的消息。",
"messageId": "string" // 可选的Telegram消息ID
}
await useMCP({
server: 'telegram',
tool: 'notify_user',
arguments: {
message: '系统状态已更新。',
messageId: '67890'
}
});
通过 Telegram 发送文件。
{
"type": "file",
"filePath": "path/to/file", // 可选的文件路径,默认为当前目录
"message": "可选的消息内容"
}
await useMCP({
server: 'telegram',
tool: 'send_file',
arguments: {}
});
await useMCP({
server: 'telegram',
tool: 'send_file',
arguments: {
filePath: '/path/to/your/file'
}
});
创建并发送项目的 ZIP 文件。
{
"type": "directory",
"directory": "string" // 可选的目录路径,默认为当前工作目录
}
await useMCP({
server: 'telegram',
tool: 'zip_project',
arguments: {}
});
await useMCP({
server: 'telegram',
tool: 'zip_project',
arguments: {
directory: '/path/to/specific/directory'
}
});