cloud-functions

6
1
Source

Complete guide for CloudBase cloud functions development - runtime selection, deployment, logging, invocation, and HTTP access configuration.

Install

mkdir -p .claude/skills/cloud-functions && curl -L -o skill.zip "https://mcp.directory/api/skills/download/4885" && unzip -o skill.zip -d .claude/skills/cloud-functions && rm skill.zip

Installs to .claude/skills/cloud-functions

About this skill

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.

Read before writing code if

  • The request mentions runtime, HTTP function, scf_bootstrap, function logs, or function deployment.

Then also read

  • Auth setup or provider-related backend work -> ../auth-tool/SKILL.md
  • AI in functions -> ../ai-model-nodejs/SKILL.md

Do NOT use for

  • CloudRun container services or Web authentication UI implementation.

Common mistakes / gotchas

  • Picking the wrong function type and trying to compensate later.
  • Mixing Event Function code shape (exports.main(event, context)) with HTTP Function code shape (req / res on port 9000).
  • 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.
  • Forgetting that runtime cannot be changed after creation.
  • Using cloud functions as the first solution for Web login.
  • Forgetting that HTTP Functions do NOT auto-install dependencies — always include node_modules.
  • Forgetting to add app.use(express.json()) or equivalent body parsing middleware for POST/PUT requests.
  • Leaving HTTP handlers without sending a response (causes request timeout).
  • Not returning proper HTTP status codes (400, 401, 405) for error cases.

Minimal checklist

Overview

Use this skill when developing, deploying, and managing CloudBase cloud functions. CloudBase supports two types of cloud functions:

  • Event Functions (普通云函数): Traditional serverless functions triggered by events (SDK calls, timers)
  • HTTP Functions (HTTP 云函数): Web service functions triggered by HTTP requests, supporting multiple languages

Writing mode at a glance

  • If the request is for a normal CloudBase function triggered by SDK calls, timers, or other events, write an Event Function with exports.main = async (event, context) => {}.
  • If the request is for an HTTP endpoint, REST API, SSE, or WebSocket service, write an HTTP Function that listens on port 9000 and handles req / res.
  • If the user mentions HTTP access for an existing Event Function, keep the Event Function code shape and add gateway access separately.

When to use this skill

Use this skill for cloud function operations when you need to:

  • Create and deploy Event Functions (Node.js)
  • Create and deploy HTTP Functions (Node.js/Python/Go/Java)
  • Understand runtime limitations and selection
  • Query function logs and monitor execution
  • Invoke cloud functions from applications
  • Configure HTTP access for cloud functions
  • Implement SSE (Server-Sent Events) or WebSocket

Do NOT use for:

  • CloudRun backend services (use cloudrun-development skill)
  • Complex container-based services (use cloudrun-development skill)
  • Database operations (use database skills)

How to use this skill (for a coding agent)

  1. Choose the right function type

    • Event Function: For SDK calls, scheduled tasks, event-driven scenarios
    • HTTP Function: For Web APIs, REST services, SSE/WebSocket, multi-language support
    • If the prompt says "HTTP 云函数", use the HTTP Function model first; if it says "触发器云函数" or omits HTTP, default to the Event Function model.
  2. Understand runtime limitations

    • Runtime CANNOT be changed after function creation
    • Must select correct runtime during initial creation
    • If runtime needs to change, must delete and recreate function
  3. Write code AND deploy — do not stop after writing files

    • CRITICAL: After writing function code, you MUST also deploy it using manageFunctions. Creating files locally without deploying is incomplete.
    • Use manageFunctions(action="createFunction") to create AND deploy in one step
    • Provide functionRootPath as the parent directory of the function folder (e.g., /project/cloudfunctions/ not /project/cloudfunctions/myFunction/)
    • Preferred MCP Tools: Use queryFunctions for reads, manageFunctions(action="createFunction") for creation, and manageFunctions(action="updateFunctionCode") for code updates
    • Legacy compatibility: If older prompts mention createFunction / updateFunctionCode, map them to the manageFunctions actions above
    • CLI: Use tcb fn deploy (Event) or tcb fn deploy --httpFn (HTTP) only as a fallback when MCP tools are unavailable
    • In agent / non-interactive runs, never default to CLI login flows for deployment; keep the flow on manageFunctions
    • For HTTP functions, create or update them through manageFunctions with func.type="HTTP" as the primary path
    • HTTP Functions require scf_bootstrap file in the function directory
    • Provide correct functionRootPath (parent directory of function folder)
  4. Query logs properly

    • Use queryFunctions(action="listFunctionLogs") for log list (basic info)
    • Use queryFunctions(action="getFunctionLogDetail") with RequestId for detailed logs
    • Legacy compatibility: Treat getFunctionLogs / getFunctionLogDetail as the two queryFunctions actions above
    • Note time range limitations (max 1 day interval)
  5. Handle legacy tool names safely

    • Prefer the converged entrances: queryFunctions, manageFunctions, queryGateway, manageGateway
    • If old names appear in historical docs or prompts, convert them before acting:
      • getFunctionList -> queryFunctions
      • createFunction -> manageFunctions(action="createFunction")
      • updateFunctionCode -> manageFunctions(action="updateFunctionCode")
      • updateFunctionConfig -> manageFunctions(action="updateFunctionConfig")
      • getFunctionLogs -> queryFunctions(action="listFunctionLogs")
      • getFunctionLogDetail -> queryFunctions(action="getFunctionLogDetail")
      • manageFunctionTriggers -> manageFunctions(action="createFunctionTrigger"|"deleteFunctionTrigger")
      • readFunctionLayers -> queryFunctions(action="listLayers"|"listLayerVersions"|"getLayerVersionDetail"|"listFunctionLayers")
      • writeFunctionLayers -> manageFunctions(action="createLayerVersion"|"deleteLayerVersion"|"attachLayer"|"detachLayer"|"updateFunctionLayers")
      • createFunctionHTTPAccess -> manageGateway(action="createAccess")

