@@ -10,9 +10,12 @@ import {
1010 handleIntegrationById ,
1111 handleIntegrations ,
1212} from '@repo/mcp-common/src/api/cf1-integration'
13+ import {
14+ assetCategoryTypeParam ,
15+ assetCategoryVendorParam ,
16+ } from '@repo/mcp-common/src/schemas/cf1-integrations'
1317
1418import type { MyMCP } from '../index'
15- import { assetCategoryTypeParam , assetCategoryVendorParam } from '@repo/mcp-common/src/schemas/cf1-integrations'
1619
1720const PAGE_SIZE = 3
1821
@@ -24,12 +27,10 @@ const assetSearchTerm = z.string().describe('The search keyword for assets')
2427const assetIdParam = z . string ( ) . describe ( 'The UUID of the asset to analyze' )
2528const assetCategoryIdParam = z . string ( ) . describe ( 'The UUID of the asset category to analyze' )
2629
27-
28-
29-
30-
3130// Define types for our tool handlers
32- type ToolHandler < T extends Record < string , any > > = ( params : T & { accountId : string ; apiToken : string } ) => Promise < any >
31+ type ToolHandler < T extends Record < string , any > > = (
32+ params : T & { accountId : string ; apiToken : string }
33+ ) => Promise < any >
3334
3435interface ToolDefinition < T extends Record < string , any > > {
3536 name : string
@@ -39,10 +40,7 @@ interface ToolDefinition<T extends Record<string, any>> {
3940}
4041
4142// Helper function to handle common error cases and account ID checks
42- const withAccountCheck = < T extends Record < string , any > > (
43- agent : MyMCP ,
44- handler : ToolHandler < T >
45- ) => {
43+ const withAccountCheck = < T extends Record < string , any > > ( agent : MyMCP , handler : ToolHandler < T > ) => {
4644 return async ( params : T ) => {
4745 const accountId = agent . getActiveAccountId ( )
4846 if ( ! accountId ) {
@@ -81,12 +79,20 @@ const withAccountCheck = <T extends Record<string, any>>(
8179}
8280
8381// Tool definitions with their handlers
84- const toolDefinitions : ToolDefinition < any > [ ] = [
82+ const toolDefinitions : Array < ToolDefinition < any > > = [
8583 {
8684 name : 'integration_by_id' ,
8785 description : 'Analyze Cloudflare One Integration by ID' ,
8886 params : { integrationIdParam } ,
89- handler : async ( { integrationIdParam, accountId, apiToken } : { integrationIdParam : string ; accountId : string ; apiToken : string } ) => {
87+ handler : async ( {
88+ integrationIdParam,
89+ accountId,
90+ apiToken,
91+ } : {
92+ integrationIdParam : string
93+ accountId : string
94+ apiToken : string
95+ } ) => {
9096 const { integration } = await handleIntegrationById ( {
9197 integrationIdParam,
9298 accountId,
@@ -100,6 +106,7 @@ const toolDefinitions: ToolDefinition<any>[] = [
100106 description : 'List all Cloudflare One Integrations in a given account' ,
101107 params : { } ,
102108 handler : async ( { accountId, apiToken } : { accountId : string ; apiToken : string } ) => {
109+ console . log ( 'integrations_list' , accountId , apiToken )
103110 const { integrations } = await handleIntegrations ( { accountId, apiToken } )
104111 return { integrations }
105112 } ,
@@ -108,7 +115,15 @@ const toolDefinitions: ToolDefinition<any>[] = [
108115 name : 'assets_search' ,
109116 description : 'Search Assets by keyword' ,
110117 params : { assetSearchTerm } ,
111- handler : async ( { assetSearchTerm, accountId, apiToken } : { assetSearchTerm : string ; accountId : string ; apiToken : string } ) => {
118+ handler : async ( {
119+ assetSearchTerm,
120+ accountId,
121+ apiToken,
122+ } : {
123+ assetSearchTerm : string
124+ accountId : string
125+ apiToken : string
126+ } ) => {
112127 const { assets } = await handleAssetsSearch ( {
113128 accountId,
114129 apiToken,
@@ -122,7 +137,15 @@ const toolDefinitions: ToolDefinition<any>[] = [
122137 name : 'asset_by_id' ,
123138 description : 'Search Assets by ID' ,
124139 params : { assetIdParam } ,
125- handler : async ( { assetIdParam, accountId, apiToken } : { assetIdParam : string ; accountId : string ; apiToken : string } ) => {
140+ handler : async ( {
141+ assetIdParam,
142+ accountId,
143+ apiToken,
144+ } : {
145+ assetIdParam : string
146+ accountId : string
147+ apiToken : string
148+ } ) => {
126149 const { asset } = await handleAssetById ( {
127150 accountId,
128151 apiToken,
@@ -135,7 +158,15 @@ const toolDefinitions: ToolDefinition<any>[] = [
135158 name : 'assets_by_integration_id' ,
136159 description : 'Search Assets by Integration ID' ,
137160 params : { integrationIdParam } ,
138- handler : async ( { integrationIdParam, accountId, apiToken } : { integrationIdParam : string ; accountId : string ; apiToken : string } ) => {
161+ handler : async ( {
162+ integrationIdParam,
163+ accountId,
164+ apiToken,
165+ } : {
166+ integrationIdParam : string
167+ accountId : string
168+ apiToken : string
169+ } ) => {
139170 const { assets } = await handleAssetsByIntegrationId ( {
140171 accountId,
141172 apiToken,
@@ -149,7 +180,15 @@ const toolDefinitions: ToolDefinition<any>[] = [
149180 name : 'assets_by_category_id' ,
150181 description : 'Search Assets by Asset Category ID' ,
151182 params : { assetCategoryIdParam } ,
152- handler : async ( { assetCategoryIdParam, accountId, apiToken } : { assetCategoryIdParam : string ; accountId : string ; apiToken : string } ) => {
183+ handler : async ( {
184+ assetCategoryIdParam,
185+ accountId,
186+ apiToken,
187+ } : {
188+ assetCategoryIdParam : string
189+ accountId : string
190+ apiToken : string
191+ } ) => {
153192 const { assets } = await handleAssetsByAssetCategoryId ( {
154193 accountId,
155194 apiToken,
@@ -188,7 +227,15 @@ const toolDefinitions: ToolDefinition<any>[] = [
188227 name : 'asset_categories_by_vendor' ,
189228 description : 'List asset categories by vendor' ,
190229 params : { assetCategoryVendorParam } ,
191- handler : async ( { assetCategoryVendorParam, accountId, apiToken } : { assetCategoryVendorParam : string ; accountId : string ; apiToken : string } ) => {
230+ handler : async ( {
231+ assetCategoryVendorParam,
232+ accountId,
233+ apiToken,
234+ } : {
235+ assetCategoryVendorParam : string
236+ accountId : string
237+ apiToken : string
238+ } ) => {
192239 const { categories } = await handleAssetCategories ( {
193240 accountId,
194241 apiToken,
@@ -201,7 +248,15 @@ const toolDefinitions: ToolDefinition<any>[] = [
201248 name : 'asset_categories_by_type' ,
202249 description : 'Search Asset Categories by type' ,
203250 params : { assetCategoryTypeParam } ,
204- handler : async ( { assetCategoryTypeParam, accountId, apiToken } : { assetCategoryTypeParam ?: string ; accountId : string ; apiToken : string } ) => {
251+ handler : async ( {
252+ assetCategoryTypeParam,
253+ accountId,
254+ apiToken,
255+ } : {
256+ assetCategoryTypeParam ?: string
257+ accountId : string
258+ apiToken : string
259+ } ) => {
205260 const { categories } = await handleAssetCategories ( {
206261 accountId,
207262 apiToken,
@@ -214,7 +269,17 @@ const toolDefinitions: ToolDefinition<any>[] = [
214269 name : 'asset_categories_by_vendor_and_type' ,
215270 description : 'Search Asset Categories by vendor and type' ,
216271 params : { assetCategoryTypeParam, assetCategoryVendorParam } ,
217- handler : async ( { assetCategoryTypeParam, assetCategoryVendorParam, accountId, apiToken } : { assetCategoryTypeParam ?: string ; assetCategoryVendorParam : string ; accountId : string ; apiToken : string } ) => {
272+ handler : async ( {
273+ assetCategoryTypeParam,
274+ assetCategoryVendorParam,
275+ accountId,
276+ apiToken,
277+ } : {
278+ assetCategoryTypeParam ?: string
279+ assetCategoryVendorParam : string
280+ accountId : string
281+ apiToken : string
282+ } ) => {
218283 const { categories } = await handleAssetCategories ( {
219284 accountId,
220285 apiToken,
0 commit comments