@@ -51,27 +51,52 @@ export const clayPopulateTool: ToolConfig<ClayPopulateParams, ClayPopulateRespon
5151
5252 transformResponse : async ( response : Response ) => {
5353 const contentType = response . headers . get ( 'content-type' )
54- let data
54+ const timestamp = new Date ( ) . toISOString ( )
5555
56+ // Extract response headers
57+ const headers : Record < string , string > = { }
58+ response . headers . forEach ( ( value , key ) => {
59+ headers [ key ] = value
60+ } )
61+
62+ // Parse response body
63+ let responseData
5664 if ( contentType ?. includes ( 'application/json' ) ) {
57- data = await response . json ( )
65+ responseData = await response . json ( )
5866 } else {
59- data = await response . text ( )
67+ responseData = await response . text ( )
6068 }
6169
6270 return {
6371 success : true ,
6472 output : {
65- data : contentType ?. includes ( 'application/json' ) ? data : { message : data } ,
73+ data : contentType ?. includes ( 'application/json' ) ? responseData : { message : responseData } ,
74+ metadata : {
75+ status : response . status ,
76+ statusText : response . statusText ,
77+ headers : headers ,
78+ timestamp : timestamp ,
79+ contentType : contentType || 'unknown' ,
80+ } ,
6681 } ,
6782 }
6883 } ,
6984
7085 outputs : {
71- success : { type : 'boolean' , description : 'Operation success status' } ,
72- output : {
86+ data : {
7387 type : 'json' ,
74- description : 'Clay populate operation results including response data from Clay webhook' ,
88+ description : 'Response data from Clay webhook' ,
89+ } ,
90+ metadata : {
91+ type : 'object' ,
92+ description : 'Webhook response metadata' ,
93+ properties : {
94+ status : { type : 'number' , description : 'HTTP status code' } ,
95+ statusText : { type : 'string' , description : 'HTTP status text' } ,
96+ headers : { type : 'object' , description : 'Response headers from Clay' } ,
97+ timestamp : { type : 'string' , description : 'ISO timestamp when webhook was received' } ,
98+ contentType : { type : 'string' , description : 'Content type of the response' } ,
99+ } ,
75100 } ,
76101 } ,
77102}
0 commit comments