npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@smile5690/mcp-wxcloud

v1.0.0

Published

MCP server for WeChat Cloud Development database operations - Query, Add, Update, Delete, Aggregate

Readme

微信云开发数据库 MCP 服务器

用于访问微信云开发数据库的 MCP (Model Context Protocol) 服务器。

功能

提供以下 MCP 工具:

| 工具名称 | 功能描述 | |---------|---------| | wxcloud_get_access_token | 获取微信云开发 API 的 access_token | | wxcloud_query | 查询数据库记录 | | wxcloud_count | 统计记录数量 | | wxcloud_add | 插入记录 | | wxcloud_update | 更新记录 | | wxcloud_delete | 删除记录 | | wxcloud_aggregate | 聚合查询 | | wxcloud_raw_query | 执行原始查询语句 | | wxcloud_raw_update | 执行原始更新语句 | | wxcloud_raw_aggregate | 执行原始聚合语句 |

安装

cd mcp-wxcloud
npm install
npm run build

配置

1. 获取必要信息

  • AppID: 在微信公众平台 → 开发管理 → 开发设置 中获取
  • AppSecret: 在微信公众平台 → 开发管理 → 开发设置 中获取
  • 环境ID: 在微信开发者工具 → 云开发控制台 → 设置 → 环境设置 中获取

2. 配置 MCP

在 Trae IDE 的 MCP 配置文件中添加:

全局配置: C:\Users\<用户名>\AppData\Roaming\TRAE SOLO CN\User\mcp.json

项目配置: 项目根目录下的 .mcp.json

{
  "mcpServers": {
    "wxcloud": {
      "command": "node",
      "args": ["c:\\soft\\android studio\\yjf\\03\\NuoNuoFeeding\\mcp-wxcloud\\dist\\index.js"],
      "env": {
        "WX_APPID": "你的AppID",
        "WX_APPSECRET": "你的AppSecret",
        "WX_ENV_ID": "你的云环境ID"
      }
    }
  }
}

使用示例

查询记录

查询 users 集合中所有年龄大于 18 的用户,限制返回 20 条

工具调用:

{
  "collection": "users",
  "where": "{\"age\": _.gt(18)}",
  "limit": 20
}

统计记录

统计 orders 集合中状态为 completed 的记录数量

工具调用:

{
  "collection": "orders",
  "where": "{\"status\": \"completed\"}"
}

插入记录

向 logs 集合插入一条日志记录

工具调用:

{
  "collection": "logs",
  "data": "{\"type\": \"error\", \"message\": \"测试日志\", \"timestamp\": new Date()}"
}

更新记录

更新 users 集合中 ID 为 xxx 的记录,将 status 字段改为 active

工具调用:

{
  "collection": "users",
  "docId": "xxx",
  "data": "{\"status\": \"active\"}"
}

删除记录

删除 logs 集合中创建时间超过 30 天的记录

工具调用:

{
  "collection": "logs",
  "where": "{\"createTime\": _.lt(new Date(Date.now() - 30 * 24 * 60 * 60 * 1000))}"
}

聚合查询

按用户分组统计订单总金额

工具调用:

{
  "collection": "orders",
  "group": "{\"_id\": \"$userId\", \"totalAmount\": _.sum(\"$amount\")}"
}

查询语法说明

微信云开发数据库使用类似 MongoDB 的查询语法:

比较操作符

  • _.eq(value) - 等于
  • _.neq(value) - 不等于
  • _.gt(value) - 大于
  • _.gte(value) - 大于等于
  • _.lt(value) - 小于
  • _.lte(value) - 小于等于
  • _.in(array) - 在数组中
  • _.nin(array) - 不在数组中

逻辑操作符

  • _.and([...]) - 且
  • _.or([...]) - 或
  • _.nor([...]) - 非
  • _.not(condition) - 取反

聚合操作符

  • _.sum(field) - 求和
  • _.avg(field) - 平均值
  • _.count() - 计数
  • _.max(field) - 最大值
  • _.min(field) - 最小值
  • _.first(field) - 第一个值
  • _.last(field) - 最后一个值

注意事项

  1. access_token 有效期: 7200 秒(2小时),服务器会自动缓存和刷新
  2. 查询限制: 单次查询最多返回 100 条记录,使用 skip 实现分页
  3. 安全: AppSecret 是敏感信息,请妥善保管,不要泄露
  4. 权限: 确保云开发数据库的权限设置允许通过 HTTP API 访问

错误码参考

| 错误码 | 说明 | |-------|------| | 0 | 成功 | | -1 | 系统错误 | | 40014 | AccessToken 不合法 | | 42001 | AccessToken 过期 | | 85088 | 该 APP 未开通云开发 |

开发

# 开发模式(自动编译)
npm run dev

# 构建
npm run build

# 运行
npm start

许可证

MIT