qq-onebot-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@qq-onebot-mcp 上QQ号"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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 |
| MCP server: tools, exclusive lock, inbox |
Bridge |
| OneBot WS client (zero dependencies) |
Bridge |
| Group chat pure LLM direct replies |
Wake-up |
| Resident listener + host session injection (optional closed loop) |
Control |
| Process lifecycle (start/stop/status) |
Related MCP server: NapCat MCP Server
Quick Start
NapCat: Install it and log in with a QQ alt account, enable OneBot WS (default
ws://127.0.0.1:3001).Configuration:
cp .env.example .env, fill inQQ_BOT,QQ_ALLOWED_SENDERS(optionally addLLM_API_KEYto enable group chat).Register MCP: Point the host to
qq-mcp-server.mjs(stdio). For DSH use thedsh-bundle/template, seeINSTALL-DSH.md.Go online: Tell the agent "get on QQ" → follow
skills/qq-online/SKILL.mdto attach → wait for messages → reply.
Environment variable | Required | Description |
| ✅ | Bot QQ number |
| ✅ | Private chat whitelist, comma-separated |
| NapCat WS address (default | |
| Static group whitelist (empty = dynamic) | |
| For group chat direct replies |
.envis git-ignored, never commit it.
MCP Tools
Tool | Description |
| Exclusive acquire / release the bridge (file lock, cross-host; auto-preempts crash leftovers) |
| Blocking wait for private messages (zero polling, recommended for loops) |
| Fetch inbox (with optional timeout) |
| Reply to the current conversation partner (whitelist only) |
| Bridge status |
| 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> 0QQ 消息 → 监听器(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.flagin<workdir>.
⚠️
session.prompthas 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_sendcan 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 fromAGENTS_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
Available Tools
8 toolsqq_attachA
Claims the QQ bridge for THIS conversation (exclusive). Pass a unique tag (e.g. your session id) to identify the owner. Fails if another conversation already claimed it. Call once when you start handling QQ.
Inputs: tag (required).
qq_detachA
Releases the QQ bridge. Only the current owner (matching tag) can release; others get an error. Call when done or on /布卡换碟 new-conversation.
Inputs: tag (required).
qq_get_agent_profileA
Get the AGENTS.md role profile (personality, duties, security boundaries) that defines how this QQ bridge agent should behave. Load it once and treat it as your system prompt while chatting through QQ. Path overridable via AGENTS_MD env.
Inputs: no named parameters.
qq_poll_inboxA
Fetch private messages received by the bot (whitelisted owner only). Returns immediately if new messages; else waits up to timeoutMs (max 30000, batch max 50).
Inputs: timeoutMs.
qq_sendA
Send a private message to the current chat user (the whitelisted owner from inbox). message is the content.
Inputs: message (required).
qq_statusA
Query bridge status: connection, bot QQ, private whitelist, group whitelist, inbox count.
Inputs: no named parameters.
qq_take_disc_changeA
Check if the owner requested a DISC CHANGE (换碟) in private chat. Returns true once if a new-conversation signal is pending (connector should start a fresh session), false otherwise. Poll after handling inbox messages.
Inputs: no named parameters.
qq_wait_inboxA
BLOCK until new private messages arrive (zero polling/cost while waiting). Returns immediately when messages arrive; or after maxWaitMs. Call in a loop to idle efficiently waiting for QQ messages.
Inputs: maxWaitMs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose: sending, receiving (with two variants for context), status, profile retrieval, disc-change signal, and lifecycle management (attach/detach). No overlap causes ambiguity.
All tools follow the consistent `qq_` prefix followed by an action verb (send, poll, wait, status, get, take, attach, detach). Naming is uniform, snake_case, and predictable.
With 8 tools, the server is well-scoped for a QQ bridge: it covers messaging, inbox handling, status, profile, and session control without excess. This is within the ideal 3-15 tool range.
Core private-message workflows and lifecycle are covered: send, receive, status, claim/release, and disc-change. Missing group-message tools and whitelist management, though these may be intentionally out of scope for a private-owner bridge.
Related MCP Connectors
Telegram bridge for your MCP-compatible agent. Bidirectional, no LLM in our stack.
Human-input bridge for AI agents with voice-first answer links, MCP tools, and HTTP APIs.
MCP server for AI dialogue using various LLM models via AceDataCloud
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseAqualityNot gradedmaintenanceAn 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.726MIT
- FlicenseCqualityDmaintenanceEnables 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.574-
- AlicenseNot gradedqualityDmaintenanceA 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.3MIT
- AlicenseBqualityCmaintenanceConnects QQ via NapCat OneBot v11 to an Astral Code app-server, exposing MCP tools for sending messages, files, images, and fetching conversation history.102Apache 2.0