Skip to content

feat(mcp): 🚀 消息推送配置工具 queryMessagePush/manageMessagePush(事件+消息类型订阅 · appid 多会话透传 · 幂等乐观锁) - #949

Merged
binggg merged 10 commits into
mainfrom
feat/virtual-payment-mcp
Aug 24, 2026
Merged

feat(mcp): 🚀 消息推送配置工具 queryMessagePush/manageMessagePush(事件+消息类型订阅 · appid 多会话透传 · 幂等乐观锁)#949
binggg merged 10 commits into
mainfrom
feat/virtual-payment-mcp

Conversation

@binggg

@binggg binggg commented Aug 20, 2026

Copy link
Copy Markdown
Member

概述

新增消息推送配置 MCP 工具 queryMessagePush / manageMessagePush(通用能力,虚拟支付 7 事件为默认场景),支持 事件类消息类型 订阅的批量/幂等管理,Agent 可一次性完成任意合法事件的订阅、启停、移除。

功能清单

核心工具

  • queryMessagePushlist(当前配置 + version 乐观锁)、listSupportedEvents(合法事件/消息类型约束)
  • manageMessagePushsubscribe / unsubscribe / setEnable,写操作带 confirm="yes" 确认保护(未确认返回 CONFIRM_REQUIRED 摘要)

订阅能力

  • 事件类(默认 msg_type="event"):任意合法事件(user_enter_tempsessionxpay_* 虚拟支付 7 事件等),subscribe 缺省时默认订阅虚拟支付 7 事件
  • 消息类型msg_type="text"|"image"|"voice"|"video"|"miniprogrampage",2026-08-24 新增):管理消息类型条目(event 固定空串),缺省 "event" 完全向后兼容
  • 声明式幂等 merge(对齐 kubectl apply):重复执行收敛到同一状态,无变化返回 NO_CHANGE 不发起写请求
  • 一事一函数:同事件绑定到其他函数时自动重绑(保留原 enable 状态),新事件默认启用

传输与可靠性

  • CloudApiRequestFn 领域语义适配层:复用 cloudBaseOptions.requestFn(service/action/version/region/payload),与 databaseNoSQL/functions 同模式,包内零 URL、零微信细节
  • appid 可选字段透传(非破坏性增量):多小程序会话时宿主可选择对应登录态,缺省注入方无感知
  • version 乐观锁:全量覆盖写 + version 校验,冲突优先结构化判断(ret=80208),errmsg 正则仅兜底
  • 默认不启用:进 AVAILABLE_PLUGINS 不在 DEFAULT_PLUGINS,用户/微信仓库 pluginsEnabled 手动启用

测试

  • tsc --noEmit 通过
  • vitest run src/tools/msg-push.test.ts40/40 通过(schema/幂等/version 冲突/rebound 保留 enable/appid 透传/消息类型订阅)
  • 真实 E2E(mcp/scripts/test-with-ticket.cjs):mock + 真实微信 IDE ticket(azhi 环境)全过——subscribe 幂等 / setEnable / unsubscribe / appid 透传 / 全量快照还原(测试不污染线上配置)

配套文档(skill)

  • config/source/skills/miniprogram-development/:新增 references/message-push-customer-service.md(消息推送配置、客服自动回复、云函数接收推送、日志入口,wxide CLI 优先、不暴露底层),全部 references 分层中文化(SKILL.md description 双语、正文英文),版本 2.28.1 → 2.32.0
  • Claude mirror(config/.claude/skills/miniprogram-development/)同步

变更文件

  • mcp/src/tools/msg-push.ts(新):queryMessagePush / manageMessagePush 实现(含 msg_type 消息类型支持)
  • mcp/src/tools/msg-push.test.ts(新):40 个单测
  • mcp/src/types.ts:CloudApiRequestFn 可选 appid 字段 + MsgPush 相关类型
  • mcp/src/server.ts:AVAILABLE_PLUGINS 注册 msg-push
  • mcp/src/index.ts:类型导出
  • mcp/scripts/test-with-ticket.cjs:消息推送 E2E 测试组(_i 参数 / qbase 直连 CGI / 全量快照还原 / msg_type 用例)
  • config/source/skills/miniprogram-development/**:skill 文档(沉淀 + 中文化)
  • config/source/editor-config/compat-baseline.json:advisory 刷新

后续(不在本 PR)

  • 微信侧消费(spec specs/virtual-payment-mcp/design.md §5/§6 已定):main 升级 @cloudbase/cloudbase-mcp 后经 EXPOSED_TOOL_NAME 暴露 cloud_msg_push_query / cloud_msg_push_manage,验证旧工具无 break change 后提 PR 给微信侧参考(ATO 9109db6b)
  • 发版时机由 Booker 另行确认(本 PR 只开发不发版)

Comment thread mcp/scripts/test-with-ticket.cjs Fixed
t and others added 2 commits August 24, 2026 15:08
…equestFn 适配、全量快照还原)

- makeTicketUrl 加 _i={service}~{action} + test_env + clientversion(与微信开发者工具抓包一致,否则 42001)
- getCosAuth 同步传 service/action
- msg-push 测试组:传输层改注入 cloudBaseOptions.requestFn(#949 重构后工具不再读 pluginOptions.msgPush.requestFn),mock 用适配器包装、真实用 qbase 直连 CGI(不走 apihttpagent)
- 真实模式全量快照还原:subscribe 会 rebound 改绑已有回调 + 强制 enable=true,unsubscribe/setEnable 无法恢复,结束用测试前 config 快照覆盖写(先读当前 version 避免乐观锁冲突)
- 已实测:mock 全过;真实模式干净基线跑通且配置完全还原(enable=false + 原回调不变)
… prefer ret=80208 for VERSION_CONFLICT (dc0eaaf9)

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread mcp/scripts/test-with-ticket.cjs Fixed
Comment thread mcp/scripts/test-with-ticket.cjs Fixed
t and others added 5 commits August 24, 2026 18:18
…/...) (dc0eaaf9)

Co-authored-by: Cursor <cursoragent@cursor.com>
…nce (dc0eaaf9)

Fold wxide-CLI-first message push and customer-service auto-reply guidance
into miniprogram-development; mark cloud_msg_push_* and CLI logs as 9109db6b gaps.

Co-authored-by: Cursor <cursoragent@cursor.com>
…c0eaaf9)

Accept new miniprogram-development message-push-customer-service surfaces
into compat-baseline after skill docs landing.

Co-authored-by: Cursor <cursoragent@cursor.com>
…elopment skill (dc0eaaf9)

Translate references to Chinese narrative while keeping API/command names in
English; bilingual SKILL.md description; English body; refresh compat baseline.

Co-authored-by: Cursor <cursoragent@cursor.com>
@binggg binggg changed the title feat(mcp): 🚀 消息推送配置工具 queryMessagePush/manageMessagePush(复用 CloudApiRequestFn 领域语义适配层) feat(mcp): 🚀 消息推送配置工具 queryMessagePush/manageMessagePush(事件+消息类型订阅 · appid 多会话透传 · 幂等乐观锁) Aug 24, 2026
t added 2 commits August 24, 2026 20:01
# Conflicts:
#	config/.claude/skills/miniprogram-development/SKILL.md
#	config/source/skills/miniprogram-development/SKILL.md
@binggg
binggg merged commit 86aeaa4 into main Aug 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant