@@ -4,6 +4,7 @@ import { tool } from "../../tool";
4
4
import { mcpError , toContent } from "../../util" ;
5
5
import { getApiFilter } from "../../../functions/functionslog" ;
6
6
import { listEntries } from "../../../gcp/cloudlogging" ;
7
+ import { getErrMsg } from "../../../error" ;
7
8
8
9
const SEVERITY_LEVELS = [
9
10
"DEFAULT" ,
@@ -44,13 +45,14 @@ export const get_logs = tool(
44
45
{
45
46
name : "get_logs" ,
46
47
description :
47
- "Retrieves a page of Cloud Functions log entries using Google Cloud Logging advanced filters." ,
48
+ "Use this to retrieve a page of Cloud Functions log entries using Google Cloud Logging advanced filters." ,
48
49
inputSchema : z . object ( {
49
50
function_names : z
50
- . union ( [ z . string ( ) , z . array ( z . string ( ) ) . min ( 1 ) ] )
51
+ . array ( z . string ( ) )
52
+ . min ( 1 )
51
53
. optional ( )
52
54
. describe (
53
- "Optional list of deployed Cloud Function names to filter logs (string or array )." ,
55
+ "Optional list of deployed Cloud Function IDs to filter logs (e.g. ['fnA','fnB'] )." ,
54
56
) ,
55
57
page_size : z
56
58
. number ( )
@@ -101,8 +103,8 @@ export const get_logs = tool(
101
103
{ function_names, page_size, order, page_token, min_severity, start_time, end_time, filter } ,
102
104
{ projectId } ,
103
105
) => {
104
- const resolvedOrder = order ;
105
- const resolvedPageSize = page_size ;
106
+ const resolvedOrder : "asc" | "desc" = order ?. toLowerCase ( ) === "asc" ? "asc" : "desc" ;
107
+ const resolvedPageSize = page_size ?? 50 ;
106
108
107
109
const normalizedSelectors = normalizeFunctionSelectors ( function_names ) ;
108
110
const filterParts : string [ ] = [ getApiFilter ( normalizedSelectors ) ] ;
@@ -176,9 +178,11 @@ export const get_logs = tool(
176
178
177
179
return toContent ( response ) ;
178
180
} catch ( err ) {
179
- const message =
180
- err instanceof Error ? err . message : "Failed to retrieve Cloud Logging entries." ;
181
- return mcpError ( message ) ;
181
+ const errMsg = getErrMsg (
182
+ ( err as any ) ?. original || err ,
183
+ "Failed to retrieve Cloud Logging entries." ,
184
+ ) ;
185
+ return mcpError ( errMsg ) ;
182
186
}
183
187
} ,
184
188
) ;
0 commit comments