Added cosmos shell extension.#2536
Open
mkrueger wants to merge 37 commits intomicrosoft:mainfrom
Open
Conversation
1ff098d to
23e9166
Compare
74a8e01 to
e889376
Compare
9a75647 to
b988636
Compare
sevoku
reviewed
Jul 18, 2025
19f5bc1 to
8103cd6
Compare
41f8a97 to
cc9114b
Compare
1d23eb9 to
63b3193
Compare
63b3193 to
d266276
Compare
Member
Author
|
We should bump vs code in main at some point - it's getting hard to update this branch. |
fd31d4d to
99694cf
Compare
mkrueger
added a commit
to mkrueger/vscode-cosmosdb
that referenced
this pull request
Jan 21, 2026
- Implemented Cosmos Shell extension with MCP server integration - Added credential support for Cosmos Shell (including Entra ID) - Added MCP configuration settings - Added LSP server support - Added l10n localization strings - Added settings button to error messages - Fixed various configuration and import issues
99694cf to
312cb64
Compare
mkrueger
added a commit
to mkrueger/vscode-cosmosdb
that referenced
this pull request
Jan 21, 2026
- Implemented Cosmos Shell extension with MCP server integration
- Added credential support for Cosmos Shell (including Entra ID)
- Added MCP configuration settings
- Added LSP server support
- Added l10n localization strings
- Added settings button to error messages
- Fixed various configuration and import issues
312cb64 to
9c00c4f
Compare
mkrueger
added a commit
to mkrueger/vscode-cosmosdb
that referenced
this pull request
Jan 21, 2026
- Implemented Cosmos Shell extension with MCP server integration
- Added credential support for Cosmos Shell (including Entra ID)
- Added MCP configuration settings
- Added LSP server support
- Added l10n localization strings
- Added settings button to error messages
- Fixed various configuration and import issues
9c00c4f to
81bddf7
Compare
9539f4d to
9b21587
Compare
9b21587 to
d523568
Compare
…ndependent - Rename folder src/cosmosShell -> src/cosmosDBShell, files and identifiers (CosmosShell* -> CosmosDBShell*, cosmosshell -> cosmosdbshell). - Rename env vars COSMOS_SHELL_ACCOUNT_KEY/COSMOS_SHELL_TOKEN -> COSMOSDB_SHELL_ACCOUNT_KEY/COSMOSDB_SHELL_TOKEN. - Update VS Code contributions (command id, context keys, language id, NLS keys). - Use path.win32.* in the Windows branch of cosmosDBShellCommandResolver so unit tests pass on Linux CI.
sevoku
reviewed
Apr 28, 2026
Member
sevoku
left a comment
There was a problem hiding this comment.
Nice, works much better now with the latest Shell build! Will approve after BugBash if no new issues come up.
- Show command on tree items even when shell isn't installed - Detect .NET SDK and offer guided install via dotnet tool - Stream install output, detect success/failure, auto-relaunch - Chain SDK install -> tool install via .NET Install Tool extension - Offer Reload Window when PATH isn't refreshed yet
Fixes AzureCosmosDB/cosmosdb-shell-preview#24. Track per-terminal launch state (endpoint + auth mode + tenant/MI client id) instead of just the endpoint, and always send 'connect <endpoint>' before navigating an existing terminal so a previously disconnected shell is re-attached. Reuse only when launch-time env credentials (account key / Entra fallback token) match; otherwise spawn a new shell so the right env vars get baked into the process.
After acquiring the .NET SDK via the .NET Install Tool, PATH may not yet be refreshed in the current VS Code session, so 'dotnet --list-sdks' on a bare 'dotnet' lookup fails and the install flow stalls silently. Plumb the returned dotnetPath through isDotNetSdkInstalled and the dotnet tool install spawn, and auto-chain into the Cosmos DB Shell install + launch instead of asking the user to confirm again.
…checks and improved error handling
2ef4233 to
71e063e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Integrates the external Cosmos DB Shell CLI into the extension, adding a launch command, optional MCP server exposure, and basic language support for .csh scripts.
Changes:
- Adds Cosmos DB Shell activation + command registration and wires MCP provider + LSP startup into extension activation.
- Implements command resolution (with Windows PATH/PATHEXT + dotnet tool shim support) and MCP endpoint helpers with unit tests.
- Adds VS Code contributions for settings, command/menu entry, and a new
cosmosdbshelllanguage configuration.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tree/cosmosdb/CosmosDBAccountResourceItem.ts | Switches account icon helper to URI-based implementation. |
| src/tree/cosmosdb/CosmosDBAccountAttachedResourceItem.ts | Improves tooltip composition + switches icon helper. |
| src/extension.ts | Activates Cosmos DB Shell integration and registers MCP/LSP hooks. |
| src/cosmosDBShell/cosmosDBShellMcpEndpoint.ts | Adds helper for MCP endpoint formatting. |
| src/cosmosDBShell/cosmosDBShellMcpEndpoint.test.ts | Adds unit test for MCP endpoint formatting. |
| src/cosmosDBShell/cosmosDBShellCommandResolver.ts | Adds cross-platform shell command resolution (Windows PATH + shim unwrapping). |
| src/cosmosDBShell/cosmosDBShellCommandResolver.test.ts | Adds unit tests for Windows command resolution behavior. |
| src/cosmosDBShell/configuration.json | Adds language configuration (brackets/comments/autoclosing) for .csh. |
| src/cosmosDBShell/CosmosDBShellExtension.ts | Adds main Cosmos DB Shell integration: terminal orchestration, install prompts, MCP provider, LSP client. |
| src/constants.ts | Adds getThemeAgnosticIconURI helper. |
| package.nls.json | Adds localized strings for the new command/settings. |
| package.json | Adds vscode-languageclient, language contribution, command/menu, settings, and MCP provider contribution. |
| l10n/bundle.l10n.json | Adds localized strings used by the Cosmos DB Shell flows. |
| ext.fileSystem = new DatabasesFileSystem(); | ||
|
|
||
| const cosmosDBShellSupport: CosmosDBShellExtension = new CosmosDBShellExtension(); | ||
| await cosmosDBShellSupport.activate(); |
Comment on lines
+165
to
+174
| const listener = vscode.window.onDidCloseTerminal((closedTerminal) => { | ||
| listener.dispose(); | ||
| if (closedTerminal === terminal && Date.now() - startTime < 5000) { | ||
| const exitCode = closedTerminal.exitStatus?.code; | ||
| const exitReason = closedTerminal.exitStatus?.reason; | ||
| ext.outputChannel.error( | ||
| `Cosmos DB Shell exited early.${exitCode !== undefined ? ` Exit code: ${exitCode}.` : ''}${exitReason !== undefined ? ` Reason: ${exitReason}.` : ''}`, | ||
| ); | ||
| } | ||
| }); |
Comment on lines
+46
to
+49
| function resolveWindowsCommand(command: string, env: NodeJS.ProcessEnv): string | undefined { | ||
| if (isExplicitPath(command)) { | ||
| return isFile(command) ? command : undefined; | ||
| } |
Comment on lines
+628
to
+633
| { | ||
| "//": "[Database] Launch Cosmos DB Shell", | ||
| "command": "cosmosDB.launchCosmosDBShell", | ||
| "when": "view =~ /azure(ResourceGroups|Workspace|FocusView)/ && (viewItem =~ /treeitem[.]database(?![a-z.\\/])/i || viewItem =~ /treeitem[.]container(?![a-z.\\/])/i) && viewItem =~ /experience[.]core/i", | ||
| "group": "1@4" | ||
| }, |
Comment on lines
+7
to
+10
| * entry-point for mongoClusters-related code. Activated from ./src/extension.ts | ||
| * | ||
| * We'll try to have everything related to mongoClusters-support managed from here. | ||
| * In case of a failure with this plan, this comment section will be updated. |
Comment on lines
+592
to
+596
| const rawConnectionString = node.model.accountInfo.endpoint; | ||
| if (!rawConnectionString) { | ||
| void vscode.window.showErrorMessage(l10n.t('Failed to extract the connection string from the selected node.')); | ||
| return; | ||
| } |
Comment on lines
+41
to
+48
| export function getThemeAgnosticIconURI(iconName: string): IconPath { | ||
| const iconPath = Uri.joinPath(ext.context.extensionUri, 'resources', 'icons', 'theme-agnostic', iconName); | ||
| assert.ok(fs.existsSync(iconPath.fsPath), `Icon not found: ${iconPath.fsPath}`); | ||
| return { | ||
| light: iconPath, | ||
| dark: iconPath, | ||
| }; | ||
| } |
Comment on lines
+132
to
+134
| // Create a singleton instance to access the context updater | ||
| //const cosmosDBShellExt = new CosmosDBShellExtension(); | ||
|
|
Resolved conflicts: - src/tree/cosmosdb/CosmosDBAccountAttachedResourceItem.ts: kept main's spread-based return shape; kept branch's getThemeAgnosticIconURI call - src/tree/cosmosdb/CosmosDBAccountResourceItem.ts: same as above - package-lock.json: regenerated from main Migrated src/cosmosDBShell/cosmosDBShellCommandResolver.test.ts from jest to vitest.
7f8da65 to
7bacabf
Compare
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.
Add Cosmos DB Shell integration
Integrates the external Cosmos DB Shell (
cosmosdbshellCLI / .NET tool) into the extension. Users can launch a connected shell from the resource tree and optionally expose it as an MCP server for GitHub Copilot.Highlights
NoSQL: Launch Cosmos DB Shellwith context-menu entries on NoSQL database/container items (gated byvscodeDatabases.cosmosDBShellSupportEnabled).getAccessTokenForVSCodewith fallback handling), and managed identity.cosmosDBShellCommandResolver.ts): walksPATH/PATHEXTon Windows and unwrapsdotnet tool.cmd/.batshims; passthrough on macOS/Linux. Honors a configured absolute path and surfaces actionable errors.cosmosDbShellMcpProvider) that exposes the shell over HTTP on127.0.0.1at a configurable port and refreshes when shell settings change..csh(cosmosdbshell) with basic bracket/comment/auto-closing config.New settings
cosmosDB.shell.pathnullcosmosdbshellexecutable.cosmosDB.shell.MCP.enabledfalsecosmosDB.shell.MCP.port6128Notes
mcpServerDefinitionProvidersAPI (typings vendored invscode.proposed.d.ts).vscode-languageclient ~9.0.1.cosmosdbshellseparately; degrades gracefully when not found.