@@ -23,47 +23,80 @@ export const clayPopulateTool: ToolConfig<ClayPopulateParams, ClayPopulateRespon
2323 } ,
2424 authToken : {
2525 type : 'string' ,
26- required : true ,
26+ required : false ,
2727 visibility : 'user-only' ,
28- description : 'Auth token for Clay webhook authentication' ,
28+ description :
29+ 'Optional auth token for Clay webhook authentication (most webhooks do not require this)' ,
2930 } ,
3031 } ,
3132
3233 request : {
3334 url : ( params : ClayPopulateParams ) => params . webhookURL ,
3435 method : 'POST' ,
35- headers : ( params : ClayPopulateParams ) => ( {
36- 'Content-Type' : 'application/json' ,
37- Authorization : `Bearer ${ params . authToken } ` ,
38- } ) ,
36+ headers : ( params : ClayPopulateParams ) => {
37+ const headers : Record < string , string > = {
38+ 'Content-Type' : 'application/json' ,
39+ }
40+
41+ if ( params . authToken && params . authToken . trim ( ) !== '' ) {
42+ headers [ 'x-clay-webhook-auth' ] = params . authToken
43+ }
44+
45+ return headers
46+ } ,
3947 body : ( params : ClayPopulateParams ) => ( {
4048 data : params . data ,
4149 } ) ,
4250 } ,
4351
4452 transformResponse : async ( response : Response ) => {
4553 const contentType = response . headers . get ( 'content-type' )
46- let data
54+ const timestamp = new Date ( ) . toISOString ( )
4755
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
4864 if ( contentType ?. includes ( 'application/json' ) ) {
49- data = await response . json ( )
65+ responseData = await response . json ( )
5066 } else {
51- data = await response . text ( )
67+ responseData = await response . text ( )
5268 }
5369
5470 return {
5571 success : true ,
5672 output : {
57- 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+ } ,
5881 } ,
5982 }
6083 } ,
6184
6285 outputs : {
63- success : { type : 'boolean' , description : 'Operation success status' } ,
64- output : {
86+ data : {
6587 type : 'json' ,
66- 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+ } ,
67100 } ,
68101 } ,
69102}
0 commit comments