This Node.js client provides programmatic access to the MongoDB Atlas Administration API, enabling management of Atlas resources such as clusters, users, and projects. It abstracts the complexities of HTTP Digest Authentication by internally using the `urllib` package. The current stable version is 4.14.0. Releases are typically driven by updates to Node.js versions or resolutions of dependency vulnerabilities, rather than a fixed cadence. A key differentiator is its direct focus on managing Atlas via API keys, providing a more granular control for automation compared to the broader MongoDB Node.js driver. It ships with comprehensive TypeScript types, facilitating type-safe development. Additionally, it offers explicit support for integration with Model Context Protocol (MCP) servers, enabling AI assistants to interact with Atlas resources through natural language. This library is specifically designed for server-side Node.js environments.
npm install mongodb-atlas-api-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes the MongoDB Atlas API client and demonstrates fetching all database users from a specified project using API keys. It includes environment variable usage and basic error handling for common API issues.
Upgrade your Node.js environment to version 18 or higher. Consider using an LTS version for production stability.
Thoroughly test your application after upgrading to v3.0.0 or later to ensure continued compatibility, especially if you rely on specific HTTP client behaviors or custom `httpOptions`.
Ensure your Node.js environment is updated to a supported version. Node.js 18 or higher is recommended for current versions of the client.
For new projects or enhanced security, consider using MongoDB Atlas Service Accounts and OAuth 2.0 for authentication, potentially with a different client library or a custom implementation for token management. Otherwise, ensure API keys follow best practices for rotation and IP access lists.
Use `const getClient = require('mongodb-atlas-api-client');` instead of `const { getClient } = require('mongodb-atlas-api-client');` as `getClient` is the default export.Verify your `publicKey`, `privateKey`, and `projectId` in the `getClient` configuration. Ensure they are correct and have the necessary permissions within MongoDB Atlas.
Add the public IP address of your application server to the IP Access List in your MongoDB Atlas project settings. For development, `0.0.0.0/0` can be used, but this is not recommended for production.