feat: add MongoDB Atlas discovery provider plugin#765
Draft
tnaum-ms wants to merge 3 commits into
Draft
Conversation
dc4b60e to
d381af3
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new MongoDB Atlas Service Discovery plugin so users can browse Atlas Projects → Clusters in the Discovery View, import clusters into Connections, and connect using existing SCRAM auth flows (separate from Atlas Admin API auth).
Changes:
- Introduces the
service-atlas-mongodbplugin (auth/session management, Atlas Admin API client w/ Digest + Bearer, discovery tree items, and new-connection wizard steps). - Adds an Atlas experience and wires it into command enablement + shell labeling so Atlas nodes behave like other cluster nodes.
- Updates database creation behavior to support Atlas by optionally creating an initial collection (instead of create+drop dummy collection).
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/services/discoveryServices.ts | Extends DiscoveryProvider.getDiscoveryWizard to allow async wizard option creation. |
| src/plugins/service-atlas-mongodb/models/AtlasProjectModel.ts | Adds Atlas API response model interfaces (org/project/cluster). |
| src/plugins/service-atlas-mongodb/models/AtlasClusterModel.ts | Adds Atlas tree cluster model + factory function. |
| src/plugins/service-atlas-mongodb/discovery-wizard/SelectAtlasSteps.ts | Wizard prompt steps for selecting Atlas project and cluster. |
| src/plugins/service-atlas-mongodb/discovery-wizard/AtlasExecuteStep.ts | Wizard execute step that copies selected cluster connection string into the main context. |
| src/plugins/service-atlas-mongodb/discovery-tree/AtlasServiceRootItem.ts | Root discovery tree node with auth gating, filtering, retry/sign-in nodes, and project loading. |
| src/plugins/service-atlas-mongodb/discovery-tree/AtlasProjectItem.ts | Project tree node; loads clusters for a project and builds cluster items. |
| src/plugins/service-atlas-mongodb/discovery-tree/AtlasClusterItem.ts | Cluster tree node integrating with ClusterItemBase for connect/browse + Atlas-specific tooltip/description. |
| src/plugins/service-atlas-mongodb/config.ts | Centralizes provider IDs, labels, URLs, and storage keys. |
| src/plugins/service-atlas-mongodb/auth/executeAtlasAuthFlow.ts | Single mapping from selected auth method → concrete auth flow. |
| src/plugins/service-atlas-mongodb/auth/AtlasSessionManager.ts | Session state machine + SecretStorage/globalState persistence and service-account refresh. |
| src/plugins/service-atlas-mongodb/auth/AtlasSession.ts | Session union types and session-state enum. |
| src/plugins/service-atlas-mongodb/auth/AtlasServiceAccountFlow.ts | Interactive prompt flow for service-account client_id/client_secret auth. |
| src/plugins/service-atlas-mongodb/auth/AtlasServiceAccountClient.ts | Token acquisition for service-account client_credentials flow. |
| src/plugins/service-atlas-mongodb/auth/AtlasAuthQuickPick.ts | QuickPick to choose API Key vs Service Account authentication. |
| src/plugins/service-atlas-mongodb/auth/AtlasApiKeyFlow.ts | Interactive prompt + validation flow for Atlas API keys (Digest-auth). |
| src/plugins/service-atlas-mongodb/AtlasDiscoveryProvider.ts | Registers the Atlas provider, integrates filters/credentials, and provides discovery tree + wizard wiring. |
| src/plugins/service-atlas-mongodb/api/AtlasDigestAuth.ts | Digest challenge parsing + authorization header computation. |
| src/plugins/service-atlas-mongodb/api/AtlasApiClient.ts | Atlas Admin API client supporting Bearer (SA) and Digest (API key), with refresh+retry logic. |
| src/DocumentDBExperiences.ts | Adds the Atlas experience to the experience registry. |
| src/documentdb/shell/ShellSessionManager.ts | Allows shell sessions to provide a label prefix for terminal titles. |
| src/documentdb/shell/DocumentDBShellPty.ts | Uses the provided shell label in the banner and terminal tab title strings. |
| src/documentdb/ClustersExtension.ts | Registers the new Atlas discovery provider at extension startup. |
| src/documentdb/ClustersClient.ts | Updates createDatabase to optionally create an initial collection (Atlas support). |
| src/commands/openInteractiveShell/openInteractiveShell.ts | Uses experience-aware shell labels in terminal naming and connection info extraction. |
| src/commands/createDatabase/ExecuteStep.ts | Passes optional initial collection name into ClustersClient.createDatabase. |
| src/commands/createDatabase/CreateDatabaseWizardContext.ts | Adds wizard fields for “requires initial collection” and collectionName. |
| src/commands/createDatabase/createDatabase.ts | Enables initial-collection prompting for Atlas experience during DB creation. |
| src/commands/createCollection/InitialCollectionNameStep.ts | Adds a prompt step for an initial collection name (reused by create-database flow). |
| package.json | Extends command enablement regexes to include the new Atlas experience. |
| l10n/bundle.l10n.json | Adds/updates localized strings for Atlas UI/auth flows and new shell/title templates. |
| docs/atlas-mongodb-discovery-flow.md | Documents the end-to-end Atlas discovery flow and file map. |
| docs/ai-and-plans/PRs/733-atlas-mongodb-discovery/ux-review-iteration-2-cluster-item.md | UX review notes for Atlas cluster item presentation. |
| docs/ai-and-plans/PRs/733-atlas-mongodb-discovery/ux-review-iteration-1-k8s-alignment.md | UX alignment analysis vs Kubernetes/Azure discovery conventions. |
| docs/ai-and-plans/PRs/733-atlas-mongodb-discovery/decisions.md | Design decisions and work items for the Atlas provider implementation. |
Comment on lines
+61
to
+68
| async getDiscoveryWizard(context: NewConnectionWizardContext): Promise<IWizardOptions<NewConnectionWizardContext>> { | ||
| let session = await this.sessionManager.getSession(); | ||
| if (!session) { | ||
| session = await this.promptSignInForWizard(context); | ||
| } | ||
|
|
||
| context.properties['atlas.session'] = session; | ||
|
|
Comment on lines
+199
to
+203
| case 403: | ||
| throw new AtlasApiError( | ||
| vscode.l10n.t('Access denied. Verify your API key has the required permissions.'), | ||
| response.status, | ||
| ); |
Comment on lines
+302
to
+305
| if (this.cluster.connectionString) { | ||
| md.appendMarkdown(`\n---\n`); | ||
| md.appendMarkdown(`Connection string available — expand to connect and browse databases.`); | ||
| } |
| md.appendMarkdown(`**${escapeMarkdown(this.cluster.name)}**\n\n`); | ||
| md.appendMarkdown(`- **State:** ${escapeMarkdown(this.cluster.stateName)}\n`); | ||
| md.appendMarkdown(`- **Type:** ${escapeMarkdown(this.cluster.clusterType)}\n`); | ||
| md.appendMarkdown(`- **MongoDB:** v${escapeMarkdown(this.cluster.mongoDBVersion)}\n`); |
Comment on lines
+65
to
+67
| public getAtlasConsoleUrl(): string { | ||
| return `https://cloud.mongodb.com/v2/${this.cluster.projectId}#/clusters/detail/${this.cluster.name}`; | ||
| } |
Comment on lines
+6
to
+24
| import { type Experience } from '../../../DocumentDBExperiences'; | ||
| import { type BaseClusterModel } from '../../../tree/models/BaseClusterModel'; | ||
|
|
||
| /** | ||
| * Cluster model for MongoDB Atlas clusters discovered via the Atlas Admin API. | ||
| * Extends BaseClusterModel with Atlas-specific metadata. | ||
| */ | ||
| export interface AtlasClusterModel extends BaseClusterModel { | ||
| /** Atlas project (group) ID this cluster belongs to */ | ||
| readonly projectId: string; | ||
|
|
||
| /** Atlas project name */ | ||
| readonly projectName: string; | ||
|
|
||
| /** Cluster state (IDLE, CREATING, UPDATING, etc.) */ | ||
| readonly stateName: string; | ||
|
|
||
| /** Cluster type (REPLICASET, SHARDED, GEOSHARDED) */ | ||
| readonly clusterType: string; |
Adds a Service Discovery provider for MongoDB Atlas, browsing the Projects -> Clusters hierarchy in the Discovery View. Authentication supports two officially supported Atlas Admin API mechanisms: - API Key (HTTP Digest) - Service Account (client_credentials grant) Clusters are added to the Connections View via the shared ClusterItemBase machinery (SCRAM database credentials handled separately from the Admin API session).
7289b94 to
a291f7e
Compare
Contributor
✅ Code Quality Checks
This comment is updated automatically on each push. |
Contributor
📦 Build Size Report
Download artifact · updated automatically on each push. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a MongoDB Atlas Service Discovery provider, letting users browse their Atlas Projects → Clusters in the Discovery View and import them into Connections.
Authentication
Two officially supported Atlas Admin API mechanisms:
client_credentials)Database access still uses the standard SCRAM credential flow, separate from the Admin API session.