{"library":"mongodb-atlas-api-client","title":"MongoDB Atlas API Client","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mongodb-atlas-api-client"],"cli":null},"imports":["const getClient = require('mongodb-atlas-api-client');","import getClient from 'mongodb-atlas-api-client';","import type { AtlasClientOptions, UserApiClient } from 'mongodb-atlas-api-client';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import getClient from 'mongodb-atlas-api-client';\n\nconst PUBLIC_KEY = process.env.ATLAS_PUBLIC_KEY ?? 'your-public-key';\nconst PRIVATE_KEY = process.env.ATLAS_PRIVATE_KEY ?? 'your-private-key';\nconst PROJECT_ID = process.env.ATLAS_PROJECT_ID ?? 'your-project-id';\n\nif (!PUBLIC_KEY || !PRIVATE_KEY || !PROJECT_ID) {\n  console.error('Missing MongoDB Atlas API keys or Project ID. Please set ATLAS_PUBLIC_KEY, ATLAS_PRIVATE_KEY, and ATLAS_PROJECT_ID environment variables or provide them directly.');\n  process.exit(1);\n}\n\nasync function runAtlasClient() {\n  try {\n    const { user, cluster } = getClient({\n      publicKey: PUBLIC_KEY,\n      privateKey: PRIVATE_KEY,\n      baseUrl: \"https://cloud.mongodb.com/api/atlas/v1.0\",\n      projectId: PROJECT_ID\n    });\n\n    const options = {\n      envelope: true,\n      itemsPerPage: 5,\n      pretty: true,\n      httpOptions: { \n        timeout: 10000 // 10 second timeout for urllib\n      }\n    };\n\n    console.log('Fetching all users...');\n    const allUsers = await user.getAll(options);\n    console.log('Found users:', allUsers.results.map(u => u.username));\n\n    // Example: Fetch a specific cluster (replace 'yourClusterName' with an actual cluster name)\n    // console.log('Fetching cluster: yourClusterName');\n    // const singleCluster = await cluster.get('yourClusterName');\n    // console.log('Cluster details:', singleCluster.name);\n\n  } catch (error) {\n    console.error('Error interacting with MongoDB Atlas API:', error);\n    if (error.status === 401 || error.status === 403) {\n      console.error('Authentication or Authorization error. Check your API keys and IP Access List.');\n    }\n  }\n}\n\nrunAtlasClient();","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}