atlas-inspect-cluster
Analyze MongoDB Atlas cluster configuration and status by providing project ID and cluster name to monitor performance and identify issues.
Instructions
Inspect MongoDB Atlas cluster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Atlas project ID | |
| clusterName | Yes | Atlas cluster name |
Implementation Reference
- src/tools/index.ts:1-11 (registration)Registration of all tools including AtlasTools (which re-exports InspectClusterTool) into the AllTools array for MCP tool provision.import * as AtlasTools from "./atlas/tools.js"; import * as AtlasLocalTools from "./atlasLocal/tools.js"; import * as MongoDbTools from "./mongodb/tools.js"; import type { ToolClass } from "./tool.js"; // Export the collection of tools for easier reference export const AllTools: ToolClass[] = Object.values({ ...MongoDbTools, ...AtlasTools, ...AtlasLocalTools, });
- The tool's execute handler fetches cluster details via helper and formats output.protected async execute({ projectId, clusterName }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> { const cluster = await inspectCluster(this.session.apiClient, projectId, clusterName); return this.formatOutput(cluster); } private formatOutput(formattedCluster: Cluster): CallToolResult { const clusterDetails = { name: formattedCluster.name || "Unknown", instanceType: formattedCluster.instanceType, instanceSize: formattedCluster.instanceSize || "N/A", state: formattedCluster.state || "UNKNOWN", mongoDBVersion: formattedCluster.mongoDBVersion || "N/A", connectionStrings: formattedCluster.connectionStrings || {}, }; return { content: formatUntrustedData("Cluster details:", JSON.stringify(clusterDetails)), }; }
- Input schema definition for projectId and clusterName using AtlasArgs.export const InspectClusterArgs = { projectId: AtlasArgs.projectId().describe("Atlas project ID"), clusterName: AtlasArgs.clusterName().describe("Atlas cluster name"), }; export class InspectClusterTool extends AtlasToolBase { public name = "atlas-inspect-cluster"; protected description = "Inspect MongoDB Atlas cluster"; static operationType: OperationType = "read"; protected argsShape = { ...InspectClusterArgs, };
- src/tools/atlas/tools.ts:3-3 (registration)Re-export of InspectClusterTool for inclusion in AtlasTools.export { InspectClusterTool } from "./read/inspectCluster.js";
- src/common/atlas/cluster.ts:83-115 (helper)Core helper function that calls Atlas API to inspect cluster (both dedicated and flex) and formats the response.export async function inspectCluster(apiClient: ApiClient, projectId: string, clusterName: string): Promise<Cluster> { try { const cluster = await apiClient.getCluster({ params: { path: { groupId: projectId, clusterName, }, }, }); return formatCluster(cluster); } catch (error) { try { const cluster = await apiClient.getFlexCluster({ params: { path: { groupId: projectId, name: clusterName, }, }, }); return formatFlexCluster(cluster); } catch (flexError) { const err = flexError instanceof Error ? flexError : new Error(String(flexError)); apiClient.logger.error({ id: LogId.atlasInspectFailure, context: "inspect-cluster", message: `error inspecting cluster: ${err.message}`, }); throw error; } } }