@@ -9,10 +9,7 @@ export class ListClustersTool extends AtlasToolBase {
99 protected name = "atlas-list-clusters" ;
1010 protected description = "List MongoDB Atlas clusters" ;
1111 protected argsShape = {
12- projectId : z
13- . string ( )
14- . describe ( "Atlas project ID to filter clusters" )
15- . optional ( ) ,
12+ projectId : z . string ( ) . describe ( "Atlas project ID to filter clusters" ) . optional ( ) ,
1613 } ;
1714
1815 protected async execute ( { projectId } : ToolArgs < typeof this . argsShape > ) : Promise < CallToolResult > {
@@ -30,7 +27,7 @@ export class ListClustersTool extends AtlasToolBase {
3027 throw new Error ( `Project with ID "${ selectedProjectId } " not found.` ) ;
3128 }
3229
33- const data = await this . apiClient . listClusters ( project . id || '' ) ;
30+ const data = await this . apiClient . listClusters ( project . id || "" ) ;
3431
3532 return this . formatClustersTable ( project , data ) ;
3633 }
@@ -40,8 +37,8 @@ export class ListClustersTool extends AtlasToolBase {
4037 if ( ! clusters . results ?. length ) {
4138 throw new Error ( "No clusters found." ) ;
4239 }
43- const rows = clusters . results !
44- . map ( ( result ) => {
40+ const rows = clusters
41+ . results ! . map ( ( result ) => {
4542 return ( result . clusters || [ ] ) . map ( ( cluster ) => {
4643 return { ...result , ...cluster , clusters : undefined } ;
4744 } ) ;
@@ -55,33 +52,38 @@ export class ListClustersTool extends AtlasToolBase {
5552 content : [
5653 { type : "text" , text : `Here are your MongoDB Atlas clusters:` } ,
5754 {
58- type : "text" , text : `Project | Cluster Name
55+ type : "text" ,
56+ text : `Project | Cluster Name
5957----------------|----------------
60- ${ rows } `
58+ ${ rows } `,
6159 } ,
6260 ] ,
6361 } ;
6462 }
6563
66-
6764 private formatClustersTable ( project : Group , clusters : PaginatedClusterDescription20240805 ) : CallToolResult {
6865 if ( ! clusters . results ?. length ) {
6966 throw new Error ( "No clusters found." ) ;
7067 }
71- const rows = clusters . results !
72- . map ( ( cluster ) => {
68+ const rows = clusters
69+ . results ! . map ( ( cluster ) => {
7370 const connectionString = cluster . connectionStrings ?. standard || "N/A" ;
7471 const mongoDBVersion = cluster . mongoDBVersion || "N/A" ;
7572 return `${ cluster . name } | ${ cluster . stateName } | ${ mongoDBVersion } | ${ connectionString } ` ;
7673 } )
7774 . join ( "\n" ) ;
7875 return {
7976 content : [
80- { type : "text" , text : `Here are your MongoDB Atlas clusters in project "${ project . name } " (${ project . id } ):` } ,
8177 {
82- type : "text" , text : `Cluster Name | State | MongoDB Version | Connection String
78+ type : "text" ,
79+ text : `Here are your MongoDB Atlas clusters in project "${ project . name } " (${ project . id } ):` ,
80+ } ,
81+ {
82+ type : "text" ,
83+ text : `Cluster Name | State | MongoDB Version | Connection String
8384----------------|----------------|----------------|----------------|----------------
84- ${ rows } ` } ,
85+ ${ rows } `,
86+ } ,
8587 ] ,
8688 } ;
8789 }
0 commit comments