
cloud-functions
CloudBase function runtime guide for building, deploying, and debugging your own Event Functions or HTTP Functions. This skill should be used when users need application runtime code on CloudBase, not when they are merely calling CloudBase official platform APIs.
- Installs
- 54
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/tencentcloudbase/cloudbase-ai-toolkit --skill cloud-functions- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads cloud-functions automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Sibling skills (local only)
Sibling CloudBase skills ship beside this skill. Use local relative paths such as ../auth-tool-cloudbase/SKILL.md.
If a referenced sibling skill file is missing from this environment, ask the user to install the full CloudBase plugin (or the missing skill). Do not HTTP-fetch remote skill or protocol markdown into the agent context.
Cross-cutting protocols (required before code changes or deployments):
- Change Safety Protocol:
../cloudbase-platform/references/protocols/change-safety-protocol.md - Deployment Gate:
../cloudbase-platform/references/protocols/deployment-gate.md - Sensitive Runtime Data Protection:
../cloudbase-platform/references/protocols/sensitive-runtime-data-protection.md
Cloud Functions Development
Activation Contract
Use this first when
- The task is to create, update, deploy, inspect, or debug a CloudBase Event Function or HTTP Function that serves application runtime logic.
- The request mentions function runtime, function logs,
scf_bootstrap, function triggers, or function gateway exposure.
Read before writing code if
- You still need to decide between Event Function and HTTP Function.
- The task mentions
manageFunctions,queryFunctions,manageGateway, or legacy function-tool names. - The task might require
callCloudApias a fallback for logs or gateway setup. - An HTTP Function will call CloudBase resources through
@cloudbase/node-sdkor@cloudbase/manager-node-> read./references/http-function-credentials.md. HTTP Functions must use explicit credentials; do not rely on the Event Function passwordless runtime path.
Exception only (do not read by default)
- Migrating an existing app that already uses classic TCP DB clients (
DATABASE_URL/ Prisma /mysql2/pg/ Redis) → read./references/vpc-and-tcp-database.mdvia./references.md. New business CRUD must prefer CloudBase native SDK (app.database()/app.rdb()) or MCP SQL tools instead of TCP.
Then also read
- Detailed reference routing ->
./references.md - Auth setup or provider-related backend work ->
../auth-tool-cloudbase/SKILL.md - CloudBase Integration Center generated WeChat Pay or Official Account functions ->
../cloudbase-wechat-integration/SKILL.md(official docs:https://docs.cloudbase.net/integration/introduce.md) - AI in functions ->
../ai-model-nodejs/SKILL.md - Long-lived container services or Agent runtimes ->
../cloudrun-development/SKILL.md - Calling CloudBase official platform APIs from a client or script ->
../http-api-cloudbase/SKILL.md
Do NOT use for
- CloudRun container services.
- Web authentication UI implementation.
- Database-schema design or general data-model work.
- CloudBase official platform API clients or raw HTTP integrations that only consume platform endpoints.
- Creating Integration Center instances through guessed APIs. For WeChat Pay or Official Account generated functions, use
cloudbase-wechat-integrationfor the business contract and this skill only for function operations. - Tasks that the CloudBase JS SDK can handle directly — simple data reads/writes, leaderboards, file uploads, real-time queries. Reach for the matching SDK surface before writing a function:
db.collection(...).get/add/updateonly for confirmed NoSQL collections, andapp.rdb().from(...)for CloudBase PG tables. Functions add deployment complexity, CORS configuration, and HTTP gateway binding that the SDK eliminates entirely.
Common mistakes / gotchas
- Picking the wrong function type and trying to compensate later.
- Confusing official CloudBase API client work with building your own HTTP function.
- Mixing Event Function code shape (
exports.main(event, context)) with HTTP Function code shape (req/reson port9000). - Treating HTTP Access as the implementation model for HTTP Functions. HTTP Access is a gateway configuration for Event Functions, not the HTTP Function runtime model.
- Assuming
db.collection("name").add(...)will create a missing document-database collection automatically. Collection creation is a separate management step. - Baking static content into the deployment package — media files, user uploads, or assets that change on their own cadence. The package is uploaded on every deploy and a function package has a hard size ceiling, so large or independently-changing content makes every deploy slower and can push the package over the limit.
- Media files (
*.mp4, large images, fonts) — go to cloud storage, referenced by URL, not into the package. - User uploads written to the function's local filesystem — the function is ephemeral and
/tmpis small and not shared. Uploads go to cloud storage. - Frequently-updated static resources bundled in — every change forces a full function redeploy. Serve them from cloud storage so the function only redeploys when the code changes.
- Media files (
- Forgetting that runtime cannot be changed after creation.
- Using cloud functions as the first answer for Web login.
- Forgetting that HTTP Functions must ship
scf_bootstrap, listen on port9000, and include dependencies. - Assuming an HTTP Function can use CloudBase SDKs without explicit credentials. The default temporary credential path is not reliable for HTTP Functions and credential rotation can break a running service. Use a CloudBase server API Key or Tencent Cloud key pair for
@cloudbase/node-sdk; use a Tencent Cloud key pair for@cloudbase/manager-node. Seereferences/http-function-credentials.md. - Forgetting how an HTTP Function is meant to be reached. A call with no credential fails
401 MISSING_CREDENTIALS; a call that carries one but is not allowed fails403 EXCEED_AUTHORITY. For browser, game or app clients, add a gateway route (manageGateway(action="createRoute", auth: false)) instead of widening the function security rule — in PostgreSQL environments that rule lives in an environment-wideauthz.user.regodocument, so editing it overwrites the policy for the whole environment. Seereferences/http-functions.md. - Reading an
InsufficientBalanceinvoke failure as an account problem. A cloud function answers HTTP 410 with this code and the code reads as a short account balance, but what runs out is the environment's resource points — drawn down before any account balance and not restored by a top-up. The four causes (trial points exhausted / plan points exhausted / plan expired / account in arrears) need four different answers, only the last of which involves topping up, so diagnose withmanageEnv(action="usage")plus the account balance before advising. See../cloud-api-operations/references/recipes/credits-exhaustion.md. - Mismatching the
scf_bootstrapNode.js binary path with the function runtime (e.g. using/var/lang/node18/bin/nodebut settingruntime: "Nodejs16.13"). - For Custom Image HTTP Functions: forgetting that TCR, the CloudApp build, and SCF must be in the same region; using
:latestinstead of a unique tag; or confusing the request-driven port-9000image model with a long-lived CloudRun container that listens on the injectedPORT. - Assuming MCP covers the whole image pipeline.
manageFunctionscovers SCF image deploy (Stage B) viaruntime: "CustomImage"+imageConfig, but the CloudApp custom build → TCR push (Stage A) is a raw Tencent Cloud API path — confirm action names and parameters from official docs before anycallCloudApifallback. - Making code or configuration changes without first following the Change Safety Protocol (
cloudbase-platform/references/protocols/change-safety-protocol.md). - Exposing functions publicly or deploying without first completing the checks in
cloudbase-platform/references/protocols/deployment-gate.md. - Returning
req.headers,process.env,event, orcontextwholesale — gateways may injectx-cloudbase-context(base64 temporary credentials). Never echo that header or dump credential env vars to clients. Follow../cloudbase-platform/references/protocols/sensitive-runtime-data-protection.md. - Using a bare layer name (e.g.
common) across environments. SCF LayerName is an account-scoped shared namespace: same name → shared version sequence. Create new layers with fixed format{layerName}_{当前envId}(e.g.common_cloud1-d9ghadgak3edf6b36). Pass the full name aslayerName— do not invent automatic suffixes. Treat MCP layerwarningsas soft advisories (operation still succeeds). Details:./references/operations-and-config.md. - Long-running MCP image deployments must complete the full workflow: When using
manageFunctionswithdeployFunctionfor a realcloudorlocaldeployment, preferwait=falseto avoid blocking a single Tool Call for an extended period. If the tool returns ataskId, do not end the workflow, report success, or ask the user to wait while the status isrunning. Automatically callqueryFunctions(action="getFunctionDeployStatus", taskId="...")and continue polling according to the reported progress until the status becomessucceededorfailed. Only after reaching a reasonable polling limit may you report that the deployment is still in progress; include thetaskId, current stage, and latest progress. On success, report the image URI or build ID, function status, and Gateway URL. On failure, report the failed stage, error code, request ID, and diagnostic guidance. If the status isexpired, explain that the local task record exceeded its retention window; the cloud deployment may still be running, so callgetFunctionDetailto confirm the actual cloud-side status instead of treating it as a failure.
Minimal checklist
- Read Cloud Functions Execution Checklist before deployment or runtime changes.
- Decide whether the task is Event Function, HTTP Function, or actually CloudRun.
- Separate static from dynamic: media, user uploads and frequently-updated assets live in cloud storage, not in the function package.
- Pick the detailed reference file in references.md before writing implementation code.
MCP image deployment with polling
For real cloud or local custom-image deployments, prefer:
{
"action": "deployFunction",
"dryRun": false,
"confirm": true,
"wait": false,
"deployConfig": {}
}
The wait field controls whether the current MCP Tool call waits for the complete deployment:
wait=true: wait for the manager deployment to reach a terminal result and return it.wait=false: return ataskIdpromptly while the deployment continues in the MCP background.
When wait=false returns a taskId, the deployment workflow is not complete. Automatically call queryFunctions with action="getFunctionDeployStatus" and that taskId; continue while the status is running, then stop only at succeeded or failed. Wait about 5 seconds before the first follow-up query and use the returned progress/nextActions to continue without aggressive polling. Do not tell the user to ask again or imply success before a terminal status is returned. An expired status means the task exceeded the maximum retention window and was force-terminated locally — the cloud deployment may still be in progress, so confirm the real state with getFunctionDetail instead of reporting failure.
If a reasonable polling limit is reached, report only that the task is still running, including the taskId, current status, current stage, and latest progress. For a terminal result, report the deployment strategy, action, image URI/digest, build ID, function status, Gateway URL, or the failed stage, error code, request ID, and diagnostic next step.
Personal-tier TCR credentials — never put the password in tool arguments
Personal-tier image builds (imageConfig.imageType="personal" with local / cloud) need a TCR push credential. Read it from the MCP process environment, not from tool arguments:
- Leave
func.imageConfig.build.registryCredentialout of the request whenTCB_TCR_USERNAMEandTCB_TCR_PASSWORDare set in the MCP serverenvblock — the MCP fills them in automatically, the same wayTENCENTCLOUD_SECRETIDworks. - Never ask the user to paste the password into chat, and never write it into tool arguments. Anything placed in arguments enters the model context and the tool-call history.
- If deployment fails with
CLOUD_REGISTRY_CREDENTIAL_MISSINGorCLOUD_REGISTRY_CREDENTIAL_INVALID, instruct the user to add these two variables to theenvblock of their MCP configuration and restart the MCP server. Do not work around it by passing the credential inline. - The username is the Tencent Cloud account UIN and is not itself a secret; it may be passed explicitly if needed. Explicit arguments take precedence per field, so username-in-argument plus password-from-environment is a valid combination.
Know when that environment channel does not exist. It works only for a local stdio MCP server whose client configuration exposes a custom env block. Some GUI clients do not inherit shell exports, and IDE-embedded MCP servers usually inject credentials from a hard-coded allowlist (often only TENCENTCLOUD_*), leaving the user no way to set arbitrary variables. Telling those users to "set it in the MCP env block" is an instruction they cannot act on. Route them to an enterprise registry (imageType="enterprise", which mints a short-lived TCR token instead of using a fixed password) or to buildStrategy="image" with an already-pushed image.
Enterprise-tier builds require a login state with CAM permission
cloud / local builds against an enterprise registry mint a TCR token through CAM (as does autoGrant). Environment-level API Keys and OAuth-issued STS credentials carry no CAM policy, so those calls fail with UnauthorizedOperation. The MCP probes the login state before starting a real enterprise build and refuses up front rather than failing midway; treat that error as a routing signal, not a retryable fault:
- Sign in with an account-level
TENCENTCLOUD_SECRETID/TENCENTCLOUD_SECRETKEYpair, or - Switch to
buildStrategy="image"and deploy an image that was pushed elsewhere, or - Use a personal-tier registry — its static password goes straight to
docker loginwithout touching CAM, which makes it the one build path that does work for API Key users.
Writing mode at a glance
- If the request is for SDK calls, timers, or event-driven workflows, write an Event Function with
exports.main = async (event, context) => {}. - If the request is for REST APIs, browser-facing endpoints, SSE, or WebSocket, write an HTTP Function with
req/reson port9000. - For Node.js HTTP Functions, default to the native
httpmodule unless the user explicitly asks for Express, Koa, NestJS, or another framework. - If the HTTP Function needs custom system libraries or an arbitrary runtime but should still be SCF request-driven and scale to zero, deploy it as a Custom Image HTTP Function (
Runtime: CustomImage) from a TCR image. The container still listens on the fixed port9000. See./references/http-functions-custom-image.md. This is distinct from a CloudRun container, which listens on the injectedPORTand runs long-lived. - 有 Dockerfile 的 HTTP 无状态服务可优先考虑 HTTP 云函数,不必上云托管 — a Dockerfile alone does not mean CloudRun. If the service is stateless, request-driven HTTP without long connections / custom runtime / VPC database access, prefer an HTTP Function (or Custom Image HTTP Function) — faster to deploy, cheaper, and no CloudRun environment initialization needed. Route to CloudRun (
../cloudrun-development/SKILL.md) only for WebSocket/SSE long connections, stable independent processes, custom system dependencies, or VPC DB access. - If the user mentions HTTP access for an existing Event Function, keep the Event Function code shape and add gateway access separately.
HTTP Function authoring contract
Use these rules whenever you are writing the function code itself:
- Do not write an HTTP Function as
exports.main(event, context). That is the Event Function contract. - Treat the function as a standard web server process that must listen on port
9000. - With Node.js, prefer
http.createServer((req, res) => { ... })by default so the runtime contract stays explicit. - With the Node.js native
httpmodule, do not assume Express-style helpers exist.req.body,req.query, andreq.paramsare not provided for you. - For Node.js HTTP Functions, choose one module system up front and keep it consistent. Default to CommonJS for simple functions (
require(...), no"type": "module"inpackage.json) unless you explicitly want ES Modules. - If you do choose ES Modules (
"type": "module"+import ...), do not mix in CommonJS-only globals or APIs such asrequire(...),module.exports, or bare__dirname. In ESM, derive file paths fromimport.meta.urlwithfileURLToPath(...)only when needed. - With the native
httpmodule, parsereq.urlyourself withnew URL(...), collect the request body from the stream, and only then callJSON.parse. Empty bodies should be handled explicitly instead of assuming JSON is always present. - Return responses explicitly with
res.writeHead(...)andres.end(...), includingContent-Typesuch asapplication/json; charset=utf-8for JSON APIs. - Handle CORS headers — but first check who terminates CORS. A function reached through the HTTP gateway must not set
Access-Control-Allow-Originitself: the gateway already fills it from the environment security-domain allowlist, and a second value yields<origin>,*, which browsers reject outright — every request fails with a CORS error that looks like the service is down. Only set CORS headers when the function is called directly, outside the gateway:- Respond to
OPTIONSpreflight with an empty204 - Include
Access-Control-Allow-Originonly for direct, non-gateway callers - Include
Access-Control-Allow-Methods: GET, POST, OPTIONSas needed - Include
Access-Control-Allow-Headers: Content-Typefor JSON requests
- Respond to
- Keep routing and method handling explicit. Unknown paths should return
404, and known paths with unsupported methods should normally return405. - Keep gateway setup and security-rule changes separate from the runtime code. They affect access, not the HTTP Function programming model.
- Do not add HTTP access service configuration when the task is only to create an HTTP Function itself. Gateway paths or custom domains are separate access-layer work; public invocation requirements should be handled through the function security rule workflow (note: anonymous login is disabled by default).
- If the HTTP Function calls CloudBase through
@cloudbase/node-sdkor@cloudbase/manager-node, complete the explicit credential gate in./references/http-function-credentials.mdbefore deployment. Never hardcode credentials in the function package. - Never echo sensitive runtime data. Do not return
req.headers,process.env, orx-cloudbase-contextin responses. Debug endpoints must use an explicit non-sensitive allowlist. See../cloudbase-platform/references/protocols/sensitive-runtime-data-protection.md.
Quick decision table
| 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 custom system libraries / arbitrary runtime, but still SCF request-driven + scale-to-zero? | HTTP Function with Runtime: CustomImage (deploy from a TCR image) |
| Has a Dockerfile but is a stateless HTTP service (no long connections / custom runtime / VPC DB)? | HTTP Function (or Custom Image HTTP Function) — not CloudRun |
| Needs long-lived container runtime or custom system environment? | CloudRun |
| Only needs HTTP access for an existing Event Function? | Event Function + gateway access |
How to use this skill (for a coding agent)
-
Choose the correct runtime model first
- Event Function ->
exports.main(event, context) - HTTP Function -> web server on port
9000 - If the requirement is really a container service, reroute to CloudRun early
- Event Function ->
-
Use the converged MCP entrances
- Reads ->
queryFunctions,queryGateway - Writes ->
manageFunctions,manageGateway - Translate legacy names before acting rather than copying them literally
- Reads ->
-
Write code and deploy, do not stop at local files
- Use
manageFunctions(action="createFunction")for creation - Use
manageFunctions(action="updateFunctionCode")for code updates - Use
manageFunctions(action="updateFunctionConfig")for config updates (timeout, memorySize, envVariables) - For a Custom Image HTTP Function, call
manageFunctions(action="createFunction")withfunc.runtime="CustomImage"andimageConfig(imageUriwith tag;registryIdfor enterprise TCR); iterate later withmanageFunctions(action="updateFunctionCode")+imageConfig. NofunctionRootPathis needed because the code lives in the image. See./references/http-functions-custom-image.md. - Keep
functionRootPathas the directory that directly contains function folders (e.g.,cloudfunctions/orfunctions/), NOT the project root and NOT the function subdirectory itself - Prefer MCP when available — use
manageFunctionsandqueryFunctionswhen those tools are in this session - CLI fallback when MCP is missing — if function tools are not loaded (first session / pre-restart), configure MCP for next time, then use
tcb fn deployvia../cloudbase-cli/SKILL.md(see guidelinetooling-fallback.md). Do not stall waiting for restart. - Do NOT invent CLI when the runtime has no shell — if only MCP exists and it works, stay on MCP; if neither works, report the gap
- For batch updates (multiple functions), call
manageFunctions(action="updateFunctionConfig")individually for each function — MCP does not have a--allbatch parameter like CLI - If an HTTP Function uses
@cloudbase/node-sdk, prefer a server API Key created withmanageAppAuth(action="createApiKey", keyType="api_key")and inject it asCLOUDBASE_APIKEY; Tencent CloudSecretId/SecretKeyis also supported - If an HTTP Function uses
@cloudbase/manager-node, inject Tencent CloudSecretId/SecretKey; do not claim that a CloudBase API Key initializes the Manager SDK - Merge credential environment variables with the existing function configuration instead of replacing the whole environment-variable set
- Use
-
Prefer doc-first fallbacks
- If a task falls back to
callCloudApi, first check the official docs or knowledge-base entry for that action - Confirm the exact action name and parameter contract before calling it
- Do not guess raw cloud API payloads from memory
- If a task falls back to
-
Read the right detailed reference
- Event Function details ->
./references/event-functions.md - HTTP Function details ->
./references/http-functions.md - HTTP Function CloudBase SDK credentials ->
./references/http-function-credentials.md - HTTP Function from a container image (
Runtime: CustomImage, TCR image pipeline) ->./references/http-functions-custom-image.md - Logs, gateway, env vars, layers (
{layerName}_{当前envId}), and legacy mappings ->./references/operations-and-config.md
- Event Function details ->
Database write reminder
- If a function will write to CloudBase document database, create the target collection first through console or management tooling.
db.collection("feedback").add(...)only inserts into an existing collection; it does not auto-createfeedbackwhen absent.- If the product requirement says "create when missing", implement that as an explicit collection-management step before the first write instead of assuming the runtime write call will provision it.
Function types comparison
| 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 |
Minimal code skeletons
Event Function hello world
cloudfunctions/hello-event/index.js
exports.main = async (event, context) => {
// Do not return event/context/process.env — they may contain platform secrets.
const name = typeof event?.name === "string" ? event.name : "world";
return {
ok: true,
message: `hello ${name} from event function`,
};
};
cloudfunctions/hello-event/package.json
{
"name": "hello-event",
"version": "1.0.0"
}
HTTP Function hello world
cloudfunctions/hello-http/index.js
const http = require("http");
const { URL } = require("url");
// CORS: leave this empty when the function is reached through the HTTP gateway.
// The gateway already fills Access-Control-Allow-Origin from the environment
// security-domain allowlist; adding a second value makes the header illegal
// ('<origin>,*') and browsers block every request. Only set CORS headers here
// when the function is called directly, outside the gateway.
const CORS_HEADERS = {};
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"
}
Preferred tool map
Function management
queryFunctions(action="listFunctions"|"getFunctionDetail")manageFunctions(action="createFunction")manageFunctions(action="updateFunctionCode")manageFunctions(action="updateFunctionConfig")
Layers (SCF Layer)
Layers are account-scoped, not env-scoped. Align with MCP manageFunctions / queryFunctions layer guidance:
- Naming (required for new layers):
{layerName}_{当前envId}— examplecommon_cloud1-d9ghadgak3edf6b36. Do not reuse a bare name likecommonin another env. - Create:
manageFunctions(action="createLayerVersion", layerName="…_{envId}", …)afterqueryFunctions(action="listLayers")to check duplicates. MCP may return a softwarningsentry if the name lacks the currentenvId; it does not rewrite the name. - Read:
queryFunctions(action="listLayers"|"listLayerVersions"|"getLayerVersionDetail"|"listFunctionLayers")— list results are an account-level view and may include layers created in other envs. - Bind / unbind / replace:
manageFunctions(action="attachLayer"|"detachLayer"|"updateFunctionLayers") - Delete version:
manageFunctions(action="deleteLayerVersion")— deleting a version can affect every env that binds that version. - Full contract and warning semantics →
./references/operations-and-config.md
Logs
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 entry
queryFunctions vs queryLogs:
queryFunctionsqueries execution logs of a single cloud function and requiresfunctionNamequeryLogssearches CLS (cross-service log aggregation) using CLS query syntax
Examples:
// 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:
- Function logs:
(src:app OR src:system) AND log:"START RequestId" - Aggregated function request status:
| 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_num - Document database (NoSQL):
module:database - Document database slow-query events:
module:database AND eventType:(MongoSlowQuery)—MongoSlowQueryis the document-database slow-query event - Relational database (MySQL):
module:rdb - Relational database (MySQL) events:
module:rdb AND eventType:(MysqlFreeze OR MysqlRecover OR MysqlSlowQuery)—MysqlFreeze= freeze,MysqlRecover= recover,MysqlSlowQuery= slow query - Workflow (approval flow):
module:workflow - Data model:
module:model - User permissions:
module:auth - LLM trace logs:
module:llm AND logType:llm-tracelog - Gateway access logs:
logType:accesslog - App publish / delete events:
module:app AND eventType:(AppProdPub OR AppProdDel)—AppProdPub= app publish,AppProdDel= app delete
If these are unavailable, read ./references/operations-and-config.md before any callCloudApi fallback
Gateway exposure
queryGateway(action="getRoute")/listRoutes/listCustomDomainsmanageGateway(action="createRoute")— for HTTP functions passupstreamResourceType="WEB_SCF"; for Event functions passupstreamResourceType="SCF". Omitdomainto attach the route on the HTTP gateway IsDefault domain (DomainType=HTTPSERVICE, typically*.{region}.app.tcloudbase.com)- IsDefault vs static hosting CDN: environments often also expose a separate IsDefault
STATIC_STOREdomain (*.tcloudbaseapp.com). Omittingdomaindoes not bind that static-hosting CDN entry, and it is not aSTATIC_STOREupstream binding (that requiresupstreamResourceType="STATIC_STORE"). Verify withqueryGateway(action="listRoutes")and checkDomain/DomainType/Path/UpstreamResourceType manageGateway(action="updateRoute")/deleteRoute/enableRoute/disableRoute/bindCustomDomain/deleteCustomDomain- Disable a route or the static hosting default domain: prefer
manageGateway(action="disableRoute", domain=..., path=...)(looks up the existing route, setsRoutes[].Enable=falseviaModifyHTTPServiceRoute).updateRoutemay also passenable=false/route.enable=false. To close*.tcloudbaseapp.com, list routes, take theSTATIC_STOREIsDefault domain, thendisableRoutewith thatdomainand usuallypath="/"— notmanageHosting, and notModifyGatewayRoute - When tool results include
accessUrl/accessUrls, prefer them directly (gateway custom-domain URLs are ranked before default domains) - Do not call deprecated GWAPI actions via
callCloudApi(CreateCloudBaseGWAPI, etc.)
Related skills
cloudrun-development-> container services, long-lived runtimes, Agent hostinghttp-api-cloudbase-> raw CloudBase HTTP API invocation patternscloudbase-platform-> general CloudBase platform decisionsops-inspector-> AIOps-style inspection and log search across services
Reference index
All packaged reference files (required for skill lint reachability):
- event-functions.md
- http-function-credentials.md
- http-functions-custom-image.md
- http-functions.md
- operations-and-config.md
- vpc-and-tcp-database.md
FAQ
What does the cloud-functions skill do?
CloudBase function runtime guide for building, deploying, and debugging your own Event Functions or HTTP Functions. This skill should be used when users need application runtime code on CloudBase, not when they are merely calling CloudBase official platform APIs.
How do I install cloud-functions?
Run npx skills add https://github.com/tencentcloudbase/cloudbase-ai-toolkit --skill cloud-functions in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/cloud-functions/ (personal) or .claude/skills/cloud-functions/ (project).
Which AI agents can use cloud-functions?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is cloud-functions safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains cloud-functions?
It is published by tencentcloudbase in tencentcloudbase/cloudbase-ai-toolkit. It has 54 recorded installs.
More from tencentcloudbase/cloudbase-ai-toolkit
miniprogram-development
tencentcloudbase/cloudbase-ai-toolkit
WeChat Mini Program development skill for building, debugging, previewing, testing, publishing, and optimizing mini program projects (小程序开发、调试、预览、发布). Covers project structure and config (project.config.json, appid, miniprogramRoot, tabBar, routing/navigation, icon assets), WeChat Developer Tools Nightly workflows (wechatide CLI, WeChat IDE Skills/MCP), miniprogram-ci preview/upload, console/network debugging, message push (消息推送) and customer-service auto-reply (客服消息), mini program SEO / search indexing (小程序搜索优化、页面收录、搜索推广、mpcrawler), and CloudBase integration (wx.cloud, 腾讯云开发, 云开发) when explicitly used. Use when users create, develop, modify, debug, preview, deploy, publish, or promote WeChat Mini Programs. NOT for Web frontend (use web-development), pure backend services (use cloudrun-development / cloud-functions), or UI-design-only tasks (use ui-design).
web-development
tencentcloudbase/cloudbase-ai-toolkit
Use when users need to implement, integrate, debug, build, deploy, or validate a Web frontend after the product direction is already clear, especially for React, Vue, Vite, browser flows, or CloudBase Web integration.
cloudbase-document-database-in-wechat-miniprogram
tencentcloudbase/cloudbase-ai-toolkit
Use CloudBase document database WeChat MiniProgram SDK to query, create, update, and delete data. Supports complex queries, pagination, aggregation, and geolocation queries.
cloudbase-platform
tencentcloudbase/cloudbase-ai-toolkit
CloudBase platform overview and routing guide. This skill should be used when users need high-level capability selection, platform concepts, console navigation, realtime (broadcast / presence / live database changes), or cross-platform best practices before choosing a more specific implementation skill.
auth-wechat-miniprogram
tencentcloudbase/cloudbase-ai-toolkit
Open the skill to read its SKILL.md instructions.
ai-model-wechat
tencentcloudbase/cloudbase-ai-toolkit
Open the skill to read its SKILL.md instructions.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.