Xadeus-QQ-MCP
Xadeus-QQ-MCP
Built by a 15-year-old developer, based on Amadeus-QQ-MCP.
QQ MCP (Model Context Protocol) Server — connects to QQ via NapCatQQ (OneBot v11), giving AI agents direct control over QQ (send/receive messages, group management, auto-wake on incoming messages, and more).
Features
Feature | Description |
Auto-Wake | Incoming QQ messages matching rules trigger the AI agent window automatically. Supports any client — opencode, Cursor, Claude Desktop, Windsurf — configure via |
Dedup Lock | Prevents duplicate wake during processing. Unlock manually when done |
Persistent Rules | Wake rules saved to |
|
|
Group Moderation | Mute, unmute, kick, set card, send notices |
File Sending | Send any file from URL to QQ groups/private chats |
Message Recall | Recall bot-sent messages |
Timer Scheduler | Cron or interval-based timed wake |
One-Click Setup | Auto-detect NapCat, configure ports, update agent configs |
Related MCP server: Amadeus-QQ-MCP
Architecture
QQ ←→ NapCat (OneBot v11)
↓ WebSocket :3001 / HTTP :3000
Xadeus-QQ-MCP (Python MCP Server)
↓ MCP Protocol
AI Agent (opencode / Cursor / Claude / ...)Quick Start
Prerequisites
Install NapCat.Shell and QQ
Configure NapCat OneBot v11 (WebSocket :3001, HTTP :3000)
One-Click Setup (Recommended)
.\quickstart.ps1 -qq 你的QQ号Auto-detects NapCat, configures HTTP:3000/WS:3001, creates Python venv, writes QQ_OVERRIDE, generates NapCat start script, sets window wake patterns.
Options:
.\quickstart.ps1 -qq 123456 -windowTitle "OC,opencode,cmd" # Custom window patterns
.\quickstart.ps1 -configFile config.json # Config file mode
.\quickstart.ps1 -restart # Kill stale MCP + wait for recoveryDefault -windowTitle: OC,opencode,Administrator,cmd,管理员
(comma-separated substrings, matched case-insensitively against window titles)
Also available via Python:
python setup.py # Interactive mode
python setup.py --qq YOUR_QQ --fast # Non-interactiveManual Setup
git clone https://github.com/mouse114514/Xadeus-QQ-MCP
cd Xadeus-QQ-MCP
# Virtual env
uv venv
uv sync
# Start MCP Server
uv run python -m qq_agent_mcp --qq YOUR_QQConfigure Your AI Agent
Important: The
QQ_OVERRIDEenvironment variable before starting your agent:$env:QQ_OVERRIDE = "YOUR_QQ"Or edit the fallback value in
src/qq_agent_mcp/__main__.py:QQ_OVERRIDE.This works around AI agents that cache the MCP command at startup and ignore subsequent config file changes.
opencode — edit ~/.config/opencode/opencode.json:
{
"mcp": {
"qq-agent": {
"type": "local",
"command": [
"C:\\path\\.venv\\Scripts\\python.exe",
"-m", "qq_agent_mcp",
"--qq", "YOUR_QQ"
],
"enabled": true,
"timeout": 120000
}
}
}Cursor / Claude Desktop / Windsurf — edit the respective MCP config file:
{
"mcpServers": {
"qq-agent": {
"command": "C:\\path\\.venv\\Scripts\\python.exe",
"args": ["-m", "qq_agent_mcp", "--qq", "YOUR_QQ"],
"enabled": true
}
}
}Or just run python setup.py — it detects all installed agents automatically.
Wake Target Configuration
Use set_wake_config to bind to any AI agent window:
{
"window_title_patterns": ["opencode", "cursor", "claude"],
"focus_shortcut": "ctrl+l"
}Saved to src/qq_agent_mcp/wake_config.json.
MCP Tools
Messaging
Tool | Description |
| Send text with segmentation and optional reply wait |
| Send image (base64) |
| Send voice (base64) |
| Wait for new messages |
Context & History
Tool | Description |
| Recent messages for a group/friend |
| Batch query multiple targets |
| Render chat screenshot (iPhone dark mode style) |
| Archive old messages to summary |
Wake System
Tool | Description |
| Add auto-wake rule (group/private + keywords) |
| Remove wake rule by index |
| List all wake rules |
| Lock/unlock wake to prevent duplicates |
| Enable/disable all or specific rules |
| Configure target window and focus shortcut |
| View current wake config |
| Debug wake monitor state |
Group Management
Tool | Description |
| List joined groups |
| List group members |
| Get member details |
| Mute a member |
| Unmute a member |
| Kick a member |
| Set group nickname |
| Send group notice |
System
Tool | Description |
| Check QQ and NapCat connection |
| List friends |
| Recall bot message |
| Send file from URL |
| Add scheduled wake (cron/interval) |
| Remove timer |
| List all timers |
Known Issues & Workarounds
Issue | Cause | Workaround |
MCP won't restart after crash/kill | opencode has restart backoff; after ~3 kills it stops retrying | Restart your AI agent, or |
Two MCP processes always appear | FastMCP stdio transport spawns parent+child chain | Named mutex prevents duplicate typing (built-in fix) |
Config changes ignored after editing | opencode caches MCP command at startup | Restart opencode, or use |
Wake message doubled | Both processes try to type simultaneously | Fixed via Windows named mutex ( |
Messages from same QQ ignored |
| Removed in current build |
Wake won't fire even with matching rule | Lock ( | Auto-unlock after 5 min, or call |
Restart Helper
.\quickstart.ps1 -restartKills stale MCP processes and waits for auto-restart. If the agent doesn't recover, it prompts you to restart manually.
Tech Stack
Python 3.12+ (httpx, aiohttp, FastMCP)
NapCat.Shell (QQ + OneBot v11)
Win32 API (ctypes) — window activation, keyboard simulation
License
Based on Amadeus-QQ-MCP (MIT License).
中文版
Xadeus-QQ-MCP
由一位 15 岁高中生基于 Amadeus-QQ-MCP 深度优化改造。
QQ MCP (Model Context Protocol) Server — 通过 NapCatQQ (OneBot v11) 协议连接 QQ,为 AI Agent 提供直接操控 QQ 的能力(收发消息、管理群聊、自动唤醒等)。
功能亮点
功能 | 说明 |
Auto-Wake 自动唤醒 | QQ 消息匹配规则时自动激活 AI Agent 窗口。支持任意客户端 — opencode、Cursor、Claude Desktop、Windsurf,通过 |
Pending 防重复锁 | 唤醒后自动上锁,防止重复唤醒。Agent 干完活后手动解锁 |
规则持久化 | 唤醒规则自动保存到 |
|
|
群管理 | 禁言、解禁、踢人、设名片、发公告 |
文件发送 | 从 URL 下载文件发送到群/私聊 |
消息撤回 | 撤回机器人发送的消息 |
定时任务 | 支持 cron 和间隔两种模式的定时唤醒 |
一键配置 | 自动检测 NapCat、端口、多 Agent 配置 |
架构
QQ ←→ NapCat (OneBot v11)
↓ WebSocket :3001 / HTTP :3000
Xadeus-QQ-MCP (Python MCP Server)
↓ MCP 协议
AI Agent (opencode / Cursor / Claude / ...)快速开始
前置条件
安装 NapCat.Shell 和 QQ
配置 NapCat OneBot v11 (WebSocket :3001, HTTP :3000)
一键配置(推荐)
.\quickstart.ps1 -qq 你的QQ号自动检测 NapCat、配置 HTTP:3000/WS:3001、创建 Python venv、 写入 QQ_OVERRIDE、生成 NapCat 启动脚本、设置窗口唤醒匹配模式。
选项:
.\quickstart.ps1 -qq 123456 -windowTitle "OC,opencode,cmd" # 自定义窗口匹配模式
.\quickstart.ps1 -configFile config.json # 配置文件模式
.\quickstart.ps1 -restart # 杀死残留 MCP + 等待恢复默认 -windowTitle:OC,opencode,Administrator,cmd,管理员
(逗号分隔,不区分大小写子串匹配窗口标题)
Python 版(功能相同):
python setup.py # 交互模式
python setup.py --qq 你的QQ号 --fast # 静默模式手动安装
git clone https://github.com/mouse114514/Xadeus-QQ-MCP
cd Xadeus-QQ-MCP
# 虚拟环境
uv venv
uv sync
# 启动 MCP Server
uv run python -m qq_agent_mcp --qq 你的QQ号配置 AI Agent
重要:AI Agent 配置中的
$env:QQ_OVERRIDE = "你的QQ号"或直接修改
src/qq_agent_mcp/__main__.py:QQ_OVERRIDE的默认值。这样做是为了绕过 AI Agent 缓存 MCP 命令的问题—— Agent 只在启动时读取一次配置,改配置文件不生效。
opencode — 编辑 ~/.config/opencode/opencode.json:
{
"mcp": {
"qq-agent": {
"type": "local",
"command": [
"C:\\path\\.venv\\Scripts\\python.exe",
"-m", "qq_agent_mcp",
"--qq", "你的QQ号"
],
"enabled": true,
"timeout": 120000
}
}
}Cursor / Claude Desktop / Windsurf — 编辑对应 MCP 配置文件:
{
"mcpServers": {
"qq-agent": {
"command": "C:\\path\\.venv\\Scripts\\python.exe",
"args": ["-m", "qq_agent_mcp", "--qq", "你的QQ号"],
"enabled": true
}
}
}运行 python setup.py 可自动检测并配置所有已安装的 Agent。
唤醒目标配置
通过 set_wake_config 配置窗口标题,即可绑定到任意 AI Agent:
{
"window_title_patterns": ["opencode", "cursor", "claude"],
"focus_shortcut": "ctrl+l"
}配置文件保存在 src/qq_agent_mcp/wake_config.json。
MCP 工具一览
消息
工具 | 说明 |
| 发文本消息,支持分段、等待回复 |
| 发图片 |
| 发语音 |
| 等待新消息 |
上下文
工具 | 说明 |
| 查看最近消息 |
| 批量查看多目标 |
| 生成聊天截图(iPhone 深色模式) |
| 压缩缓存 |
唤醒系统
工具 | 说明 |
| 添加唤醒规则(群/私聊 + 关键词) |
| 删除唤醒规则 |
| 查看所有规则 |
| 锁定/解锁唤醒 |
| 启用/禁用规则 |
| 配置窗口标题和快捷键 |
| 查看唤醒配置 |
| 诊断唤醒状态 |
群管理
工具 | 说明 |
| 群列表 |
| 群成员列表 |
| 成员详情 |
| 禁言 |
| 解禁 |
| 踢出 |
| 设群名片 |
| 发群公告 |
系统
工具 | 说明 |
| 检查连接状态 |
| 好友列表 |
| 撤回消息 |
| 发送文件 |
| 添加定时任务 |
| 删除定时任务 |
| 查看所有定时任务 |
已知问题
问题 | 原因 | 解决方法 |
MCP 被杀后无法自启 | opencode 有重启退避策略 | 重启 AI Agent,或 |
总是有两个 MCP 进程 | FastMCP stdio 产生父子进程链 | 内置命名互斥锁解决重复打字 |
改 opencode.json 不生效 | opencode 启动时缓存命令 | 重启 opencode,或用 |
唤醒消息出现双倍字符 | 两个进程同时打字 | 已修复(Windows 命名互斥锁) |
同 QQ 号发消息不唤醒 |
| 已修复(移除 context.py/wake.py 过滤) |
匹配规则但不唤醒 | 唤醒锁 ( | 5 分钟自动解锁,或调用 |
重启助手
.\quickstart.ps1 -restart杀死残留 MCP 进程并等待自动重启。如果 Agent 不自动恢复,会提示你手动重启。
技术栈
Python 3.12+ (httpx, aiohttp, FastMCP)
NapCat.Shell (QQ + OneBot v11)
Win32 API (ctypes) — 窗口激活、键盘模拟
授权
基于 Amadeus-QQ-MCP (MIT License) 改造。
Maintenance
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/mouse114514/Xadeus-QQ-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server