Skip to main content
Glama

napcat-mcp

把 NapCat / OneBot v11 的接口暴露成 MCP 工具,并附带一个 LLM 驱动的智能 QQ 机器人(SmartBot)。

  • MCP Server:把 45 个 OneBot 动作注册为 MCP 工具,供任意 MCP 客户端调用。

  • SmartBot:常驻 QQ 机器人。支持多群/私聊、长期记忆、知识库、工具调用、 原生联网搜索、多模态识图、主动插话、权限(主人/管理)分级、审批加群/加好友、 群文件操作、联通云盘(沃盘)集成等。

环境要求

  • Node.js ≥ 21(依赖内置 node:sqlite;开发使用 Node 24 验证)

  • 一个可用的 NapCat(或其它 OneBot v11 实现),开放 WebSocket 服务

  • (可选)DeepSeek 或任意 OpenAI / Anthropic 兼容的 LLM API

Related MCP server: astral-bridge

快速开始

npm install

# 配置
cp config.example.json config.json
# 编辑 config.json:填 wsUrl / token、bot.owner、bot.admins、bot.llm.apiKey 等
# 人设:复制 persona.example.txt 为 persona.txt 并改写,config.json 用 bot.personaFile 指向它

npm run build

# 只跑 MCP server(stdio)
npm run start

# 跑 QQ 机器人
npm run start:bot:bg     # 后台启动(pid → .bot.pid,日志 → logs/bot.out.log)
npm run status:bot
npm run stop:bot

目录结构

src/
  index.ts            MCP server 入口
  config.ts log.ts onebot.ts download.ts types.ts
  tools/              MCP 工具(definitions / common / index)
  integrations/wopan/ 联通云盘纯 TS 实现(crypto / client / fs)
  bot/
    index.ts          SmartBot
    prompt.ts         系统提示词组装
    tools.ts          工具聚合入口
    tools/            支撑模块(requests / risk / own / images / catalog)
    toolsets/         按域拆分的工具集(admin/social/web/... + extended + wopan)
    brain.ts memory.ts kb.ts search.ts web.ts ssrf.ts fsaccess.ts fileserver.ts ...
docs/                 接口覆盖情况等文档
scripts/bot-bg.mjs    后台启停脚本

说明

  • 工具系统:bot 侧工具按风险分级(low / manage / high),执行前在代码里强制校验; 工具较多时启用「工具字典」懒加载——模型用 list_tools 查目录、describe_tool 查用法, 避免每轮把全部工具 schema 塞进上下文(见 bot.lazyTools)。

  • 记忆 / 知识库:SQLite(memory.db / kb.db),全局时间线 + 摘要压缩 + 用户画像。

  • 联通云盘:src/integrations/wopan 为纯 TypeScript 实现(协议参考见 docs/wopan/)。 配置在 config.json 的 bot.wopan:

    "wopan": { "enabled": true, "tokenFile": "vendor/wo_cnpan/tokens.json", "space": "personal" }

    tokenFile 也可用环境变量 WOPAN_TOKENS 指定;space 可选 personal/family(家庭云再配 familyId)。 相关工具全部 risk=high(仅主人可用);enabled:false 则不注册这些工具。

  • 隐私:config.json、persona.txt、*.db、logs/、downloads/、sandbox/、 .private/ 均已在 .gitignore 中,不会入库。

License

MIT

免责声明

  • 本项目仅供个人学习与技术研究使用。

  • 联通云盘(沃盘)部分基于对公开 Web 端的协议分析,请遵守对应服务条款,不要用于批量抓取、 规避限速或其它违规用途;其中的 CLIENT_ID / CLIENT_SECRET 为官方客户端常量。

  • 使用本机器人时请遵守所在平台规则,并注意不要泄露他人隐私数据。

Available Tools

45 tools
delete_msg撤回消息A
Destructive

按 message_id 撤回一条自己发送的或具有管理权限的消息。

Inputs: message_id (required).

fetch_custom_face获取收藏表情包B
Read-only

获取机器人QQ收藏(自定义)的表情包图片URL列表,可用于再发送。

Inputs: count.

get_essence_msg_list获取群精华消息A
Read-only

获取指定群的全部精华消息列表。

Inputs: group_id (required).

