Skip to content

feat: add MongoDB Atlas discovery provider plugin#765

Draft
tnaum-ms wants to merge 3 commits into
mainfrom
feature/atlas-discovery
Draft

feat: add MongoDB Atlas discovery provider plugin#765
tnaum-ms wants to merge 3 commits into
mainfrom
feature/atlas-discovery

Conversation

@tnaum-ms

Copy link
Copy Markdown
Collaborator

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:

  • API Key (HTTP Digest)
  • Service Account (client_credentials)

Database access still uses the standard SCRAM credential flow, separate from the Admin API session.

Copilot AI review requested due to automatic review settings June 30, 2026 13:07
@tnaum-ms tnaum-ms requested a review from a team as a code owner June 30, 2026 13:07
@tnaum-ms tnaum-ms marked this pull request as draft June 30, 2026 13:08
@tnaum-ms tnaum-ms force-pushed the feature/atlas-discovery branch from dc4b60e to d381af3 Compare June 30, 2026 13:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-mongodb plugin (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;
tnaum-ms and others added 2 commits July 7, 2026 20:45
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).
@BChoudhury-ms BChoudhury-ms force-pushed the feature/atlas-discovery branch from 7289b94 to a291f7e Compare July 7, 2026 15:15
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

✅ Code Quality Checks

Check Status How to fix
Localization (l10n) ✅ Passed
ESLint ✅ Passed
Prettier formatting ✅ Passed

This comment is updated automatically on each push.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📦 Build Size Report

Metric Base (main) PR Delta
VSIX (vscode-documentdb-0.9.1.vsix) 8.01 MB 8.02 MB ⬆️ +10 KB (+0.1%)
Webview bundle (views.js) 5.88 MB 5.88 MB ✅ 0 KB (0.0%)

Download artifact · updated automatically on each push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants