Skip to main content
Glama
kakao-channel

kakao-channel

kakao-channel-chat

非官方(Unofficial)。 这是对 Kakao 频道管理中心(Business Chat,内部代号 "rocket")的未公开内部 API 进行逆向工程的产物。它不是 Kakao 的官方产品,规格可能在毫无预告的情况下发生变化并失效,也可能与 Kakao 的服务条款相冲突。请仅在自动化你自己拥有的频道场景下使用,并自行承担责任。 详见 DISCLAIMER。

复用已登录的浏览器会话,用代码操作 Kakao 频道聊天的 Node 工具包。
提供 API 库 · CLI · MCP 服务器 三种形式。外部运行时依赖只有 MCP SDK 一个(库/CLI 为零依赖)。

支持的功能

  • ✅ 登录状态检查 & token 无限续期(会话不中断)

  • ✅ 聊天室列表 + 区分已读/未读 + 聊天室 deep link

  • ✅ 会话记录查询(区分我方/客户/系统消息,提取链接)

  • ✅ 标记已读、发送消息(回复)

  • ✅ 实时监控新消息(SSE / 轮询)

  • ✅ 常驻守护进程(token 自动续期 + keepalive + 监控 + 可选自动回复)

  • ✅ MCP 服务器 — 可在 Claude、Cursor 等工具中使用

Related MCP server: line-desktop-mcp

工作原理