get_file获取文件信息B
Read-only

获取一般文件消息的详细信息及本地/下载路径。

Inputs: file (required), file_id.

get_forward_msg获取合并转发内容B
Read-only

获取合并转发(聊天记录)的具体内容。

Inputs: id (required), message_id.

get_friend_list获取好友列表A
Read-only

获取机器人好友列表(好友QQ号、昵称等)。

Inputs: no named parameters.

get_friend_msg_history获取好友历史消息A
Read-only

获取与指定好友/临时会话的历史消息。

Inputs: user_id (required), count, message_seq.

get_group_files_by_folder获取群文件夹文件B
Read-only

获取群指定文件夹下的文件与子文件夹列表。

Inputs: group_id (required), folder_id (required), file_count.

get_group_file_system_info获取群文件系统信息A
Read-only

获取群文件空间大小与使用情况。

Inputs: group_id (required).

get_group_file_url获取群文件下载链接B
Read-only

根据 file_id 获取群文件的下载URL。

Inputs: file_id (required), group_id (required).

get_group_honor_info获取群荣誉B
Read-only

获取群荣誉(龙王、群聊之火等)信息。

Inputs: type (required), group_id (required).

get_group_info获取群信息B
Read-only

获取指定群的详细信息(群名、人数、群主、公告等)。

Inputs: group_id (required).

get_group_list获取群列表A
Read-only

获取机器人加入的全部群聊列表(群号、群名等)。

Inputs: no named parameters.

get_group_member_info获取群成员信息A
Read-only

获取指定群内某成员的详细信息(昵称、群名片、角色、等级等)。

Inputs: user_id (required), group_id (required), no_cache.

get_group_member_list获取群成员列表A
Read-only

获取指定群的全部成员列表(成员较多时返回会较大)。

Inputs: group_id (required), no_cache.

get_group_msg_history获取群历史消息A
Read-only

获取指定群的聊天记录(从 message_seq 起始,最多 count 条)。

Inputs: group_id (required), count, message_seq, reverse_order.

get_group_mute_list获取群禁言列表A
Read-only

获取群内被禁言成员的列表(NapCat 专用动作 get_group_shut_list)。

Inputs: group_id (required).

get_group_notice_list获取群公告B
Read-only

获取指定群的公告列表(NapCat 专用动作 _get_group_notice)。

Inputs: group_id (required).

get_group_root_files获取群根目录文件列表B
Read-only

获取群文件根目录下的文件和文件夹列表。

Inputs: group_id (required), file_count.

get_group_system_msg获取群系统消息B
Read-only

获取入群申请/邀请等群系统通知。

Inputs: count.

get_image获取图片信息A
Read-only

根据图片 file 标识获取图片详细信息(含下载URL/路径)。

Inputs: file (required), file_id.

get_login_info获取登录号信息A
Read-only

获取机器人(当前登录QQ)的信息。

Inputs: no named parameters.

get_msg获取消息详情A
Read-only

根据 message_id 获取单条消息的详细信息。

Inputs: message_id (required).

get_online_clients获取在线客户端A
Read-only

获取当前登录QQ的在线客户端列表。

Inputs: no named parameters.

get_record获取语音信息A
Read-only

根据语音 file 标识获取语音文件信息,可转换格式。

Inputs: file (required), out_format.

get_status获取运行状态A
Read-only

查机器人运行状态(是否在线/正常)。若要查 NapCat 版本用 get_version_info;查自身登录QQ用 get_login_info。

Inputs: no named parameters.

get_stranger_info获取陌生人信息A
Read-only

获取指定QQ用户的信息(无需为好友)。

Inputs: user_id (required), no_cache.

get_version_info获取版本信息A
Read-only

获取NapCat/OneBot版本信息。

Inputs: no named parameters.

send_group_forward_msg发送合并转发A

以合并转发(聊天记录)形式向群发送若干条由 send_forward_node 构建的节点消息。nodes 为 node 消息段数组,每节点 {type:'node',data:{uin,nickname,content}}。

Inputs: message (required), group_id (required).

send_group_msg发送群消息A

