Files
cs-note/claude-code-best/docs/features/channels.md
T

97 lines
3.0 KiB
Markdown
Raw Normal View History

2026-06-09 23:15:17 +08:00
---
tags: [channels, mcp, 微信, 飞书, telegram, discord, 外部事件]
create time: 2026-06-09 22:30
---
2026-06-08 23:08:57 +08:00
2026-06-09 23:15:17 +08:00
# Channels — 外部频道消息接入
2026-06-08 23:08:57 +08:00
## 概述
2026-06-09 23:15:17 +08:00
Channel 是一个 MCP 服务器,它将外部事件推送到你运行中的 Claude Code 会话中,以便 Claude 可以在你不在终端时做出反应。支持 Telegram、Discord、iMessage、飞书、微信等平台。
2026-06-08 23:08:57 +08:00
2026-06-09 23:15:17 +08:00
> [!info]
> 启动参数:`--channels` / `--dangerously-load-development-channels`
> 状态:已解除 feature flag 和 OAuth 限制,可直接使用
2026-06-08 23:08:57 +08:00
2026-06-09 23:15:17 +08:00
## 正文
2026-06-08 23:08:57 +08:00
2026-06-09 23:15:17 +08:00
### 快速开始
2026-06-08 23:08:57 +08:00
```bash
# 启用频道监听(plugin 格式)
ccb --channels plugin:feishu@claude-code-feishu-channel
# 启用内置微信 channel
ccb weixin login
ccb --channels plugin:weixin@builtin
# 启用频道监听(server 格式)
ccb --channels server:my-slack-bridge
# 同时启用多个频道
ccb --channels plugin:feishu@claude-code-feishu-channel --channels server:discord-bot
# 开发模式(跳过 allowlist 检查,用于测试自定义 channel)
ccb --dangerously-load-development-channels server:my-custom-channel
```
2026-06-09 23:15:17 +08:00
### 支持的 Channel
2026-06-08 23:08:57 +08:00
| Channel | 说明 | 来源 |
|---------|------|------|
| **Telegram** | 官方 Telegram Bot 集成 | `/plugin install telegram@claude-plugins-official` |
| **Discord** | 官方 Discord Bot 集成 | `/plugin install discord@claude-plugins-official` |
| **iMessage** | macOS 原生消息 | `/plugin install imessage@claude-plugins-official` |
| **飞书 (Feishu/Lark)** | 双向消息、群组聊天、文件附件 | `/plugin install feishu@claude-code-feishu-channel` |
| **微信 (WeChat)** | 内置 channel,支持扫码登录、双向消息、附件透传 | `ccb weixin login` + `ccb --channels plugin:weixin@builtin` |
2026-06-09 23:15:17 +08:00
### 微信内置 Channel
2026-06-08 23:08:57 +08:00
2026-06-09 23:15:17 +08:00
#### 登录
2026-06-08 23:08:57 +08:00
```bash
ccb weixin login
```
已登录状态可清除:
```bash
ccb weixin login clear
```
2026-06-09 23:15:17 +08:00
#### 会话启用
2026-06-08 23:08:57 +08:00
```bash
ccb --channels plugin:weixin@builtin
```
2026-06-09 23:15:17 +08:00
#### 配对授权
2026-06-08 23:08:57 +08:00
首次收到未授权微信用户消息时,weixin channel 会回一条 6 位 pairing code。运营侧可在终端执行:
```bash
ccb weixin access pair <code>
```
确认后,该微信用户后续消息才会进入 Claude Code 会话。
2026-06-09 23:15:17 +08:00
### 相关文件
2026-06-08 23:08:57 +08:00
| 文件 | 职责 |
|------|------|
| `src/services/mcp/channelNotification.ts` | 频道 gate 逻辑、消息包装 |
| `src/services/mcp/channelAllowlist.ts` | 频道开关(已默认开启) |
| `src/services/mcp/useManageMCPConnections.ts` | MCP 连接管理中的频道注册 |
| `src/components/LogoV2/ChannelsNotice.tsx` | 启动时频道状态提示 |
| `src/main.tsx` | `--channels` 参数解析 |
| `src/interactiveHelpers.tsx` | Dev channels 确认对话框 |
2026-06-09 23:15:17 +08:00
### 参考链接
2026-06-08 23:08:57 +08:00
- [官方 Channels 文档](https://code.claude.com/docs/zh-CN/channels) — 完整使用说明、安全性、Enterprise 控制
- [飞书 Channel 插件](https://github.com/whobot-ai/claude-code-feishu-channel) — 安装配置教程、MCP 工具、Skill 命令参考
2026-06-09 23:15:17 +08:00
## 关联笔记
- [[all-features-guide]]