Skip to content

Commit 6cbbdaf

Browse files
chore: sync from CloudBase-MCP
1 parent 589dc40 commit 6cbbdaf

7 files changed

Lines changed: 294 additions & 7 deletions

File tree

‎generated/skill-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 2,
3-
"generatedAt": "2026-10-10T08:11:58.547Z",
3+
"generatedAt": "2026-10-12T09:26:53.384Z",
44
"skills": {
55
"ai-model-nodejs": {
66
"name": "ai-model-nodejs",

‎skills/cloud-api-operations/SKILL.md‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,23 @@ Priority rule: if `@cloudbase/manager-node` has a matching method, use it; drop
4646

4747
### 3. Check credentials before the first call
4848

49+
**Three identities produce the same error text.** Before reading anything into an `UnauthorizedOperation`, find out which one you are holding:
50+
51+
| Identity | How it is reached | CAM / CloudAudit |
52+
| --- | --- | --- |
53+
| Account-level login (`federated-user/<id>`) | Device-code / web login, or account-level SecretId + Key | reachable, subject to that identity's CAM policies |
54+
| `TCB_QcsRole` service role | what CLI / MCP **become** after calling a CloudBase product API | refused (`resource (...) has no permission`) |
55+
| Environment API Key (`<uin>:TCB-CAPI-Configured-idaas-apikey`) | `--cloudbase-api-key -e <envId>` | refused — the API Key model has no channel to attach arbitrary CAM policies |
56+
57+
Confirm the identity with `sts GetCallerIdentity` (`--api-version 2018-08-13`) before concluding anything: the refusal text is identical across all three rows, so it cannot tell you which row you are in.
58+
59+
**Order matters.** Calling a CloudBase product API swaps the identity to `TCB_QcsRole` for the rest of the session, so a CAM / CloudAudit call issued *after* any product call is refused even though the login is account-level. Do the CAM / audit work **first**.
60+
4961
- Read the current credential scope from `auth` tools: `credential_scope: account` = account-level, reaches control-plane APIs subject to that identity's CAM policies; `env` = API Key, scoped to one environment's data plane plus the fixed TCB policies.
5062
- Permission comes from a different place per credential identity: the account-level identity's own policies, the API Key model (no channel to attach arbitrary CAM policies), or the TCB service role that CLI / MCP assume. Which cross-product capabilities that role family already covers is not fixed — read the attached policies (`ListAttachedRolePolicies` + `GetPolicy`) instead of assuming, and treat `UnauthorizedOperation` as "this identity lacks this action", never as a broken setup.
5163
- On `UnauthorizedOperation` / `AuthFailure`, hand the user a **one-click CAM grant link** (role name + policy name + `principal`) instead of telling them to go find the policy in the console, then retry the original call. Role targets, the `principal` values, and which preset policy covers what: `./references/calling-methods.md` §3.
5264

53-
**Done when**: the credential identity is known, and every permission error has been converted into a clickable authorization link carrying a concrete policy name before any retry.
65+
**Done when**: the credential identity has been confirmed with `sts GetCallerIdentity` (not inferred from the error text), and every permission error has been converted into a clickable authorization link carrying a concrete policy name before any retry.
5466

5567
### 4. Follow a proven recipe when one exists
5668

@@ -60,6 +72,7 @@ Recipes encode the exact call sequence, required parameters, and empirically dis
6072
- **ICP filing readiness and wait-time checks**: `./references/recipes/icp-filing-readiness.md`
6173
- **PostgreSQL instance spec change and shared-to-dedicated upgrade**: `./references/recipes/pg-instance-spec.md`
6274
- **Custom domain onboarding for an env (HTTP access domain, certificate, DNS binding)**: `./references/recipes/custom-domain.md`
75+
- **Operation trace / 操作审计 — who did what, from which IP, with which key**: `./references/recipes/cloud-audit-operation-trace.md`
6376

6477
**Done when**: every parameter value in the call sequence traces to a recipe value marked as verified (实测) or to official docs.
6578

‎skills/cloud-api-operations/references/calling-methods.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ TCB 服务角色族挂的是 TCB 自己声明的策略集(`QcloudAccessForTCBR
9797
**角色挂载的策略会随产品迭代变化**,别照着文档里的旧结论判断。确认当前覆盖范围要现场读,但**读 cam 需要调用身份自己就有 cam 策略**:
9898

9999
1. `ListAttachedRolePolicies`:看角色挂了哪些策略
100-
2. `GetPolicy(PolicyId=…)`:读该策略的 `PolicyDocument`,逐条看 `action` 数组里有没有你要的 Action
100+
2. `GetPolicy(PolicyId=…)`:直接回 `PolicyDocument` —— 一段**字符串**,二次解析后看 `statement[].action`;`GetPolicyVersion` 也能读,但 `VersionId` **必须是数字**(传字符串报 `InvalidParameter ... should be uint64`)
101101

102-
实测边界(2026-09-24,账号级 device 登录):`cam/GetRole`、`cam/ListAttachedRolePolicies`、`cam/ListPolicies` **三个都返回 `UnauthorizedOperation`**(`qcs::cam:::role/<roleId> has no permission`、`resource (*) has no permission`)。原因是调用者拿的正是 `TCB_QcsRole` 换来的临时密钥,而该角色自己没有 cam 读权限 —— 于是「想查清楚缺什么权限」这件事本身就要先有权限。所以**不要指望现场读出角色载体**,§3.2 的 `principal` 用固定值;真要读 cam,让用户换一个有 `QcloudCamReadOnlyAccess` 的身份。
102+
⚠️ **能不能读,取决于调用那一刻的身份,而不是「登录时是谁」**:账号级身份(`federated-user`)下 `GetRole` / `ListAttachedRolePolicies` / `ListPolicies` / `GetPolicy` 都**能调通**(2026-10-12 实测);一旦调过云开发产品接口、身份被换成 `TCB_QcsRole`,同一批调用全被拒(`resource (*) has no permission`)。⇒ **要读 cam 就先读 cam**;真读不了再让用户换一个有 `QcloudCamReadOnlyAccess` 的身份。读不了不影响 §3.2 —— 那里的 `principal` 用固定值。
103103

104104
**确认「我到底是谁」用 `sts/GetCallerIdentity`,不依赖 cam**:返回 `Type`(`CAMRole` / `Account`)、`Arn`、`UserId`;以 `TCB_QcsRole` 调用时 `UserId` 形如 `<ownerUin>:TCB_QcsRole-<uin>-<timestamp>`。哪一行身份由此判定,比 `credential_scope` 更准 —— `credential_scope: account` 只说明「不是环境级 API Key」,实际落地仍可能是角色扮演身份。
105105

@@ -130,6 +130,8 @@ https://console.cloud.tencent.com/cam/role/grant?roleName=<角色名>&policyName
130130

131131
链接是**一次性操作**:用户点完授权,重试原调用即可。
132132

133+
> 当前身份已经是**账号级**(`federated-user`)时,也可以不等人点,直接调 `cam/ListPolicies` → `cam/AttachRolePolicy` → `cam/ListAttachedRolePolicies` 把它挂上(可重复执行);入参见 [`./recipes/cloud-audit-operation-trace.md`](./recipes/cloud-audit-operation-trace.md) 的「给服务角色补权限」。
134+
133135
两条使用边界,写进给用户的说明里:
134136

135137
- **点链接的人得有权授**。授权页要主账号或具备 CAM 写权限的身份登录;子账号点开同样授不了 —— 别把这条链接当万能兜底。
@@ -150,6 +152,8 @@ https://console.cloud.tencent.com/cam/role/grant?roleName=<角色名>&policyName
150152
| DNS 解析记录(DNSPod 的域名、记录增删改查) | `QcloudDNSPodFullAccess` |
151153
| 只读 DNS 解析记录 | `QcloudDNSPodReadOnlyAccess` |
152154
| 读 PostgreSQL 实例(`postgres:DescribeDBInstances` …) | `QcloudPostgreSQLReadOnlyAccess`(覆盖所有 `Describe*` / `Inquiry*`) |
155+
| 读操作审计事件(`cloudaudit:LookUpEvents` / `DescribeEvents` …) | `QcloudAuditReadOnlyAccess` |
156+
| 建/改云审计跟踪集(把日志投递到 COS / CLS) | `QcloudAuditFullAccess` |
153157

154158
两条容易踩的:
155159

‎skills/cloud-api-operations/references/recipes/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
| 2 | ICP 备案提交前自查与等待期查询 | [icp-filing-readiness.md](./icp-filing-readiness.md) | ✅ 生产实证(2026-09-21) |
2323
| 3 | PostgreSQL 实例变配与升级独享 | [pg-instance-spec.md](./pg-instance-spec.md) | 🟡 部分实证(2026-09-24):`ModifyPGInstanceSpec` 升配 + 降配已跑通;**共享升独享未跑**(账号下的 PG 实例全是独享形态,该接口只接受共享实例,只拿到前置条件报错原文);「费用与套餐」一节的资源点单价与「无需升级套餐」、以及「目标 = 现状回 `unchanged`」按文档与界面核对,**未实跑** |
2424
| 4 | 自定义域名接入云开发 | [custom-domain.md](./custom-domain.md) | 🟡 部分实证(2026-09-24):现状查询、只读预检、证书读取、真实绑定与解绑(含收尾)已跑通;**未跑**——轮询到 `Status = SUCCESS`(测试域名一直停在 `PROCESSING`)、代改 DNS 解析、备案(`dnspod` / `ba` 未授权) |
25+
| 5 | 云开发环境的操作追溯(操作审计) | [cloud-audit-operation-trace.md](./cloud-audit-operation-trace.md) | 🟡 部分实证(2026-10-12):账号级身份下的 `LookUpEvents` 只读查询、`cam AttachRolePolicy` 挂 `QcloudAuditReadOnlyAccess`(挂后 `ListAttachedRolePolicies` 复核条数 +1)已跑通;**未跑**——`DescribeEvents` 全序列、`GetAttributeKey`、以及**角色态(`TCB_QcsRole`)下 `cloudaudit` 是否可见**(要等一个走角色态的 MCP 会话才能验) |
2526

2627
## 没有独立 recipe 的场景
2728

0 commit comments

Comments
 (0)