@@ -110,32 +110,27 @@ export const listAnnotationsTool: ToolConfig<
110110 transformResponse : async ( response : Response ) => {
111111 const data = await response . json ( )
112112
113+ // Handle potential nested array structure
114+ const rawAnnotations = Array . isArray ( data ) ? data . flat ( ) : [ ]
115+
113116 return {
114117 success : true ,
115118 output : {
116- annotations : Array . isArray ( data )
117- ? data . map ( ( a : any ) => ( {
118- id : a . id ,
119- alertId : a . alertId ,
120- alertName : a . alertName ,
121- dashboardId : a . dashboardId ,
122- dashboardUID : a . dashboardUID ,
123- panelId : a . panelId ,
124- userId : a . userId ,
125- newState : a . newState ,
126- prevState : a . prevState ,
127- created : a . created ,
128- updated : a . updated ,
129- time : a . time ,
130- timeEnd : a . timeEnd ,
131- text : a . text ,
132- tags : a . tags || [ ] ,
133- login : a . login ,
134- email : a . email ,
135- avatarUrl : a . avatarUrl ,
136- data : a . data ,
137- } ) )
138- : [ ] ,
119+ annotations : rawAnnotations . map ( ( a : any ) => ( {
120+ id : a . id ,
121+ dashboardId : a . dashboardId ,
122+ dashboardUID : a . dashboardUID ,
123+ created : a . created ,
124+ updated : a . updated ,
125+ time : a . time ,
126+ timeEnd : a . timeEnd ,
127+ text : a . text ,
128+ tags : a . tags || [ ] ,
129+ login : a . login ,
130+ email : a . email ,
131+ avatarUrl : a . avatarUrl ,
132+ data : a . data || { } ,
133+ } ) ) ,
139134 } ,
140135 }
141136 } ,
@@ -148,12 +143,21 @@ export const listAnnotationsTool: ToolConfig<
148143 type : 'object' ,
149144 properties : {
150145 id : { type : 'number' , description : 'Annotation ID' } ,
151- text : { type : 'string' , description : 'Annotation text' } ,
152- tags : { type : 'array' , description : 'Annotation tags' } ,
146+ dashboardId : { type : 'number' , description : 'Dashboard ID' } ,
147+ dashboardUID : { type : 'string' , description : 'Dashboard UID' } ,
148+ created : { type : 'number' , description : 'Creation timestamp in epoch ms' } ,
149+ updated : { type : 'number' , description : 'Last update timestamp in epoch ms' } ,
153150 time : { type : 'number' , description : 'Start time in epoch ms' } ,
154151 timeEnd : { type : 'number' , description : 'End time in epoch ms' } ,
155- dashboardUID : { type : 'string' , description : 'Dashboard UID' } ,
156- panelId : { type : 'number' , description : 'Panel ID' } ,
152+ text : { type : 'string' , description : 'Annotation text' } ,
153+ tags : { type : 'array' , items : { type : 'string' } , description : 'Annotation tags' } ,
154+ login : { type : 'string' , description : 'Login of the user who created the annotation' } ,
155+ email : { type : 'string' , description : 'Email of the user who created the annotation' } ,
156+ avatarUrl : { type : 'string' , description : 'Avatar URL of the user' } ,
157+ data : {
158+ type : 'json' ,
159+ description : 'Additional annotation data object from Grafana' ,
160+ } ,
157161 } ,
158162 } ,
159163 } ,
0 commit comments