Function Types Comparison

FeatureEvent Function (普通云函数)HTTP Function (HTTP 云函数)
TriggerEvent-driven (SDK, timer)HTTP request
Entry Pointexports.main = async (event, context) => {}Web Server (Express/Flask/Gin etc.)
PortNo port requiredMust listen on port 9000
BootstrapNot requiredRequires scf_bootstrap
ConnectionShort connectionSupports long connection
LanguagesNode.js onlyNode.js, Python, Go, Java
ProtocolsN/AHTTP, SSE, WebSocket
Use CasesEvent processing, scheduled tasksWeb APIs, REST services, real-time streaming

Core Knowledge - Event Functions

Runtime Environment

⚠️ CRITICAL: Runtime cannot be modified after function creation

Once a cloud function is created with a specific runtime, the runtime cannot be changed. If you need a different runtime:

  1. Delete the existing function
  2. Create a new function with the desired runtime

Supported Node.js Runtimes:

  • Nodejs18.15 (Default, Recommended)
  • Nodejs16.13
  • Nodejs14.18
  • Nodejs12.16
  • Nodejs10.15
  • Nodejs8.9

Runtime Selection Guidelines:

  • Use Nodejs18.15 for new projects (default, most modern)
  • Choose older versions only if dependencies require specific Node.js versions
  • Consider security updates and support lifecycle
  • Test thoroughly with selected runtime before deployment

Event Function Structure

Event functions require:

  1. Function Directory: Contains function code

    • Must have index.js (or specified entry file)
    • Must export handler: exports.main = async (event, context) => {}
    • Include package.json with dependencies
  2. Function Root Path: Parent directory containing function directories

    • Example: If function is at /project/cloudfunctions/myFunction/
    • functionRootPath should be /project/cloudfunctions/
    • Important: Do NOT include function name in root path
  3. Entry Point: Default is index.js with exports.main

    • Can be customized via handler parameter

Event Function Deployment

Creating New Functions:

Use manageFunctions(action="createFunction") (see MCP tool documentation for full parameter list):

  • Important: Always specify func.runtime explicitly (defaults to Nodejs18.15)
  • Provide functionRootPath as parent directory of function folders (absolute path)
  • Use force=true to overwrite existing function
  • Legacy compatibility: If an older prompt says createFunction, keep the same payload but send it through manageFunctions

Updating Function Code:

Use manageFunctions(action="updateFunctionCode"):

  • ⚠️ Note: Only updates code, cannot change runtime
  • If runtime needs to change, delete and recreate function
  • Legacy compatibility: If an older prompt says updateFunctionCode, map it to this manageFunctions action

Deployment Best Practices:

  1. Always specify runtime explicitly when creating functions
  2. Use absolute paths for functionRootPath
  3. Don't upload node_modules - dependencies installed automatically
  4. Test locally before deployment when possible
  5. Use environment variables for configuration, not hardcoded values

Core Knowledge - HTTP Functions

HTTP Function Overview

HTTP Functions are optimized for Web service scenarios, supporting standard HTTP request/response patterns.

**HTTP Function codi


Content truncated.

miniprogram-development

TencentCloudBase

WeChat Mini Program development rules. Use this skill when developing WeChat mini programs, integrating CloudBase capabilities, and deploying mini program projects.

6425

spec-workflow

TencentCloudBase

Standard software engineering workflow for requirement analysis, technical design, and task planning. Use this skill when developing new features, complex architecture designs, multi-module integrations, or projects involving database/UI design.

867

web-development

TencentCloudBase

Web frontend project development rules. Use this skill when developing web frontend pages, deploying static hosting, and integrating CloudBase Web SDK.

105

ai-model-nodejs

TencentCloudBase

Use this skill when developing Node.js backend services or CloudBase cloud functions (Express/Koa/NestJS, serverless, backend APIs) that need AI capabilities. Features text generation (generateText), streaming (streamText), AND image generation (generateImage) via @cloudbase/node-sdk ≥3.16.0. Built-in models include Hunyuan (hunyuan-2.0-instruct-20251111 recommended), DeepSeek (deepseek-v3.2 recommended), and hunyuan-image for images. This is the ONLY SDK that supports image generation. NOT for browser/Web apps (use ai-model-web) or WeChat Mini Program (use ai-model-wechat).

63

cloudbase-document-database-in-wechat-miniprogram

TencentCloudBase

Use CloudBase document database WeChat MiniProgram SDK to query, create, update, and delete data. Supports complex queries, pagination, aggregation, and geolocation queries.

61

auth-web-cloudbase

TencentCloudBase

CloudBase Web Authentication Quick Guide - Provides concise and practical Web frontend authentication solutions with multiple login methods and complete user management.

51

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,5731,370

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,1161,191

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,4181,109

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,197748

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,154684

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,318617

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.