Control QQ via NapCatQQ (OneBot v11): send and receive messages, manage groups and wake the agent on incoming messages.

التثبيت

خطوات التثبيت موجودة في التوثيق أدناه. التوثيق

التوثيق

مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.

المحتويات
  1. Xadeus-QQ-MCP
  2. Features
  3. Architecture
  4. Quick Start
  5. MCP Tools
  6. Known Issues & Workarounds
  7. Tech Stack
  8. License
  9. Xadeus-QQ-MCP
  10. 功能亮点
  11. 架构
  12. 快速开始
  13. MCP 工具一览
  14. 已知问题
  15. 技术栈
  16. 授权

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

FeatureDescription
Auto-WakeIncoming QQ messages matching rules trigger the AI agent window automatically. Cross-platform — Windows (keybd_event), macOS (osascript+pbcopy), Linux (xdotool+xclip). Supports any client — opencode, Cursor, Claude Desktop, Windsurf — configure via set_wake_config
Dedup LockPrevents duplicate wake during processing. Unlock manually when done
Persistent RulesWake rules saved to wake_rules.json, auto-loaded on restart
wait_for_reply Built-insend_message waits for reply by default
Group ModerationMute, unmute, kick, set card, send notices
File SendingSend any file from URL to QQ groups/private chats
Message RecallRecall bot-sent messages
Timer SchedulerCron or interval-based timed wake
One-Click SetupAuto-detect NapCat, configure ports, update agent configs

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
  1. Install NapCat.Shell and QQ
  2. Configure NapCat OneBot v11 (WebSocket :3001, HTTP :3000)
.\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 recovery

Default -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-interactive
Manual 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_QQ
Configure Your AI Agent

Important: The --qq argument passed by your AI agent config is ignored at runtime. Instead, set QQ_OVERRIDE environment 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
ToolDescription
send_messageSend text with segmentation and optional reply wait
send_imageSend image (base64)
send_voiceSend voice (base64)
wait_for_replyWait for new messages
Context & History
ToolDescription
get_recent_contextRecent messages for a group/friend
batch_get_recent_contextBatch query multiple targets
screenshot_chatRender chat screenshot (iPhone dark mode style)
compress_contextArchive old messages to summary
Wake System
ToolDescription
add_wake_ruleAdd auto-wake rule (group/private + keywords)
remove_wake_ruleRemove wake rule by index
list_wake_rulesList all wake rules
set_wake_pendingLock/unlock wake to prevent duplicates
set_wake_enabledEnable/disable all or specific rules
set_wake_configConfigure target window and focus shortcut
get_wake_configView current wake config
diagnose_wakeDebug wake monitor state
Group Management
ToolDescription
get_group_listList joined groups
get_group_member_listList group members
get_group_member_infoGet member details
mute_memberMute a member
unmute_memberUnmute a member
kick_memberKick a member
set_member_cardSet group nickname
send_group_noticeSend group notice
System
ToolDescription
check_statusCheck QQ and NapCat connection
get_friend_listList friends
recall_messageRecall bot message
send_fileSend file from URL
add_timerAdd scheduled wake (cron/interval)
remove_timerRemove timer
list_timersList all timers

Known Issues & Workarounds

IssueCauseWorkaround
MCP won't restart after crash/killopencode has restart backoff; after ~3 kills it stops retryingRestart your AI agent, or .\quickstart.ps1 -restart
Two MCP processes always appearFastMCP stdio transport spawns parent+child chainNamed mutex prevents duplicate typing (built-in fix)
Config changes ignored after editing opencode.jsonopencode caches MCP command at startupRestart opencode, or use QQ_OVERRIDE env var
Wake message doubledBoth processes try to type simultaneouslyFixed via Windows named mutex (Local\XadeusQQ_MCP_WakeTyping)
Messages from same QQ ignoredis_self filter in context.py and wake.pyRemoved in current build
Wake won't fire even with matching ruleLock (_pending) held from previous wakeAuto-unlock after 5 min, or call set_wake_pending(false)
Restart Helper
.\quickstart.ps1 -restart

