Skip to content

Commit 50813e3

Browse files
author
CodeBuddy Attribution Bot
committed
fix(attribution): MCP DestroyEnv 工具参数设计不清晰导致 400 错误 (issue_mo8xbscc_lyduht)
1 parent e2ca73f commit 50813e3

2 files changed

Lines changed: 69 additions & 21 deletions

File tree

mcp/src/generated/tcb-action-index.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
5050
],
5151
"exampleParams": {
5252
"Alias": "cloudbase",
53-
"AutoVoucher": "true",
53+
"AutoVoucher": true,
5454
"Channel": "qc_console",
5555
"EnvId": "my-env-i3jkguiejls",
5656
"PackageId": "baas_personal",
57-
"Period": "1",
57+
"Period": 1,
5858
"RenewFlag": "NOTIFY_AND_MANUAL_RENEW",
5959
"Resources": "[\"flexdb\"]",
6060
"Source": "qcloud",
@@ -220,7 +220,7 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
220220
"requiredKeys": [],
221221
"exampleParams": {
222222
"EnvId": "env-xxyyzzaa",
223-
"NeedOrderInfo": "true",
223+
"NeedOrderInfo": true,
224224
"ResourceId": "weda.xxxxdad",
225225
"WxAppId": "wxasdkfjdkjfk"
226226
},
@@ -299,7 +299,7 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
299299
"EndTime": "2019-04-04 19:00:00",
300300
"EnvId": "lotestapi100004",
301301
"MetricName": "DbSizepkg",
302-
"Period": "300",
302+
"Period": 300,
303303
"ResourceID": "ibot-agent1",
304304
"StartTime": "2019-04-02 09:00:00",
305305
"SubresourceID": "deepseek",
@@ -430,8 +430,8 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
430430
],
431431
"exampleParams": {
432432
"EnvId": "lowcode-abc",
433-
"MgoLimit": "10",
434-
"MgoOffset": "0",
433+
"MgoLimit": 10,
434+
"MgoOffset": 0,
435435
"MongoConnector": "无",
436436
"TableNames": "[\"table_name\"]",
437437
"Tag": "tnt-abc"
@@ -460,8 +460,8 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
460460
"EnvId": "test_envId",
461461
"Name": "zhang",
462462
"NickName": "张",
463-
"PageNo": "1",
464-
"PageSize": "10",
463+
"PageNo": 1,
464+
"PageSize": 10,
465465
"Phone": "13900139000"
466466
},
467467
"paramsType": "/**\n * 查询tcb用户列表\n */\ntype DescribeUserListParams = {\n /**\n * 邮箱,模糊查询\n */\n \"Email\"?: string;\n /**\n * 环境id\n */\n \"EnvId\": string;\n /**\n * 用户名,模糊查询\n */\n \"Name\"?: string;\n /**\n * 用户昵称,模糊查询\n */\n \"NickName\"?: string;\n /**\n * 页码,从1开始,默认1\n */\n \"PageNo\"?: number;\n /**\n * 每页数量,默认20,最大100\n */\n \"PageSize\"?: number;\n /**\n * 手机号,模糊查询\n */\n \"Phone\"?: string;\n};"
@@ -482,11 +482,11 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
482482
"EnvId"
483483
],
484484
"exampleParams": {
485-
"BypassCheck": "false",
486-
"BypassLimit": "false",
487-
"DeleteDirectly": "false",
485+
"BypassCheck": false,
486+
"BypassLimit": false,
487+
"DeleteDirectly": false,
488488
"EnvId": "yourenvid-2fb346",
489-
"IsForce": "false"
489+
"IsForce": false
490490
},
491491
"paramsType": "/**\n * 销毁环境\n */\ntype DestroyEnvParams = {\n /**\n * 是否绕过资源检查,资源包等额外资源,默认为false,如果为true,则不检查资源是否有数据,直接删除。\n */\n \"BypassCheck\"?: boolean;\n /**\n * 销毁消耗用户删除配额 默认为false-占用配额 true-不占用配额\n */\n \"BypassLimit\"?: boolean;\n /**\n * 是否自动删除环境。(仅在IsForce=false时,且仅对预付费环境有效)\n */\n \"DeleteDirectly\"?: boolean;\n /**\n * 环境Id\n */\n \"EnvId\": string;\n /**\n * 针对预付费 删除隔离中的环境时要传true 正常环境直接跳过隔离期删除\n */\n \"IsForce\"?: boolean;\n};"
492492
},
@@ -557,11 +557,11 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
557557
"exampleParams": {
558558
"EnvId": "lowcode-abc",
559559
"Filters": "[\"HIDDEN\"]",
560-
"MgoLimit": "10",
561-
"MgoOffset": "0",
560+
"MgoLimit": 10,
561+
"MgoOffset": 0,
562562
"MongoConnector": "无",
563563
"SearchValue": "prefix",
564-
"ShowHidden": "false",
564+
"ShowHidden": false,
565565
"Tag": "tag-123"
566566
},
567567
"paramsType": "/**\n * 查询文档型数据库所有表\n */\ntype ListTablesParams = {\n /**\n * 云开发环境ID\n */\n \"EnvId\"?: string;\n /**\n * 过滤标签数组,用于过滤表名,可选值如:HIDDEN、WEDA、WEDA_SYSTEM\n */\n \"Filters\"?: (string)[];\n /**\n * 每页返回数量(0-1000)\n */\n \"MgoLimit\": number;\n /**\n * 分页偏移量\n */\n \"MgoOffset\"?: number;\n /**\n * MongoDB连接器配置\n */\n \"MongoConnector\"?: {\n /**\n * MongoDB数据库名\n */\n \"DatabaseName\"?: string;\n /**\n * 连接器实例ID\n */\n \"InstanceId\"?: string;\n };\n /**\n * 模糊搜索查询值\n */\n \"SearchValue\"?: string;\n /**\n * 是否展示隐藏表\n */\n \"ShowHidden\"?: boolean;\n /**\n * FlexDB实例ID\n */\n \"Tag\"?: string;\n};"
@@ -580,7 +580,7 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
580580
],
581581
"exampleParams": {
582582
"EnvId": "env-xxxxxx",
583-
"Period": "10"
583+
"Period": 10
584584
},
585585
"paramsType": "/**\n * 修改日志主题\n */\ntype ModifyClsTopicParams = {\n /**\n * 环境ID\n */\n \"EnvId\": string;\n /**\n * 日志生命周期,单位天,可取值范围1~3600,取值为3640时代表永久保存\n */\n \"Period\"?: number;\n};"
586586
},
@@ -651,7 +651,7 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
651651
"PackageId"
652652
],
653653
"exampleParams": {
654-
"AutoVoucher": "true",
654+
"AutoVoucher": true,
655655
"EnvId": "cloudbase-8grqda2hfc2f62bb",
656656
"PackageId": "baas_pf_standard"
657657
},
@@ -680,7 +680,7 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
680680
"CollectionName": "my-table",
681681
"EnvId": "myenv-c849jgkdldcmsd",
682682
"Rule": "{ \"read\": true, \"write\": \"doc._openid == auth.openid\" }",
683-
"SyncModel": "false",
683+
"SyncModel": false,
684684
"WxAppId": "wxg89jkjdkf034kgjlsdk"
685685
},
686686
"paramsType": "/**\n * 设置数据库安全规则\n */\ntype ModifySafeRuleParams = {\n /**\n * 权限标签。包含以下取值:\n * - READONLY:所有用户可读,仅创建者和管理员可写\n * - PRIVATE:仅创建者及管理员可读写\n * - ADMINWRITE:所有用户可读,仅管理员可写\n * - ADMINONLY:仅管理员可读写\n * - CUSTOM:自定义安全规则\n */\n \"AclTag\": string;\n /**\n * 集合名称\n */\n \"CollectionName\": string;\n /**\n * 环境ID\n */\n \"EnvId\": string;\n /**\n * 安全规则内容。\n * 当 AclTag=CUSTOM 时,此参数必填。\n * 详情参考:[文档型数据库安全规则](https://docs.cloudbase.net/database/security-rules)\n */\n \"Rule\"?: string;\n /**\n * 是否同步数据模型,默认同步\n */\n \"SyncModel\"?: boolean;\n /**\n * 微信 AppId,微信必传\n */\n \"WxAppId\"?: string;\n};"
@@ -760,9 +760,9 @@ export const TCB_ACTION_INDEX_MAP: Record<string, TcbActionIndexEntry> = {
760760
"EnvId"
761761
],
762762
"exampleParams": {
763-
"AutoVoucher": "true",
763+
"AutoVoucher": true,
764764
"EnvId": "cloudbase-8grqda2hfc2f62bb",
765-
"Period": "1"
765+
"Period": 1
766766
},
767767
"paramsType": "/**\n * 续费云开发环境\n */\ntype RenewEnvParams = {\n /**\n * 是否自动选择代金券支付。\n */\n \"AutoVoucher\"?: boolean;\n /**\n * 环境ID\n */\n \"EnvId\": string;\n /**\n * 续费周期,单位:月。\n * 默认值为 1,即续费1个月。\n */\n \"Period\"?: number;\n};"
768768
},

