Skip to main content
Glama
mongodb-developer

MongoDB Atlas MCP Server

Official

create_atlas_cluster

Deploy a new MongoDB Atlas cluster in an existing project by specifying cloud provider, region, and instance size.

Instructions

Creates a new Atlas cluster in an existing Atlas project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesThe ID of the Atlas project.
clusterNameYesThe name of the cluster to create.
regionYesThe cloud provider region to deploy the cluster in. eg. US_EAST_1
cloudProviderYesThe cloud provider (e.g., AWS, GCP, AZURE).
tierYesThe instance size (e.g., M0, M2, M5).

Implementation Reference

  • The main handler function that implements the logic for creating an Atlas cluster, including special handling for M0 tier and API request to MongoDB Atlas.
    private async createAtlasCluster(input: CreateClusterInput) { if (input.tier === 'M0') { return { content: [{ type: 'text', text: 'M0 (Free Tier) clusters cannot be created via the API. Please use the MongoDB Atlas UI to create an M0 cluster.' }], isError: true }; } try { const url = `https://cloud.mongodb.com/api/atlas/v1.0/groups/${input.projectId}/clusters?pretty=true`; const body = { name: input.clusterName, providerSettings: { providerName: input.cloudProvider, instanceSizeName: input.tier, regionName: input.region } }; const result = await this.makeAtlasRequest(url, 'POST', body); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return { content: [{ type: 'text', text: error.message }], isError: true }; } }
  • TypeScript interface defining the input schema for the create_atlas_cluster tool.
    interface CreateClusterInput { projectId: string; clusterName: string; region: string; cloudProvider: string; tier: string; }
  • src/index.ts:380-408 (registration)
    Registration of the create_atlas_cluster tool in the ListTools response, including name, description, and detailed input schema.
    { name: 'create_atlas_cluster', description: 'Creates a new Atlas cluster in an existing Atlas project.', inputSchema: { type: 'object', properties: { projectId: { type: 'string', description: 'The ID of the Atlas project.', }, clusterName: { type: 'string', description: 'The name of the cluster to create.', }, region: { type: 'string', description: 'The cloud provider region to deploy the cluster in. eg. US_EAST_1', }, cloudProvider: { type: 'string', description: 'The cloud provider (e.g., AWS, GCP, AZURE).', }, tier: { type: 'string', description: 'The instance size (e.g., M0, M2, M5).', } }, required: ['projectId', 'clusterName', 'region', 'cloudProvider', 'tier'], },
  • src/index.ts:503-587 (registration)
    The CallTool request handler that dispatches to createAtlasCluster for 'create_atlas_cluster' tool calls, including input validation.
    this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => { if (!['create_atlas_cluster', 'setup_atlas_network_access', 'create_atlas_user', 'get_atlas_connection_strings', 'list_atlas_projects', 'list_atlas_clusters'].includes(request.params.name)) { throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}` ); } if (!request.params.arguments) { throw new McpError(ErrorCode.InvalidParams, 'Missing arguments'); } const input = request.params.arguments as Record<string, unknown>; switch (request.params.name) { case 'create_atlas_cluster': if (!isValidCreateClusterInput(input)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid cluster creation arguments'); } break; case 'setup_atlas_network_access': if (!input.projectId || !input.ipAddresses || !Array.isArray(input.ipAddresses)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid network access arguments'); } break; case 'create_atlas_user': if (!input.projectId || !input.username || !input.password) { throw new McpError(ErrorCode.InvalidParams, 'Invalid user creation arguments'); } break; case 'get_atlas_connection_strings': if (!input.projectId || !input.clusterName) { throw new McpError(ErrorCode.InvalidParams, 'Invalid connection string arguments'); } break; case 'list_atlas_clusters': if (!input.projectId) { throw new McpError(ErrorCode.InvalidParams, 'Invalid list clusters arguments'); } break; } let result; try { switch (request.params.name) { case 'create_atlas_cluster': result = await this.createAtlasCluster(input as unknown as CreateClusterInput); break; case 'setup_atlas_network_access': result = await this.setupAtlasNetworkAccess(input as unknown as NetworkAccessInput); break; case 'create_atlas_user': result = await this.createAtlasUser(input as unknown as CreateUserInput); break; case 'get_atlas_connection_strings': result = await this.getAtlasConnectionStrings(input as unknown as ConnectionStringsInput); break; case 'list_atlas_projects': result = await this.listAtlasProjects(); break; case 'list_atlas_clusters': result = await this.listAtlasClusters(input as unknown as ListClustersInput); break; default: throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`); } // Ensure we return the expected format return { content: result.content, _meta: request.params._meta }; } catch (error: any) { // Handle any errors that might occur return { content: [{ type: 'text', text: `Error: ${error.message}` }], isError: true, _meta: request.params._meta }; } });
  • Input validation function specifically for CreateClusterInput used before calling the handler.
    const isValidCreateClusterInput = (args: any): args is CreateClusterInput => typeof args === 'object' && args !== null && typeof args.projectId === 'string' && typeof args.clusterName === 'string' && typeof args.region === 'string' && typeof args.cloudProvider === 'string' && typeof args.tier === 'string';

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mongodb-developer/mcp-mongodb-atlas'

If you have feedback or need assistance with the MCP directory API, please join our Discord server