@@ -59,28 +59,22 @@ export class ListClustersTool extends AtlasToolBase {
5959 }
6060 const formattedClusters = clusters . results
6161 . map ( ( result ) => {
62- return ( result . clusters || [ ] ) . map ( ( cluster ) => {
63- return { ...result , ...cluster , clusters : undefined } ;
64- } ) ;
62+ return ( result . clusters || [ ] ) . map ( ( cluster ) => ( {
63+ projectName : result . groupName ,
64+ projectId : result . groupId ,
65+ clusterName : cluster . name ,
66+ } ) ) ;
6567 } )
6668 . flat ( ) ;
6769 if ( ! formattedClusters . length ) {
6870 throw new Error ( "No clusters found." ) ;
6971 }
70- const rows = formattedClusters
71- . map ( ( cluster ) => {
72- return `${ cluster . groupName } (${ cluster . groupId } ) | ${ cluster . name } ` ;
73- } )
74- . join ( "\n" ) ;
72+
7573 return {
76- content : [
77- {
78- type : "text" ,
79- text : `Project | Cluster Name
80- ----------------|----------------
81- ${ rows } `,
82- } ,
83- ] ,
74+ content : formatUntrustedData (
75+ `Found ${ formattedClusters . length } clusters across all projects` ,
76+ JSON . stringify ( formattedClusters )
77+ ) ,
8478 } ;
8579 }
8680
@@ -98,16 +92,11 @@ ${rows}`,
9892 const formattedClusters = clusters ?. results ?. map ( ( cluster ) => formatCluster ( cluster ) ) || [ ] ;
9993 const formattedFlexClusters = flexClusters ?. results ?. map ( ( cluster ) => formatFlexCluster ( cluster ) ) || [ ] ;
10094 const allClusters = [ ...formattedClusters , ...formattedFlexClusters ] ;
95+
10196 return {
10297 content : formatUntrustedData (
10398 `Found ${ allClusters . length } clusters in project "${ project . name } " (${ project . id } ):` ,
104- `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
105- ----------------|----------------|----------------|----------------|----------------|----------------
106- ${ allClusters
107- . map ( ( formattedCluster ) => {
108- return `${ formattedCluster . name || "Unknown" } | ${ formattedCluster . instanceType } | ${ formattedCluster . instanceSize || "N/A" } | ${ formattedCluster . state || "UNKNOWN" } | ${ formattedCluster . mongoDBVersion || "N/A" } | ${ formattedCluster . connectionString || "N/A" } ` ;
109- } )
110- . join ( "\n" ) } `
99+ JSON . stringify ( allClusters )
111100 ) ,
112101 } ;
113102 }
0 commit comments