From aebeed6fc2b6550cd4502ada117ec08a6ad35018 Mon Sep 17 00:00:00 2001 From: CodeBuddy Attribution Bot Date: Wed, 29 Apr 2026 12:48:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(attribution):=20queryFunctions=20MCP=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E5=88=86=E9=A1=B5=E8=AE=BE=E8=AE=A1=E4=B8=8D?= =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=8C=E5=93=8D=E5=BA=94=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=85=83=E6=95=B0=E6=8D=AE=E4=B8=94=E8=B7=A8?= =?UTF-8?q?=E9=A1=B5=E6=95=B0=E6=8D=AE=E4=B8=80=E8=87=B4=E6=80=A7=E6=97=A0?= =?UTF-8?q?=E4=BF=9D=E9=9A=9C=20(issue=5Fmojj9me4=5Fyo5uhf)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mcp/src/tools/functions.ts | 56 +++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/mcp/src/tools/functions.ts b/mcp/src/tools/functions.ts index 08db62ce..99ed6aba 100644 --- a/mcp/src/tools/functions.ts +++ b/mcp/src/tools/functions.ts @@ -531,20 +531,28 @@ export function registerFunctionTools(server: ExtendedMcpServer) { switch (input.action) { case "listFunctions": { const cloudbase = await getManager(); + const limit = input.limit ?? 20; + const offset = input.offset ?? 0; const result = await cloudbase.functions.getFunctionList( - input.limit, - input.offset, + limit, + offset, ); logCloudBaseResult(server.logger, result); + const functions = result.Functions || []; + const totalCount = result.TotalCount || 0; + const hasMore = offset + functions.length < totalCount; return buildEnvelope( { action: input.action, - functions: result.Functions || [], - totalCount: result.TotalCount || 0, + functions, + totalCount, + limit, + offset, + hasMore, requestId: result.RequestId, raw: result, }, - `已获取 ${result.Functions?.length || 0} 个云函数`, + `已获取 ${functions.length} 个云函数,总计 ${totalCount} 个${hasMore ? ",还有更多数据" : ""}`, [ { tool: "queryFunctions", @@ -603,32 +611,40 @@ export function registerFunctionTools(server: ExtendedMcpServer) { if (!input.functionName) { throw new Error("listFunctionLogs 操作时,functionName 参数是必需的"); } + const limit = input.limit ?? 20; + const offset = input.offset ?? 0; validateLogRange( input.startTime, input.endTime, - input.offset, - input.limit, + offset, + limit, ); const cloudbase = await getManager(); const result = await cloudbase.functions.getFunctionLogsV2({ name: input.functionName, - offset: input.offset, - limit: input.limit, + offset, + limit, startTime: input.startTime, endTime: input.endTime, requestId: input.requestId, qualifier: input.qualifier, }); logCloudBaseResult(server.logger, result); + const logs = result.LogList || []; + // For logs, we infer hasMore based on whether we got a full page + const hasMore = logs.length >= limit; return buildEnvelope( { action: input.action, functionName: input.functionName, - logs: result.LogList || [], + logs, + limit, + offset, + hasMore, requestId: result.RequestId, raw: result, }, - `已获取函数 ${input.functionName} 的日志列表`, + `已获取函数 ${input.functionName} 的 ${logs.length} 条日志${hasMore ? ",可能还有更多数据" : ""}`, [ { tool: "queryFunctions", @@ -697,22 +713,30 @@ export function registerFunctionTools(server: ExtendedMcpServer) { } case "listLayers": { const cloudbase = await getManager(); + const limit = input.limit ?? 20; + const offset = input.offset ?? 0; const result = await cloudbase.functions.listLayers({ - offset: input.offset, - limit: input.limit, + offset, + limit, runtime: input.runtime, searchKey: input.searchKey, }); logCloudBaseResult(server.logger, result); + const layers = result.Layers || []; + const totalCount = result.TotalCount || 0; + const hasMore = offset + layers.length < totalCount; return buildEnvelope( { action: input.action, - layers: result.Layers || [], - totalCount: result.TotalCount || 0, + layers, + totalCount, + limit, + offset, + hasMore, requestId: result.RequestId, raw: result, }, - `已获取 ${result.Layers?.length || 0} 条层记录`, + `已获取 ${layers.length} 条层记录,总计 ${totalCount} 个${hasMore ? ",还有更多数据" : ""}`, [ { tool: "queryFunctions",