@@ -77,6 +77,7 @@ def mcp_tools_api_decorator(
7777 match_subpath : bool = False ,
7878 user_verified_required : bool = False ,
7979 app_verified_required : bool = True ,
80+ none_schema : bool = False ,
8081):
8182 """
8283 MCP 工具 API 装饰器
@@ -96,6 +97,7 @@ def mcp_tools_api_decorator(
9697 @params match_subpath: 匹配所有子路径
9798 @params user_verified_required: 是否校验用户身份(考虑 mcp 也有后台调用,默认都已应用态接口开放)
9899 @params app_verified_required: 是否校验应用身份
100+ @params none_schema: 无请求体时设为 True,供 generate_resources_yaml 的 MCP 校验通过
99101 @returns 装饰器函数
100102 """
101103
@@ -115,8 +117,10 @@ def decorator(func: Callable) -> Callable:
115117 for mcp_tool in mcp or []:
116118 MCP_TOOLS_REGISTRY [mcp_tool ].append (operation_id )
117119
118- # 自动添加 mcp-tools tag
119- tags .append ("mcp-tools" )
120+ # 自动添加 mcp-tools tag(使用副本避免共用 _META_DECORATOR 的视图重复 append 导致 YAML 中 tags 重复)
121+ tags_final = list (tags ) if tags else []
122+ if "mcp-tools" not in tags_final :
123+ tags_final .append ("mcp-tools" )
120124 # 创建 extend_schema 装饰器
121125 schema_decorator = extend_schema (
122126 operation_id = operation_id ,
@@ -125,10 +129,11 @@ def decorator(func: Callable) -> Callable:
125129 request = request_slz ,
126130 responses = {200 : response_slz } if response_slz else None ,
127131 methods = methods ,
128- tags = tags ,
132+ tags = tags_final ,
129133 exclude = False ,
130134 extensions = gen_apigateway_resource_config (
131135 enable_mcp = True , # 固定为 True
136+ none_schema = none_schema ,
132137 is_public = is_public ,
133138 allow_apply_permission = allow_apply_permission ,
134139 user_verified_required = user_verified_required ,
@@ -137,7 +142,7 @@ def decorator(func: Callable) -> Callable:
137142 description_en = description ,
138143 match_subpath = match_subpath ,
139144 plugin_configs = [
140- build_bk_header_rewrite (set = {"X-Bkdbm-Mcp-Tag" : "," .join (tags )}, remove = []),
145+ build_bk_header_rewrite (set = {"X-Bkdbm-Mcp-Tag" : "," .join (tags_final )}, remove = []),
141146 ],
142147 ),
143148 )
0 commit comments