Skip to main content
Glama

qq-onebot-mcp

A lightweight MCP server that connects QQ (NapCat / OneBot 11) to any MCP host (DSH, Claude, Cursor...). Zero npm dependencies, pure Node.js ≥ 20, using only the built-in WebSocket.

  • Private chat (whitelisted owner) → messages go to inbox → host agent processes (full tool permissions) → replies.

  • Group chat @bot (whitelisted groups) → bridge answers directly via LLM API, without going through the agent, without touching the local machine.

Architecture

QQ 老大 ──私聊──▶ NapCat(QQ小号) ──OneBot11/WS:3001──▶ qq-mcp-server.mjs ──MCP──▶ 宿主 agent
                                                                   ▲
                                                              (inbox / 工具)

Layer

File

Responsibility

Access

NapCat

QQ protocol → OneBot 11 (WS 3001)

Bridge

qq-mcp-server.mjs

MCP server: tools, exclusive lock, inbox

Bridge

onebot.mjs

OneBot WS client (zero dependencies)

Bridge

group_llm.mjs

Group chat pure LLM direct replies

Wake-up

qq-listener.mjs

Resident listener + host session injection (optional closed loop)

Control

qqctl.mjs

Process lifecycle (start/stop/status)

Related MCP server: NapCat MCP Server

Quick Start

  1. NapCat: Install it and log in with a QQ alt account, enable OneBot WS (default ws://127.0.0.1:3001).

  2. Configuration: cp .env.example .env, fill in QQ_BOT, QQ_ALLOWED_SENDERS (optionally add LLM_API_KEY to enable group chat).

  3. Register MCP: Point the host to qq-mcp-server.mjs (stdio). For DSH use the dsh-bundle/ template, see INSTALL-DSH.md.

  4. Go online: Tell the agent "get on QQ" → follow skills/qq-online/SKILL.md to attach → wait for messages → reply.

Environment variable

Required

Description

QQ_BOT

Bot QQ number

QQ_ALLOWED_SENDERS

Private chat whitelist, comma-separated

ONEBOT_WS_URL

NapCat WS address (default ws://127.0.0.1:3001)

QQ_ALLOWED_GROUPS

Static group whitelist (empty = dynamic)

LLM_API_KEY / LLM_BASE_URL / LLM_MODEL

For group chat direct replies

.env is git-ignored, never commit it.

MCP Tools

Tool

Description

qq_attach / qq_detach

Exclusive acquire / release the bridge (file lock, cross-host; auto-preempts crash leftovers)

qq_wait_inbox

Blocking wait for private messages (zero polling, recommended for loops)

qq_poll_inbox

Fetch inbox (with optional timeout)

qq_send

Reply to the current conversation partner (whitelist only)

qq_status

Bridge status

qq_get_agent_profile

Read AGENTS.md role settings

Standby mode: the server does not connect to NapCat on startup; it connects only on qq_attach and disconnects on qq_detach — zero resource usage.

Fully Automatic Closed Loop (Optional)

To have QQ messages automatically wake the agent (no need to say "get online" every time): run qq-listener.mjs as a separate process:

DSH_API_URL=http://127.0.0.1:3080 DSH_SESSION_ID=<session-id> \
  node qq-listener.mjs <tag> <workdir> 0
QQ 消息 → 监听器(wait_inbox) → 写入 <workdir>/inbox/ + POST http://127.0.0.1:3080/api/session.prompt
                                                                        │
                                                    agent 自动醒来处理 → <workdir>/outbox/ → qq_send 回复
  • The listener stays resident independently of the agent session; session.prompt (mode: queue) injects messages into the host session to trigger a turn.

  • Replies go to <workdir>/outbox/*.json ({type:"send", message}), and the listener sends them (connects directly to OneBot WS when there is no chat target).

  • Graceful stop: write stop.flag in <workdir>.

⚠️ session.prompt has no authentication and is loopback-only; use it only in a trusted local environment.

Security

  • Private chat: whitelist only; unknown private messages are discarded.

  • Group chat: pure LLM, never touches local files/commands.

  • qq_send can only reply to the current conversation partner (within the whitelist).

  • When a whitelisted user pulls the bot into a group → auto-whitelist and announce.

Personalization

Edit AGENTS.md (persona/responsibilities/security boundaries); the bridge reloads it every session, no restart needed.

Local privacy (e.g., important personal relationships) can go in data/ (git-ignored) and be referenced from AGENTS_MD — never uploaded to GitHub.

Dynamic Session Discovery (Closed Loop)

The listener no longer hardcodes DSH_SESSION_ID: on each incoming message it first calls session.list to find a running session whose title contains 上号/QQ/布卡, and falls back to env if none is found. This way the closed loop still works after the "get online" session is replaced or reopened.

Development

npm test   # 全部入口语法检查

Files

├── qq-mcp-server.mjs   # MCP server(主入口)
├── onebot.mjs          # OneBot WS 客户端
├── group_llm.mjs       # 群聊 LLM 直答
├── bridge.mjs          # 独立触发桥(无 MCP 宿主)
├── bridge-acp.mjs      # ACP 连接器(持久 DSH 会话)
├── qq-listener.mjs     # 闭环监听器
├── qqctl.mjs           # 进程控制
├── dsh-bundle/         # DSH profile bundle 模板
├── skills/qq-online/   # 「上QQ号」技能
├── INSTALL-DSH.md      # 新用户自装指南
└── .env.example        # 配置模板

License

MIT

F
license - not found
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    An MCP server that enables AI clients to send and receive QQ messages through NapCatQQ (OneBot v11) for both private and group chats. It supports message context management, real-time WebSocket listening, and human-like typing simulation.
    7
    24
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables interaction with NapCat QQ bot APIs for group management, messaging, and system operations. Supports HTTP and WebSocket modes with security features like group restrictions and readonly mode.
    4
  • A
    license
    Not graded
    quality
    C
    maintenance
    A MCP server that exposes QQ bot capabilities over Streamable HTTP, enabling clients to query bot status, read group and friend info, fetch chat history, and send group/private text messages.
    2
    MIT
  • A
    license
    B
    quality
    B
    maintenance
    Connects QQ via NapCat OneBot v11 to an Astral Code app-server, exposing MCP tools for sending messages, files, images, and fetching conversation history.
    10
    1
    Apache 2.0

View all related MCP servers

Related MCP Connectors

  • Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.

  • MCP server for AI dialogue using various LLM models via AceDataCloud

  • MCP server for QPost — lets AI agents publish video and image posts to YouTube, TikTok, Instagram.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HUliangwei/qq-onebot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server