Platform Access to TCB Solution
What CloudBase for Platform Is
A solution for platforms such as AI Coding, Vibe Coding, Agent (e.g., OpenClaw, Lovable, Bolt.new, Vercel v0, Figma Make), enabling any platform/Agent to configure and manage the backend on behalf of its users. The platform aims to provide end-users with a more seamless workflow and ready-to-use backend capabilities, while abstracting away the complexity of underlying resources such as databases, SCF, and COS—users can obtain a functional application through simple instructions or operations without needing to understand these concepts.
What You Get: TCB provides each of your tenants with a standalone environment, which includes databases, SCF, Static Hosting, and a unified HTTP access gateway. Resources are isolated between tenants, and you can automate management tasks—including creation, billing, deployment, database operations, and monitoring—through Tencent Cloud APIs.
Applicable Scenarios: SaaS, internal business platforms, multi-tenant systems, or AI Coding / Vibe Coding platforms—that require providing isolated backend capabilities for each customer/tenant and managing them via APIs rather than solely through consoles.
Management Unit: Based on environments. One environment = a complete set of resources for one tenant (database, SCF, HTTP access service, Static Hosting, etc.), typically one tenant per environment. All capabilities are managed programmatically via the Tencent Cloud TCB API.
Relationship Between Tencent Cloud Accounts and Environments: Adopts the Large Account Model—You use one Tencent Cloud account (master account or a sub-user with TCB permissions) to create multiple environments under this account. Each tenant corresponds to one environment, and resources and billing for all environments belong to this account, facilitating unified management and consolidated billing for you. The number of environments is subject to account quota limitations. Before creation, you can query the upper limit of environments via the API Query Environment Quota Limit; if you need to adjust the limit, you can contact us.
The hierarchy among accounts, environments, and resources is as follows:
Creating Environment and Billing
Create an environment for the new tenant and manage its billing and quotas.
Operation Steps
Step 1: Confirm Preconditions
Before creation, you need to use the following APIs to confirm account status and available resources:
- Check whether the TCB service has been activated: CheckTcbService
- Query the maximum number of environments: DescribeEnvLimit
- Obtain the available regions list: DescribeTcbRegions
- Obtain the available package list: DescribeBaasPackageList
Step 2: Call CreateEnv to create an environment
Call the CreateEnv API. The API will automatically place an order and deduct payment. Key parameters:
| Parameter | Description |
|---|---|
PackageId | Package ID, such as baas_personal; can be obtained via DescribeBaasPackageList |
Alias | Environment alias |
Resources | Resource types to be activated together, see the table below |
Period | Purchase duration (month, default is 1) |
Tags | Environment tags for permission isolation and resource grouping; recommended to tag by tenant ID and business line |
Resources optional values:
| Value | Description |
|---|---|
flexdb | Document Database (NoSQL), compatible with MongoDB-style APIs |
storage | COS (Cloud storage) |
function | SCF (including HTTP-triggered functions) |
Select from the above types based on business needs; other resources (such as MySQL) can be activated on-demand after environment creation.
Step 3: Wait for delivery and confirm the status
Environment delivery is an asynchronous process. Call DescribeEnvs to poll until the environment status becomes available. After confirmation, you can further query usage and billing:
- Query environment billing information: DescribeEnvBilling
- Query environment quota usage: DescribeEnvLimit
Quota Considerations: Both COS resources and SCF (non-Shanghai regions) have account-level or region-level quota limits. When planning to create a large number of environments in batches, we recommend conducting a quota assessment with the TCB team in advance.
Environment Lifecycle API Reference
- Create environment: CreateEnv
- List environments: DescribeEnvs
- Terminate an environment: DestroyEnv
- Reinstate an environment (lift isolation): ReinstateEnv
- Renew environment: RenewEnv
- Modify plan: ModifyEnvPlan
Deploying Backend Services for Tenants
Requests pass through the HTTP access service unified entry point and are routed to the corresponding SCF. Supports REST API, WebSocket long connections, and container image deployment.
The complete invocation process from obtaining environment information to becoming publicly accessible:
Operation Steps
Step 1: Obtain or create log configuration
Select based on the deployment method:
Code Package Deployment (ZIP / COS): Invoke DescribeEnvs, retrieve LogsetId / TopicId from EnvInfo.LogServices[0], then pass them in as ClsLogsetId / ClsTopicId when creating a function for log delivery.
Image Deployment: You need to manually create a logset and log topic:
- Invoke CreateLogset to create a logset and obtain the returned
LogsetId - Invoke CreateTopic to create a log topic, pass in the
LogsetIdfrom the previous step, and obtain the returnedTopicId
When creating a function subsequently, pass in LogsetId / TopicId as ClsLogsetId / ClsTopicId.
Step 2: Package and upload the code
Package the function directory into a ZIP file and Base64 encode it, with a limit of 50 MB. If it exceeds this limit, upload it to COS first, then reference it via CosBucketName / CosObjectName / CosBucketRegion (the bucket name does not include the -appid suffix, and the path starts with /).
Step 3: Create or update the function
Invoke CreateFunction or UpdateFunctionCode. Required parameters: Type: 'HTTP', Namespace (TCB environment ID), and Handler. For WebSocket functions, ProtocolType: 'WS' is additionally required. Refer to WebSocket Functions for details.
Step 4: Wait for function readiness
Poll ListFunctions until Status = Active is returned.
Step 5: Configure HTTP access service route
Invoke CreateCloudBaseGWAPI. Key parameters: EnableUnion: true, Path, ServiceId (environment ID), Type: 6, Name (function name), AuthSwitch: 2 (disable authentication), PathTransmission: 2 (path passthrough), EnableRegion: true, and Domain.
Step 6: Wait for service readiness
Poll DescribeCloudBaseGWAPI until APISet[0].UnionStatus = 1 is returned to obtain the external access address.
(Optional) Bind a custom domain name
Invoke BindCloudBaseAccessDomain with ServiceId (environment ID), Domain, and BindFlag: 2. For HTTPS, pass CertId (certificates must be pre-applied in the SSL Certificate Console). If using Tencent Cloud DNSPod for resolution, check whether the CNAME record exists via DescribeRecordFilterList. If it does not exist, create it by calling CreateRecord.
The above Cloud APIs can be uniformly initiated via the management-side SDK commonService; alternatively, directly use Tencent Cloud SDK 3.0 to invoke SCF APIs, supporting multiple languages including Python, Java, PHP, Go, Node.js, .NET, C++, and Ruby.
SCF API Reference
Pass the TCB environment ID in Namespace to operate functions in the corresponding environment. For complete parameters, see SCF API Overview.
- Obtain the function list: ListFunctions
- Create a function: CreateFunction
- Update the function code: UpdateFunctionCode
- Update the function configuration: UpdateFunctionConfiguration
- Obtain function details: GetFunction
- Delete a function: DeleteFunction
- Invoke a function: Invoke
- Obtain the download URL for the function code: GetFunctionAddress
WebSocket Functions
WebSocket Functions require the following additional parameters in CreateFunction beyond those of ordinary HTTP functions:
ProtocolType: 'WS',
ProtocolParams: {
WSParams: {
IdleTimeOut: 7200 // Connection idle timeout, 10–7200 sec
}
},
Timeout: 7200 // Function timeout, must be >= IdleTimeOut, 15–7200 sec
CAUTION: The function timeout must be ≥ the idle timeout; otherwise, creation will fail.
Single-instance multi-concurrency (session-based for WebSocket, request-based for ordinary HTTP):
InstanceConcurrencyConfig: {
DynamicEnabled: 'FALSE',
MaxConcurrency: 10,
Type: 'Session-Based', // Session-Based for WebSocket; Request-Based for HTTP
SessionConfig: {
SessionExpireTime: 7200,
IdleSessionExpireTime: 3600,
SessionDestroyStrategy: 'IdleDestroy',
SessionKeyType: 'Header',
SessionKey: 'x-ws-session'
},
InstanceIsolationEnabled: 'FALSE'
}
Container Image Deployment
Image deployment is suitable for scenarios with complex dependencies, large size, or requiring custom runtime environments. It can also be deployed via CLI.
Preconditions:
- Authorize Image Pull: Grant the policy
QcloudAccessForSCFRoleInPullImageto the SCF role (one-time operation): Click to Authorize - Prepare Image Repository: Create a repository in Tencent Cloud Container Registry (TCR); refer to Retrieving Access Credentials and Pushing Images.
- Image Requirements: Linux-based
amd64image, listening on port 9000 within the container.
When building on Apple Silicon Mac or other ARM-based machines, must add --platform linux/amd64; otherwise, the function will fail to start after deployment due to architecture mismatch:
docker build --platform linux/amd64 -t your-image-name .
During deployment, replace Code.ZipFile with Code.ImageConfig in CreateFunction:
Code: {
ImageConfig: {
ImageType: 'personal', // Personal Edition Repository
ImageUri: 'ccr.ccs.tencentyun.com/your-ns/your-image:tag',
// RegistryId: '' // To be filled for Enterprise Edition repository
}
}
Refer to: ImageConfig Parameter Description
HTTP Access Service API Reference
- Create route: CreateCloudBaseGWAPI
- Modify route: ModifyCloudBaseGWAPI
- Query route list: DescribeCloudBaseGWAPI
- Query route details: DescribeCloudBaseGWService
Domain and Secure Domain
Bind custom domains and certificates to the tenant environment's Static Hosting or HTTP Access Service; configure an allowlist of frontend secure domains that can initiate TCB requests.
Operation Steps
Step 1: Apply for SSL certificate
Before binding an HTTPS domain, you need to apply for or upload a certificate in the SSL Certificate Console and obtain the CertId.
Step 2: Bind a custom domain name
Select the corresponding API based on the purpose:
- HTTP Access Service domain: Invoke BindCloudBaseAccessDomain with
ServiceId(environment ID),Domain, andBindFlag: 2. For HTTPS, also passCertId. - Static Hosting domain: Invoke CreateHostingDomain. The task is asynchronous; poll the completion status via DescribeHostingDomainTask.
Step 3: Configure DNS CNAME
After binding, point your own domain to the access domain provided by CloudBase (e.g., xxx.tcbaccess.tencentcloudbase.com) via a CNAME record at your domain registrar. If using Tencent Cloud DNSPod, you can perform this operation via API:
- Check whether the CNAME record already exists: DescribeRecordFilterList
- If it does not exist, create a record: CreateRecord with
Valueset to the access domain
Access takes effect only after both domain binding and DNS resolution are completed.
Step 4: Configure Security Domain (Optional)
Secure domains control which frontend domains can initiate requests to TCB. Add the tenant's frontend domains to the allowlist:
- Add secure domain: CreateAuthDomain
- Obtain the list of secure domains: DescribeAuthDomains
Domain API Reference
- Bind HTTP Access Service domain: BindCloudBaseAccessDomain.
- Bind Static Hosting domain: CreateHostingDomain
- Query the status of the Static Hosting domain task: DescribeHostingDomainTask
- Add secure domain: CreateAuthDomain
- Obtain the list of secure domains: DescribeAuthDomains
Database
Each environment provides two types of database capabilities, with tenants isolated by environment.
- Document Database (FlexDB / NoSQL): Stores data in collections and documents, compatible with MongoDB-style APIs, supports collection CRUD operations and index management. During environment creation, select
flexdbinResourcesto enable it. - Relational Database (MySQL): Supports standard SQL and DDL, table structure management; frontend can access via Web SDK using Supabase-style API.
- Permissions and Security: Supports database-level ACL and table-level security rules to control read/write scopes and row-level access.
Document Database
Operation Steps
Step 1: Activate
During environment creation, pass flexdb in Resources to enable it together without additional operations.
Step 2: Create Collection
Call CreateTable to create a collection, passing EnvId and the collection name.
Step 3: Manage Indexes and Permissions
- Query or modify collection indexes: UpdateTable
- Configure read/write permissions and security rules to control tenant data access scope
Document Database API Reference
- Create a collection: CreateTable
- Query collection information: DescribeTable
- List all collections: ListTables
- Modify collection indexes: UpdateTable
- Delete a collection: DeleteTable
- Modify database permissions: ModifyDatabaseACL
- obtain database permissions: DescribeDatabaseACL
- Query security rules: DescribeSecurityRule
MySQL
Operation Steps
Step 1: Enable MySQL
Call CreateMySQL to enable. The API is asynchronous; poll for results through the following API:
- Describe the creation result: DescribeCreateMySQLResult
- Describe task status: DescribeMySQLTaskStatus
Step 2: Initialize Table Structure
After the service is enabled, execute DDL statements such as creating tables and indexes through RunSql.
Step 3: Configure Accounts and Access Permissions
- Describe existing accounts: DescribeAccounts
- Reset account password: ResetAccountPassword
- Modify account privileges (isolate read/write scope by tenant): ModifyAccountPrivileges
MySQL API Reference
Lifecycle Management (tcb.tencentcloudapi.com):
- Create MySQL: CreateMySQL
- Describe the creation result: DescribeCreateMySQLResult
- Describe task status: DescribeMySQLTaskStatus
- Describe cluster information: DescribeMySQLClusterDetail
- Execute SQL statements: RunSql
- Terminate MySQL: DestroyMySQL
Account Management (cynosdb.tencentcloudapi.com):
- Describe account list: DescribeAccounts
- Reset account password: ResetAccountPassword
- Modify account privileges: ModifyAccountPrivileges
- Modify account configuration: ModifyAccountParams
Connection and Clusters (cynosdb.tencentcloudapi.com):
- Open public network: OpenWan
- Disable public network: CloseWan
- Describe cluster parameters: DescribeClusterParams
- Modify cluster parameters: ModifyClusterParam
Backup (cynosdb.tencentcloudapi.com):
- Create manual backup: CreateBackup
- Delete manual backup: DeleteBackup
- Obtain backup download URL: DescribeBackupDownloadUrl
Monitoring and Logs
View monitoring curves and HTTP access service running status by environment, and search CLS logs for troubleshooting and usage analysis.
Operation Steps
Step 1: Query Monitoring Data
Select granularity as needed:
- Environment-level monitoring curves (call volume, traffic, etc.): DescribeCurveData
- Environment-level monitoring metric data: DescribeGraphData
- HTTP access service (gateway) monitoring: DescribeGatewayData
Step 2: Search Logs
Select the corresponding log search method based on the SCF deployment method:
Code package deployment (ZIP / COS): Call SearchClsLog, and pass in:
EnvId: Environment ID- Time range
QueryString: Follow CLS syntax, such asmodule:database,src:app
A maximum of 100 results can be returned per request, supporting cursor-based pagination (up to 10,000 results).
Image Deployment: Logs for image-deployed SCF are queried through CLS (Log Service). Call SearchLog, passing in the TopicId and time range configured when creating the function.
Monitoring and Logs API Reference
- Query environment monitoring curves: DescribeCurveData
- Query environmental monitoring data: DescribeGraphData
- Query gateway monitoring data: DescribeGatewayData
- Search user invocation logs (code package deployment): SearchClsLog
- Search logs (image deployment): SearchLog
Development and Integration Method
Based on your technology stack and scenarios, you can choose the following methods to manage environments and resources:
| Method | Applicable Scenarios | Documentation |
|---|---|---|
| Management-side SDK (Node.js) | Integration in own systems or scripts, recommended as the preferred choice | Management-side SDK Documentation |
| Management Plane API | Directly invoke REST APIs and integrate with existing backend systems | TCB API Introduction |
| MCP Tool | AI Coding platforms (Cursor, Claude Code, etc.), where AI Agents invoke CloudBase capabilities | CloudBase MCP, Using Skills |
MCP provides two connection modes: local mode and hosted mode. For details, see Connection Modes:
Local Mode (recommended): MCP Server starts up locally via npx, offering the most comprehensive features (including file upload, template download, and other capabilities dependent on the local file system). Requires Node.js to be installed locally.
{
"mcpServers": {
"cloudbase": {
"command": "npx",
"args": ["@cloudbase/cloudbase-mcp@latest"],
"env": {
"CLOUDBASE_ENV_ID": "<env_id>",
"TENCENTCLOUD_SECRETID": "<SecretId>",
"TENCENTCLOUD_SECRETKEY": "<SecretKey>"
}
}
}
}
Hosted Mode: MCP Server runs on Tencent Cloud. The IDE connects via HTTP without requiring local Node.js installation, but does not support local file operations (such as downloading templates to the local machine).
{
"mcpServers": {
"cloudbase": {
"type": "http",
"url": "https://tcb-api.cloud.tencent.com/mcp/v1?env_id=<env_id>",
"headers": {
"X-TencentCloud-SecretId": "<SecretId>",
"X-TencentCloud-SecretKey": "<SecretKey>"
}
}
}
}
Hosted mode supports disabling specified plugins via the URL parameter disable_plugins (e.g., &disable_plugins=rag&disable_plugins=env); Available plugins: env, database, functions, hosting, storage, setup, rag, cloudrun, gateway, security-rule, capi, etc.; For the complete list of tools, see MCP Tools Documentation.
Recommended Implementation Sequence
- Environment Creation and Billing: Completes the creation and billing activation of a single-tenant environment and supports usage query.
- Deploy Backend: Deploys HTTP-triggered SCF to provide API or WebSocket capabilities to external systems.
- HTTP Access Service and Domains: Configure routing and custom domains to achieve external exposure and access control.
- Database and Permissions: Provision databases and create tables for tenants, and configure permissions and security rules.
- Monitoring and Logging: Perform troubleshooting and usage analysis through monitoring curves and CLS logs.
Terminology
| Term | Description |
|---|---|
| Environment | A complete set of resources for one tenant (database, SCF, HTTP access service, Static Hosting, etc.), typically one tenant per environment. |
| HTTP-triggered SCF | On-demand executed cloud functions that expose URLs via HTTP access services, suitable for REST APIs and lightweight logic. |
| HTTP Access Service | A unified HTTP entry point that routes requests to HTTP-triggered SCF (referred to as such in Tencent Cloud documentation). |
Reference Resources
Official Documentation
AI Coding / MCP
- CloudBase MCP
- MCP Tool List
- MCP Connection Modes (Local / Hosted)
- Rules / Skills(GitHub)
- Project Templates
Platform Access Integration