Kills 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 窗口。跨平台 — Windows (keybd_event)、macOS (osascript+pbcopy)、Linux (xdotool+xclip)。支持任意客户端 — opencode、Cursor、Claude Desktop、Windsurf,通过 set_wake_config 配置窗口标题即可
Pending 防重复锁唤醒后自动上锁,防止重复唤醒。Agent 干完活后手动解锁
规则持久化唤醒规则自动保存到 wake_rules.json,重启后自动加载
wait_for_reply 一体化send_message 默认自动等待回复
群管理禁言、解禁、踢人、设名片、发公告
文件发送从 URL 下载文件发送到群/私聊
消息撤回撤回机器人发送的消息
定时任务支持 cron 和间隔两种模式的定时唤醒
一键配置自动检测 NapCat、端口、多 Agent 配置

架构

QQ ←→ NapCat (OneBot v11)
          ↓  WebSocket :3001 / HTTP :3000
    Xadeus-QQ-MCP (Python MCP Server)
          ↓  MCP 协议
    AI Agent (opencode / Cursor / Claude / ...)

快速开始

前置条件
  1. 安装 NapCat.Shell 和 QQ
  2. 配置 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 配置中的 --qq 参数在运行时会被忽略。 正确方式:启动 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 工具一览

消息
工具说明
send_message发文本消息,支持分段、等待回复
send_image发图片
send_voice发语音
wait_for_reply等待新消息
上下文
工具说明
get_recent_context查看最近消息
batch_get_recent_context批量查看多目标
screenshot_chat生成聊天截图(iPhone 深色模式)
compress_context压缩缓存
唤醒系统
工具说明
add_wake_rule添加唤醒规则(群/私聊 + 关键词)
remove_wake_rule删除唤醒规则
list_wake_rules查看所有规则
set_wake_pending锁定/解锁唤醒
set_wake_enabled启用/禁用规则
set_wake_config配置窗口标题和快捷键
get_wake_config查看唤醒配置
diagnose_wake诊断唤醒状态
群管理
工具说明
get_group_list群列表
get_group_member_list群成员列表
get_group_member_info成员详情
mute_member禁言
unmute_member解禁
kick_member踢出
set_member_card设群名片
send_group_notice发群公告
系统
工具说明
check_status检查连接状态
get_friend_list好友列表
recall_message撤回消息
send_file发送文件
add_timer添加定时任务
remove_timer删除定时任务
list_timers查看所有定时任务

已知问题

问题原因解决方法
MCP 被杀后无法自启opencode 有重启退避策略重启 AI Agent,或 .\quickstart.ps1 -restart
总是有两个 MCP 进程FastMCP stdio 产生父子进程链内置命名互斥锁解决重复打字
改 opencode.json 不生效opencode 启动时缓存命令重启 opencode,或用 QQ_OVERRIDE 环境变量
唤醒消息出现双倍字符两个进程同时打字已修复(Windows 命名互斥锁)
同 QQ 号发消息不唤醒is_self 过滤器阻挡已修复(移除 context.py/wake.py 过滤)
匹配规则但不唤醒唤醒锁 (_pending) 未释放5 分钟自动解锁,或调用 set_wake_pending(false)
重启助手
.\quickstart.ps1 -restart

杀死残留 MCP 进程并等待自动重启。如果 Agent 不自动恢复,会提示你手动重启。

技术栈

  • Python 3.12+ (httpx, aiohttp, FastMCP)
  • NapCat.Shell (QQ + OneBot v11)
  • Win32 API (ctypes) — 窗口激活、键盘模拟

授权

基于 Amadeus-QQ-MCP (MIT License) 改造。

الأسئلة الشائعة

ما هو Xadeus QQ MCP؟

Control QQ via NapCatQQ (OneBot v11): send and receive messages, manage groups and wake the agent on incoming messages.

كيف أثبّت Xadeus QQ MCP؟

اتبع خطوات التثبيت في توثيقه المعروض في هذه الصفحة وفي مستودعه.

هل Xadeus QQ MCP مفتوح المصدر؟

نعم. شيفرته متاحة على GitHub بترخيص MIT.

من يصون Xadeus QQ MCP؟

ينشره mouse114514. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.

من القوائم المجتمعية awesome-mcp-servers ومستودع المشروع على GitHub. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.