scripts/generate-tcb-action-index.mjs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,54 @@ function cloneExample(value) {
5151
return JSON.parse(JSON.stringify(value));
5252
}
5353

54+
/**
55+
* Normalize example values to match their schema types.
56+
* This fixes issues where the OpenAPI YAML has string values for boolean fields
57+
* (e.g., 'false' instead of false), which can cause 400 errors when agents use them.
58+
*/
59+
function normalizeExampleValue(value, schema) {
60+
if (value === null || value === undefined) {
61+
return value;
62+
}
63+
64+
// Handle boolean type normalization
65+
if (schema?.type === "boolean" && typeof value === "string") {
66+
const lowerValue = value.toLowerCase();
67+
if (lowerValue === "true") {
68+
return true;
69+
}
70+
if (lowerValue === "false") {
71+
return false;
72+
}
73+
}
74+
75+
// Handle integer/number type normalization
76+
if ((schema?.type === "integer" || schema?.type === "number") && typeof value === "string") {
77+
const parsed = Number(value);
78+
if (!Number.isNaN(parsed)) {
79+
return schema.type === "integer" ? Math.floor(parsed) : parsed;
80+
}
81+
}
82+
83+
// Handle array type normalization
84+
if (schema?.type === "array" && Array.isArray(value)) {
85+
return value.map((item) => normalizeExampleValue(item, schema.items));
86+
}
87+
88+
// Handle object type normalization
89+
if ((schema?.type === "object" || schema?.properties) && typeof value === "object" && value !== null) {
90+
const properties = schema.properties ?? {};
91+
const normalized = {};
92+
for (const [key, val] of Object.entries(value)) {
93+
const propSchema = properties[key];
94+
normalized[key] = normalizeExampleValue(val, propSchema);
95+
}
96+
return normalized;
97+
}
98+
99+
return value;
100+
}
101+
54102
function mergeSchemaNodes(base, incoming) {
55103
if (!incoming || typeof incoming !== "object") {
56104
return base;
@@ -185,7 +233,7 @@ function buildSchemaResolver(components) {
185233
required: Array.isArray(schema.required)
186234
? [...schema.required].sort()
187235
: undefined,
188-
example: cloneExample(schema.example),
236+
example: normalizeExampleValue(cloneExample(schema.example), schema),
189237
};
190238

191239
if (schema.properties && typeof schema.properties === "object") {

0 commit comments

Comments
 (0)