Help us improve
Share bugs, ideas, or general feedback.
From cloudbase
Builds, deploys, and debugs CloudBase Event Functions and HTTP Functions. Use when creating application runtime code or function triggers on CloudBase.
npx claudepluginhub tencentcloudbase/cloudbase-mcp --plugin cloudbaseHow this skill is triggered — by the user, by Claude, or both
Slash command
/cloudbase:cloud-functionsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
If this environment only installed the current skill, start from the CloudBase main entry and use the published `cloudbase/references/...` paths for sibling skills.
Develops, deploys, and troubleshoots CloudBase projects including mini-programs, web apps, databases, cloud functions, and AI integration.
Develop, deploy, and manage Codehooks.io serverless backends — REST APIs, webhooks, NoSQL database, scheduled jobs, queue workers, and workflows.
Cloudflare Workers + Wrangler operations: bindings, local dev, secrets, deploy/CI, Workers-vs-Pages decisions, and observability. Covers KV, D1, R2, Durable Objects, Queues, Hyperdrive, Workers AI, Vectorize, and wrangler.jsonc/toml config.
Share bugs, ideas, or general feedback.
If this environment only installed the current skill, start from the CloudBase main entry and use the published cloudbase/references/... paths for sibling skills.
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/SKILL.mdhttps://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloud-functions/SKILL.mdKeep local references/... paths for files that ship with the current skill directory. When this file points to a sibling skill such as auth-tool or web-development, use the standalone fallback URL shown next to that reference.
Cross-cutting protocols (required for public exposure and code changes):
https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-platform/references/protocols/change-safety-protocol.mdhttps://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-platform/references/protocols/deployment-gate.mdscf_bootstrap, function triggers, or function gateway exposure.manageFunctions, queryFunctions, manageGateway, or legacy function-tool names.callCloudApi as a fallback for logs or gateway setup../references.md../auth-tool/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/auth-tool/SKILL.md)../cloudbase-wechat-integration/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudbase-wechat-integration/SKILL.md; official docs: https://docs.cloudbase.net/integration/introduce/index.md)../ai-model-nodejs/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/ai-model-nodejs/SKILL.md)../cloudrun-development/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/cloudrun-development/SKILL.md)../http-api/SKILL.md (standalone fallback: https://cnb.cool/tencent/cloud/cloudbase/cloudbase-skills/-/git/raw/main/skills/cloudbase/references/http-api/SKILL.md)cloudbase-wechat-integration for the business contract and this skill only for function operations.db.collection(...).get/add/update before writing a function. Functions add deployment complexity, CORS configuration, and HTTP gateway binding that the SDK eliminates entirely.exports.main(event, context)) with HTTP Function code shape (req / res on port 9000).db.collection("name").add(...) will create a missing document-database collection automatically. Collection creation is a separate management step.scf_bootstrap, listen on port 9000, and include dependencies.EXCEED_AUTHORITY. Note: anonymous login is disabled by default for new environments — if the function needs public access without authentication, configure the security rule to allow all callers rather than relying on anonymous login.scf_bootstrap Node.js binary path with the function runtime (e.g. using /var/lang/node18/bin/node but setting runtime: "Nodejs16.13").cloudbase-platform/references/protocols/change-safety-protocol.md).cloudbase-platform/references/protocols/deployment-gate.md.Use this skill when developing, deploying, and operating CloudBase cloud functions. CloudBase has two different programming models:
exports.main = async (event, context) => {}.req / res on port 9000.http module unless the user explicitly asks for Express, Koa, NestJS, or another framework.Use these rules whenever you are writing the function code itself:
exports.main(event, context). That is the Event Function contract.9000.http.createServer((req, res) => { ... }) by default so the runtime contract stays explicit.http module, do not assume Express-style helpers exist. req.body, req.query, and req.params are not provided for you.require(...), no "type": "module" in package.json) unless you explicitly want ES Modules."type": "module" + import ...), do not mix in CommonJS-only globals or APIs such as require(...), module.exports, or bare __dirname. In ESM, derive file paths from import.meta.url with fileURLToPath(...) only when needed.http module, parse req.url yourself with new URL(...), collect the request body from the stream, and only then call JSON.parse. Empty bodies should be handled explicitly instead of assuming JSON is always present.res.writeHead(...) and res.end(...), including Content-Type such as application/json; charset=utf-8 for JSON APIs.OPTIONS preflight with 200 and CORS headersAccess-Control-Allow-Origin: * (or specific origin) on all responsesAccess-Control-Allow-Methods: GET, POST, OPTIONS as neededAccess-Control-Allow-Headers: Content-Type for JSON requests404, and known paths with unsupported methods should normally return 405.| Question | Choose |
|---|---|
| Triggered by SDK calls or timers? | Event Function |
| Needs browser-facing HTTP endpoint? | HTTP Function |
| Needs SSE or WebSocket service? | HTTP Function |
| Needs long-lived container runtime or custom system environment? | CloudRun |
| Only needs HTTP access for an existing Event Function? | Event Function + gateway access |
Choose the correct runtime model first
exports.main(event, context)9000Use the converged MCP entrances
queryFunctions, queryGatewaymanageFunctions, manageGatewayWrite code and deploy, do not stop at local files
manageFunctions(action="createFunction") for creationmanageFunctions(action="updateFunctionCode") for code updatesmanageFunctions(action="updateFunctionConfig") for config updates (timeout, memorySize, envVariables)functionRootPath as the directory that directly contains function folders (e.g., cloudfunctions/ or functions/), NOT the project root and NOT the function subdirectory itselfmanageFunctions and queryFunctions instead of CLI commandsmanageFunctions(action="updateFunctionConfig") individually for each function — MCP does not have a --all batch parameter like CLIPrefer doc-first fallbacks
callCloudApi, first check the official docs or knowledge-base entry for that actionRead the right detailed reference
./references/event-functions.md./references/http-functions.md./references/operations-and-config.mddb.collection("feedback").add(...) only inserts into an existing collection; it does not auto-create feedback when absent.| Feature | Event Function | HTTP Function |
|---|---|---|
| Primary trigger | SDK call, timer, event | HTTP request |
| Entry shape | exports.main(event, context) | web server with req / res |
| Port | No port | Must listen on 9000 |
scf_bootstrap | Not required | Required |
| Dependencies | Auto-installed from package.json | Must be packaged with function code |
| Best for | serverless handlers, scheduled jobs | APIs, SSE, WebSocket, browser-facing services |
cloudfunctions/hello-event/index.js
exports.main = async (event, context) => {
return {
ok: true,
message: "hello from event function",
event,
};
};
cloudfunctions/hello-event/package.json
{
"name": "hello-event",
"version": "1.0.0"
}
cloudfunctions/hello-http/index.js
const http = require("http");
const { URL } = require("url");
// CORS headers — default to * for simple cross-origin APIs
const CORS_HEADERS = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
};
function sendJson(res, statusCode, data) {
res.writeHead(statusCode, {
"Content-Type": "application/json; charset=utf-8",
...CORS_HEADERS,
});
res.end(JSON.stringify(data));
}
function sendOptions(res) {
res.writeHead(204, CORS_HEADERS);
res.end();
}
function readJsonBody(req) {
return new Promise((resolve, reject) => {
let raw = "";
req.on("data", (chunk) => { raw += chunk; });
req.on("end", () => {
if (!raw) { resolve({}); return; }
try { resolve(JSON.parse(raw)); } catch (e) { resolve({}); }
});
req.on("error", reject);
});
}
const server = http.createServer(async (req, res) => {
// Handle CORS preflight
if (req.method === "OPTIONS") {
return sendOptions(res);
}
const url = new URL(req.url || "/", "http://127.0.0.1");
if (req.method === "GET" && url.pathname === "/") {
sendJson(res, 200, { ok: true, message: "hello from http function" });
} else if (req.method === "POST" && url.pathname === "/") {
const body = await readJsonBody(req);
sendJson(res, 200, { received: body });
} else {
sendJson(res, 404, { error: "Not Found" });
}
});
server.listen(9000);
For a more complete example with routing, method checks, and error handling, see ./references/http-functions.md.
cloudfunctions/hello-http/scf_bootstrap
#!/bin/bash
/var/lang/node18/bin/node index.js
The scf_bootstrap binary path must match the runtime — see the full mapping table in ./references/http-functions.md.
cloudfunctions/hello-http/package.json
{
"name": "hello-http",
"version": "1.0.0"
}
queryFunctions(action="listFunctions"|"getFunctionDetail")manageFunctions(action="createFunction")manageFunctions(action="updateFunctionCode")manageFunctions(action="updateFunctionConfig")Query function logs — use the queryFunctions tool:
queryFunctions(action="listFunctionLogs", functionName="xxx") — list execution logs of a specific functionqueryFunctions(action="getFunctionLogDetail", requestId="xxx") — fetch the detail of one log entryqueryFunctions vs queryLogs:
queryFunctions queries execution logs of a single cloud function and requires functionNamequeryLogs searches CLS (cross-service log aggregation) using CLS query syntaxExamples:
// List recent logs for cloud function "my-function"
queryFunctions(action="listFunctionLogs", functionName="my-function", limit=10)
// Inspect the log detail for a specific request id
queryFunctions(action="getFunctionLogDetail", requestId="abc-123")
// Cross-service error search via CLS
queryLogs(action="searchLogs", queryString='(src:app OR src:system) AND log:"ERROR"', service="tcb")
queryLogs queryString follows CLS syntax (see https://cloud.tencent.com/document/api/876/128127). The examples below are starting points; adapt them to the concrete log content of your query:
(src:app OR src:system) AND log:"START RequestId"| select request_id, max(status_code) as status where ((request_id='xxxx' AND retry_num=0) AND retry_num=0) AND status_code!=202 group by request_id, retry_nummodule:databasemodule:database AND eventType:(MongoSlowQuery) — MongoSlowQuery is the document-database slow-query eventmodule:rdbmodule:rdb AND eventType:(MysqlFreeze OR MysqlRecover OR MysqlSlowQuery) — MysqlFreeze = freeze, MysqlRecover = recover, MysqlSlowQuery = slow querymodule:workflowmodule:modelmodule:authmodule:llm AND logType:llm-traceloglogType:accesslogmodule:app AND eventType:(AppProdPub OR AppProdDel) — AppProdPub = app publish, AppProdDel = app deleteIf these are unavailable, read ./references/operations-and-config.md before any callCloudApi fallback
queryGateway(action="getAccess")manageGateway(action="createAccess")./references/operations-and-config.md firstcloudrun-development -> container services, long-lived runtimes, Agent hostinghttp-api -> raw CloudBase HTTP API invocation patternscloudbase-platform -> general CloudBase platform decisionsops-inspector -> AIOps-style inspection and log search across services