Skip to content

fix: add atlas instance size #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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 clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED";

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} | ${clusterInstanceType} | ${clusterInstanceType == "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 clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED";

return `${cluster.name} | ${clusterInstanceType} | ${clusterInstanceType == "DEDICATED" ? instanceSize : "N/A"} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
})
.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