Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/tools/atlas/read/inspectCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,38 @@ export class InspectClusterTool extends AtlasToolBase {
throw new Error("Cluster not found");
}

const regionConfigs = (cluster.replicationSpecs || [])
.map(
(replicationSpec) =>
(replicationSpec.regionConfigs || []) as {
providerName: string;
electableSpecs?: {
instanceSize: string;
};
readOnlySpecs?: {
instanceSize: string;
};
}[]
)
.flat()
.map((regionConfig) => {
return {
providerName: regionConfig.providerName,
instanceSize: regionConfig.electableSpecs?.instanceSize || regionConfig.readOnlySpecs?.instanceSize,
};
});

const instanceSize = (regionConfigs.length <= 0 ? undefined : regionConfigs[0].instanceSize) || "UNKNOWN";

const clusterInstaceType = instanceSize == "M0" ? "FREE" : "DEDICATED";
Copy link

Copilot AI Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'clusterInstaceType' appears to be misspelled; consider renaming it to 'clusterInstanceType' for clarity.

Suggested change
const clusterInstaceType = instanceSize == "M0" ? "FREE" : "DEDICATED";
const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED";

Copilot uses AI. Check for mistakes.


return {
content: [
{
type: "text",
text: `Cluster Name | State | MongoDB Version | Connection String
----------------|----------------|----------------|----------------|----------------
${cluster.name} | ${cluster.stateName} | ${cluster.mongoDBVersion || "N/A"} | ${cluster.connectionStrings?.standard || "N/A"}`,
text: `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
----------------|----------------|----------------|----------------|----------------|----------------
${cluster.name} | ${clusterInstaceType} | ${clusterInstaceType == "DEDICATED" ? instanceSize : "N/A"} | ${cluster.stateName} | ${cluster.mongoDBVersion || "N/A"} | ${cluster.connectionStrings?.standardSrv || cluster.connectionStrings?.standard || "N/A"}`,
},
],
};
Expand Down
36 changes: 32 additions & 4 deletions src/tools/atlas/read/listClusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,37 @@ ${rows}`,
}
const rows = clusters.results
.map((cluster) => {
const connectionString = cluster.connectionStrings?.standard || "N/A";
const connectionString =
cluster.connectionStrings?.standardSrv || cluster.connectionStrings?.standard || "N/A";
const mongoDBVersion = cluster.mongoDBVersion || "N/A";
return `${cluster.name} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
const regionConfigs = (cluster.replicationSpecs || [])
.map(
(replicationSpec) =>
(replicationSpec.regionConfigs || []) as {
providerName: string;
electableSpecs?: {
instanceSize: string;
};
readOnlySpecs?: {
instanceSize: string;
};
}[]
)
.flat()
.map((regionConfig) => {
return {
providerName: regionConfig.providerName,
instanceSize:
regionConfig.electableSpecs?.instanceSize || regionConfig.readOnlySpecs?.instanceSize,
};
});

const instanceSize =
(regionConfigs.length <= 0 ? undefined : regionConfigs[0].instanceSize) || "UNKNOWN";

const clusterInstaceType = instanceSize == "M0" ? "FREE" : "DEDICATED";

return `${cluster.name} | ${clusterInstaceType} | ${clusterInstaceType == "DEDICATED" ? instanceSize : "N/A"} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
Copy link

Copilot AI Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'clusterInstaceType' appears to be misspelled; consider renaming it to 'clusterInstanceType' for clarity.

Suggested change
const clusterInstaceType = instanceSize == "M0" ? "FREE" : "DEDICATED";
return `${cluster.name} | ${clusterInstaceType} | ${clusterInstaceType == "DEDICATED" ? instanceSize : "N/A"} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED";
return `${cluster.name} | ${clusterInstanceType} | ${clusterInstanceType == "DEDICATED" ? instanceSize : "N/A"} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;

Copilot uses AI. Check for mistakes.

})
.join("\n");
return {
Expand All @@ -92,8 +120,8 @@ ${rows}`,
},
{
type: "text",
text: `Cluster Name | State | MongoDB Version | Connection String
----------------|----------------|----------------|----------------|----------------
text: `Cluster Name | Cluster Type | Tier | State | MongoDB Version | Connection String
----------------|----------------|----------------|----------------|----------------|----------------
${rows}`,
},
],
Expand Down
Loading