Skip to content

Commit 07057c4

Browse files
author
CodeBuddy Attribution Bot
committed
fix(attribution): queryGateway 工具未返回明确的外部调用 URL,导致评测系统使用错误主机名触发 SSL 证书不匹配 (issue_mojgqzg4_otl94f)
1 parent e2ca73f commit 07057c4

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

mcp/src/tools/gateway.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,13 @@ describe("gateway tools", () => {
272272
targetName: "helloFn",
273273
total: 1,
274274
domains: ["env-test.app.tcloudbase.com", "api.example.com"],
275+
defaultDomain: "env-test.app.tcloudbase.com",
276+
customDomains: ["api.example.com"],
275277
urls: [
276278
"https://env-test.app.tcloudbase.com/api/hello",
277279
"https://api.example.com/api/hello",
278280
],
281+
defaultUrl: "https://env-test.app.tcloudbase.com/api/hello",
279282
enableService: true,
280283
},
281284
nextActions: [

mcp/src/tools/gateway.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ export function registerGatewayTools(server: ExtendedMcpServer) {
207207
{
208208
action: input.action,
209209
domains: result.domains,
210+
defaultDomain: result.raw.DefaultDomain,
211+
customDomains: result.raw.ServiceSet?.map((item) => item.Domain) ?? [],
210212
enableService: result.enableService,
211213
raw: result.raw,
212214
},
@@ -226,6 +228,7 @@ export function registerGatewayTools(server: ExtendedMcpServer) {
226228
{
227229
action: input.action,
228230
domains: result.raw.ServiceSet ?? [],
231+
defaultDomain: result.raw.DefaultDomain,
229232
total: (result.raw.ServiceSet ?? []).length,
230233
raw: result.raw,
231234
},
@@ -241,6 +244,7 @@ export function registerGatewayTools(server: ExtendedMcpServer) {
241244
action: input.action,
242245
routes,
243246
total: result.TotalCount ?? routes.length,
247+
defaultDomain: result.OriginDomain,
244248
raw: result,
245249
},
246250
`已获取 ${result.TotalCount ?? routes.length} 条 HTTP 路由`,
@@ -260,6 +264,7 @@ export function registerGatewayTools(server: ExtendedMcpServer) {
260264
action: input.action,
261265
routeId: input.routeId ?? null,
262266
route,
267+
defaultDomain: result.OriginDomain,
263268
raw: result,
264269
},
265270
route ? "已获取路由详情" : "未找到对应路由",
@@ -289,6 +294,12 @@ export function registerGatewayTools(server: ExtendedMcpServer) {
289294
),
290295
);
291296

297+
// 使用默认域名生成外部调用 URL,避免使用自定义域名导致 SSL 证书不匹配
298+
const defaultDomain = domainInfo.raw.DefaultDomain;
299+
const defaultUrl = (accessList.APISet || []).length > 0
300+
? `https://${defaultDomain}${normalizeAccessPath(accessList.APISet[0].Path)}`
301+
: null;
302+
292303
return buildEnvelope(
293304
{
294305
action: input.action,
@@ -297,7 +308,10 @@ export function registerGatewayTools(server: ExtendedMcpServer) {
297308
apis: accessList.APISet || [],
298309
total: accessList.Total || 0,
299310
domains: domainInfo.domains,
311+
defaultDomain,
312+
customDomains: domainInfo.raw.ServiceSet?.map((item) => item.Domain) ?? [],
300313
urls,
314+
defaultUrl,
301315
enableService:
302316
accessList.EnableService ?? domainInfo.enableService ?? false,
303317
raw: {

0 commit comments

Comments
 (0)