Kakao 频道聊天 API(business.kakao.com/api/*)只用一个 kakao 登录 Cookie 就能认证(无需额外 token)。本工具会获取有效的 kakao 会话 Cookie,然后直接调用该 API。逆向得到的完整端点可参见 API.md。

3 种认证方式(任选一种)

1) macOS + Chrome 自动提取(默认)
只需 Chrome 已登录目标频道,即可从 Cookie 存储中自动提取会话(含 HttpOnly Cookie)。无需额外配置。

node bin/kbc.js whoami   # 그냥 실행하면 됨(macOS)

2) Playwright 自行登录(跨平台 · 无头 · 推荐)
工具会用自己的浏览器完成登录并持有会话,因此非 macOS 环境、服务器环境也能运行。2FA/验证码只在首次自行处理一次。

npm i playwright && npx playwright install chromium
node bin/kbc.js login          # 브라우저가 열림 → 카카오 로그인(2FA 포함) → 세션 저장
KBC_AUTH=playwright node bin/kbc.js whoami   # 이후 저장된 세션 사용
  • 会话保存在 .kbc-auth/state.json(已加入 gitignore)中。daemon 会定期访问站点,让会话保持不过期。

  • 自动重新登录:当会话完全失效,守护进程会检测到 → 重新弹出登录浏览器(只需手动处理 2FA)→ 自动恢复。无头/服务器环境下重新运行 kbc login,守护进程会自动捕获新会话并恢复,无需重启。

3) 直接注入 Cookie

KBC_COOKIE="_kawlt=...; _kawltea=...; ..." node bin/kbc.js whoami

(从浏览器 DevTools → Network → 复制请求的 Cookie 头,或使用 “Copy as cURL”)

系统要求

  • Node ≥ 20.12

  • 如果要使用 Cookie 自动提取:需要 macOS + Google Chrome 已登录目标 Kakao 频道(内部使用 /usr/bin/sqlite3 + Keychain,macOS 自带)

  • 其他 OS/浏览器:可通过手动注入 KBC_COOKIE 使用

安装

git clone <this-repo>
cd kakao-channel-chat
npm install
cp .env.example .env      # KBC_PROFILE_ID 채워넣기

.env:

KBC_PROFILE_ID=_XXXXX     # 관리자센터 URL business.kakao.com/{이값}/chats 의 {이값}
# KBC_CHROME_PROFILE=Default   # (선택) 여러 Chrome 프로필 중 지정. 미지정 시 자동탐지
# KBC_COOKIE=...               # (선택) 쿠키 자동추출 대신 직접 주입

CLI 用法

node bin/kbc.js whoami                 # 로그인 상태
node bin/kbc.js token                  # 토큰 리프레시(무한로그인 확인)
node bin/kbc.js unread                 # 안읽은 방 (링크 포함)
node bin/kbc.js list --json            # 전체 방 (JSON)
node bin/kbc.js logs <chatId>          # 대화내역
node bin/kbc.js mark <chatId>          # 읽음 처리
node bin/kbc.js send <chatId> "<text>" --yes    # ⚠️ 실제 발송
node bin/kbc.js watch --poll           # 실시간 감시
node bin/kbc.js daemon                  # 상시 구동(토큰 무한유지+감시)
node bin/kbc.js daemon --autoreply      # + 안읽은 새 메시지 자동응답

库的使用

import { KakaoBizChatClient } from './src/client.js';

const c = new KakaoBizChatClient({ profileId: process.env.KBC_PROFILE_ID }); // 쿠키 자동
if ((await c.checkLogin()).loggedIn) {
  const unread = await c.getUnreadChats();               // is_read=false 방들 (+ .link)
  const { items } = await c.getChatlogs(unread[0].id);   // 대화내역 (.from = 'us'|'customer')
  await c.markRead(unread[0].id);
  // await c.sendText(unread[0].id, '답장');              // ⚠️ 실발송
}

实时监控:

import { watchPolling, watchSSE } from './src/push.js';
watchPolling(c, { onMessage: ({ chat }) => console.log('새 메시지', chat.name, chat.last_message) });

MCP 服务器

在 Claude Code / Claude Desktop / Cursor 等工具的 MCP 配置中添加:

{
  "mcpServers": {
    "kakao-channel": {
      "command": "node",
      "args": ["/absolute/path/to/kakao-channel-chat/src/mcp-server.js"],
      "env": {
        "KBC_PROFILE_ID": "_XXXXX",
        "KBC_CHROME_PROFILE": "Default"
      }
    }
  }
}

暴露的工具:kakao_login_status、kakao_unread_count、kakao_list_chats、kakao_get_chat、kakao_get_messages、kakao_mark_read。
发送工具(kakao_send_message)出于安全考虑默认禁用 — 在 env 中添加 KBC_MCP_ALLOW_SEND=1 即可启用。

持续运行(PM2)

在 token 过期前自动续期,并保持会话 不断线 地运行。崩溃时自动重启:

npm i -g pm2
pm2 start ecosystem.config.cjs
pm2 logs kakao-channel
pm2 save && pm2 startup   # 부팅 시 자동 실행

macOS 的 Cookie 自动提取方式需要 Chrome 一直保持登录状态才能无限维持会话(Chrome 会自动刷新 Cookie)。如果要在完全没有 Chrome 的情况下以 headless 方式运行,则需要定期更新 KBC_COOKIE,或自行实现 Kakao SSO refresh 流程。

安全 / 注意事项

  • 详细安全策略见 SECURITY.md — 明确说明会访问什么、不会访问什么。

  • Cookie、token 仅存在于本地,不会发送到外部(通讯仅限 Kakao 域名)。

  • 绝对不要把 .env 和 Cookie 提交到仓库(.gitignore 已包含)。

  • send/--autoreply 会立即发送给真实客户。

  • 请仅用于您自己拥有的频道。

许可证

MIT — LICENSE。Kakao/KakaoTalk 是 Kakao Corp. 的商标,与本项目无关。

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

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to interact with user-approved KakaoTalk chat rooms locally on Windows, including reading recent messages, observing new events, and sending replies only after explicit user approval, with sending and auto-reply disabled by default.
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables automation of LINE messaging through the Chrome extension, allowing users to check status, list chat rooms, read messages, search conversations, and manage login sessions via MCP tools.
      6
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables MCP clients on macOS to read local KakaoTalk chats and messages directly from the app's encrypted database, and to send messages through the app's Accessibility interface with explicit confirmation. It works offline against the installed desktop app without contacting Kakao's servers.
      3
      9 npm
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to control KakaoTalk PC through the Win32 API, sending, mentioning, and reading messages, opening chat rooms, sending images, extracting shared links, and monitoring rooms for keywords. It supports health checks, bulk sends to multiple rooms, and exact room-name matching for reliable automation.
      MIT