向指定群发送一条消息。message 可以是纯文本字符串,或 OneBot 消息段数组。要发图片用 [{type:'image',data:{file:'<本地路径或http(s)链接>'}}];QQ表情用 {type:'face',data:{id:'<表情id>'}};@人用 {type:'at',data:{qq:'<qq或all>'}}。

Inputs: message (required), group_id (required), auto_escape.

send_group_notice发送群公告A

在群内发布公告。需要机器人具有发公告权限(NapCat 专用动作 _send_group_notice)。

Inputs: content (required), group_id (required), type, image, +2 more.

send_group_sign群打卡B

机器人以签到卡片形式在群内打卡。

Inputs: group_id (required).

send_like点赞A

给指定QQ点赞(次数建议1-10)。

Inputs: user_id (required), times.

send_msg发送消息(通用)A

通用发送消息。需通过 message_type 指定 private/group,再提供对应的 user_id 或 group_id。message 可为纯文本或消息段数组。

Inputs: message (required), message_type (required), user_id, group_id, +1 more.

send_poke戳一戳A

在群聊或私聊中发送戳一戳。群聊需同时给 group_id 和 user_id。

Inputs: user_id (required), group_id.

send_private_msg发送私聊消息A

向指定QQ好友发送一条私聊消息。message 可为纯文本字符串或 OneBot 消息段数组(详见 send_group_msg)。

Inputs: message (required), user_id (required), auto_escape.

set_essence_msg设为精华消息A

将群内一条消息设为精华消息。需要群管理权限。

Inputs: message_id (required).

set_group_admin设置群管理员B

设置或取消指定群成员的管理员权限。

Inputs: user_id (required), group_id (required), enable.

set_group_ban群成员禁言A

禁言群内指定成员,duration 单位为秒。

Inputs: user_id (required), duration (required), group_id (required).

set_group_card设置群名片B

设置指定群成员在本群的群名片(昵称)。

Inputs: user_id (required), group_id (required), card.

set_group_kick踢出群成员A
Destructive

将指定成员移出群聊(踢人)。需要机器人在该群且有群管理权限。

Inputs: user_id (required), group_id (required), reject_add_request.

set_group_leave退出群聊A
Destructive

让机器人主动退出指定群。不可逆,确认后再调用。

Inputs: group_id (required), is_dismiss.

set_group_name设置群名称A

修改指定群的群名称。需要机器人在该群且有相应权限(通常群主/管理);只影响目标群。

Inputs: group_id (required), group_name (required).

set_group_remark设置群备注A

为指定群设置「我」在本群的备注名(只改机器人自己看到的群名,不改真实群名)。

Inputs: remark (required), group_id (required).

set_group_whole_ban全员禁言A

开启或关闭指定群的全员禁言(enable=true 开、false 关)。需要群管理权限。

Inputs: group_id (required), enable.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 45 tools

    Disambiguation4/5

    Most tools map to a distinct resource and action, with clear descriptions separating group management, messaging, and file operations. The main overlap is send_msg versus send_group_msg/send_private_msg, but the descriptions explicitly clarify the difference.

    Naming Consistency5/5

    Tool names follow a consistent verb_noun pattern: set_group_*, get_group_*, send_*, get_*. Minor deviations like fetch_custom_face do not break the overall predictability.

    Tool Count2/5

    45 tools is a very large surface for an MCP server. While the domain is broad, the number will create significant selection overhead for agents, and many related operations could be consolidated or grouped.

    Completeness4/5

    Core messaging, group management, member info, and file retrieval are well covered. Notable gaps include no way to approve/reject group requests fetched via get_group_system_msg and no file upload capability, but these are not fatal for typical bot workflows.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      Not graded
      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
      26
      MIT
    • A
      license
      B
      quality
      C
      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
      2
      Apache 2.0
    • F
      license
      A
      quality
      B
      maintenance
      Enables MCP hosts to bridge with QQ via NapCat/OneBot 11, allowing whitelisted private messages to reach an agent with full tool access while group mentions are answered by a sandboxed pure LLM without system access.
      8
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to control and monitor QQ accounts through the NapCatQQ OneBot 11 protocol, covering private/group messaging, forwards, group administration, file transfer, OCR, friend and profile management, and real-time message listening. It also handles QR-code login, hot-switching between multiple QQ accounts, and one-click self-check, deployment, and updates.
      20
      6
      MIT