← ClaudeAtlas

bmob-cloud-function-developmentlisted

Write, upload, verify, and sync Bmob server-side cloud functions using the Bmob MCP server when available. Use when the user asks to 编写云函数, 写云函数, 上传云函数, 部署云函数, 发布云函数, 同步云函数, 同步函数, 拉取云函数, 下载云函数, 验证云函数结果, or mentions `function onRequest(request, response, modules)`.
bmob/agent-skills · ★ 3 · DevOps & Infrastructure · score 79
Install: claude install-skill bmob/agent-skills
# Bmob 云函数开发 用于**写运行在 Bmob 服务器上的云函数源码**,并在已配置 MCP 时走 **`deploy_cloud_function` → `invoke_cloud_function`** 完成上传与验证,或走 **`list_cloud_functions` → `get_cloud_function`** 将线上函数同步到本地。 ## 先判断走哪条通道 1. **已配置 Bmob MCP**:优先用 `bmob-mcp` - 上传源码:`deploy_cloud_function` - 单独验证:`invoke_cloud_function` - **同步线上 → 本地**:`list_cloud_functions` → `get_cloud_function`(agent 写本地文件) 2. **未配置 MCP**:按 [云函数文档](https://github.com/bmob/BmobDocs/blob/master/mds/cloud_function/web/develop_doc.md) 与 REST `/1/functions/<name>` / 控制台流程给代码与 curl ## 语法基线 默认按 Bmob 云函数文档的 Web/Node 风格写: ```javascript function onRequest(request, response, modules) { response.send("hello"); } ``` - GET 直连参数:`request.query.xxx` - POST / REST 参数:`request.body.xxx` - 返回结果:`response.send(...)` - 数据库 / 文件 / HTTP / 加密:从 `modules` 取 `oData`、`oFile`、`oHttp`、`oCrypto` 等 ## 必须遵守的已知行为 - 通过 REST API 调用时,参数从 **`request.body`** 取,不是 `request.query` - 云函数里很多回调返回的是**字符串**,需要 `JSON.parse(data)` 后再当对象用 - 已知行为:服务端可能把传入 `request.body` 的值转成字符串;涉及数字、布尔、数组、对象时,在云函数内显式 `parseInt` / `=== "true"` / `JSON.parse` - **`modules.oData` 的 `where` 是 JSON 对象,不要 `JSON.stringify`**: - ✅ 云函数内:`db.find({ "table": "Level", "where": { "status": 1 } })` - ❌ 错误:`"where": JSON.stringify(where)` — 会把条件变成字符串,查询失效或行为异常 - 仅 **REST GET 的 query 参数** `where` 才需要 URL 编码的 JSON 字符串(见 `bmob-database-restful`);**不要**把 REST 写法套进 `oData` ## 默认工作流 ### 1. 写源码 - 函数名与用户要调用的名字一致 - 优先写最小可验证版本,再逐步扩展 - 如果要查表 / 改表,先确认表名与字段名;用户已配 MCP 时先读 `get_project_tables` ### 2. 上