---
layout: Conceptual
title: Use Azure Cosmos DB Shell in Visual Studio Code - Azure Cosmos DB | Microsoft Learn
canonicalUrl: https://learn.microsoft.com/en-us/azure/cosmos-db/shell/visual-studio-code
uhfHeaderId: MSDocsHeader-NoSQL
permissioned-type: public
recommendations: true
recommendation_types:
- Training
- Certification
breadcrumb_path: ../../breadcrumb/azure-nosql/toc.json
feedback_system: Standard
feedback_product_url: https://feedback.azure.com/d365community/forum/3002b3be-0d25-ec11-b6e6-000d3a4f0858
feedback_help_link_url: /answers/tags/187/azure-cosmos-db/
feedback_help_link_type: get-help-at-qna
ms.service: azure-cosmos-db
ms.subservice: nosql
ms.reviewer: mjbrown
ms.author: sasinnat
author: sajeetharan
description: Launch Azure Cosmos DB Shell from the Azure Cosmos DB extension, configure its executable and MCP port, and run scoped commands.
ms.topic: how-to
ms.date: 2026-11-05T00:00:00.0000000Z
ai-usage: ai-assisted
locale: en-us
document_id: 029f0816-f228-96ba-cc7b-8a2078dda395
document_version_independent_id: 029f0816-f228-96ba-cc7b-8a2078dda395
updated_at: 2026-11-17T19:52:00.0000000Z
original_content_git_url: https://github.com/MicrosoftDocs/nosql-docs-pr/blob/live/azure/cosmos-db/shell/visual-studio-code.md
gitcommit: https://github.com/MicrosoftDocs/nosql-docs-pr/blob/16c9484b7ce2c37b491a4022345ffba8598ff09f/azure/cosmos-db/shell/visual-studio-code.md
git_commit_id: 16c9484b7ce2c37b491a4022345ffba8598ff09f
site_name: Docs
depot_name: Learn.azure-nosql
page_type: conceptual
toc_rel: ../toc.json
word_count: 872
asset_id: cosmos-db/shell/visual-studio-code
moniker_range_name: 
monikers: []
item_type: Content
source_path: azure/cosmos-db/shell/visual-studio-code.md
cmProducts:
- https://authoring-docs-microsoft.poolparty.biz/devrel/cd668c2f-f5b3-4573-8ad1-019570e3e2db
spProducts:
- https://authoring-docs-microsoft.poolparty.biz/devrel/cc82e69d-afbe-4554-9f4c-6705fc860c42
platformId: 7735e19e-edde-74c1-766a-f551cbffea68
---

# Use Azure Cosmos DB Shell in Visual Studio Code - Azure Cosmos DB | Microsoft Learn

The Azure Cosmos DB extension can install and launch Azure Cosmos DB Shell in an integrated terminal. It can also register the shell's optional local MCP server for compatible AI features.

The shell is distinct from the extension's NoSQL query editor. Don't assume the two share a connection, database, or container.

## Prerequisites

- Install a supported version of [Visual Studio Code](https://code.visualstudio.com/).
- Install [Azure Cosmos DB](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb), published by Microsoft, with extension ID `ms-azuretools.vscode-cosmosdb`.
- Have an Azure Cosmos DB account, appropriate permissions, and network access from your machine.

You can use an extension-managed shell or an existing installation. For other installation methods, see [Install Azure Cosmos DB Shell](install).

## Launch the shell

1. Open the **Command Palette** with **Ctrl+Shift+P** on Windows or Linux, or **Cmd+Shift+P** on macOS.
2. Run **Launch Azure Cosmos DB Shell**. The command ID is `cosmosDB.launchCosmosDBShell`.
3. Complete the installation or repair flow if prompted.
4. In the new shell terminal, run:

    ```bash
    version
    help
    ```

If you launch from an account context, inspect the resulting connection before using it. To connect explicitly, replace the account name and tenant ID and run:

```bash
connect https://<account-name>.documents.azure.com/ --tenant=<tenant-id>
info --format=json
```

Complete sign-in and verify `accountId` and `uri` at the account root. `pwd` shows navigation, not account identity.

## Inspect and query a container

Inside the shell, list databases and substitute actual resource names in the following commands:

```bash
ls
ls --database=MyDatabase
schema --database=MyDatabase --container=MyContainer --sample=20
query "SELECT TOP 5 c.id FROM c" --database=MyDatabase --container=MyContainer --max=5
```

Use explicit scopes and a positive query bound. These reads consume RUs.

For deeper inspection, use the [command reference](command-reference) to find diagnostics, point reads, query explanation, batches, bulk operations, import/export, and policy commands.

## Configure shell settings

Open **Settings** and search for `cosmosDB.shell`, or edit your settings JSON.

| Setting | Default | Description |
| --- | --- | --- |
| `cosmosDB.shell.path` | Empty. | Full path to a custom shell executable instead of an extension-managed copy. |
| `cosmosDB.shell.MCP.enabled` | `false` | Enable local MCP when the extension launches the shell. |
| `cosmosDB.shell.MCP.port` | `6128` | Port for that MCP server. |

For example:

```json
{
  "cosmosDB.shell.MCP.enabled": true,
  "cosmosDB.shell.MCP.port": 6128
}
```

An optional Windows executable path must escape backslashes in JSON:

```json
{
  "cosmosDB.shell.path": "C:\\Tools\\CosmosDBShell\\cosmosdbshell.exe"
}
```

Use your actual executable path. Exit and relaunch the shell after changing launch settings.

## Enable local AI integration

1. Review the [Shell MCP setup and permissions](model-context-protocol-setup).
2. Enable `cosmosDB.shell.MCP.enabled` and select an available port.
3. Run **Launch Azure Cosmos DB Shell** and verify its account connection.
4. Open **MCP: List Servers**, locate the extension-registered **Azure Cosmos DB Shell** server, and start its client connection if prompted.
5. Inspect the discovered tools and approve only the access needed for your task.

The server uses Streamable HTTP at `http://127.0.0.1:6128/`, with legacy SSE at `/sse`. Use the selected port if you changed it. The extension's MCP settings apply to extension-launched shells, not independently launched processes.

MCP clients share the shell's connection and navigation, and can operate with its permissions. Keep the server local, use a least-privilege identity, and review destructive confirmations.

## Export a bounded selection

For a local JSON-array file that import can read directly:

```bash
export sample-ids.json --database=MyDatabase --container=MyContainer --query="SELECT c.id FROM c" --max=5
```

This example intentionally exports only IDs. It isn't a full-fidelity backup or a complete migration file. Use full documents, the intended scope, and an appropriate bound for a reviewed data-copy workflow. See [Import and export](command-reference#import-and-export).

Use built-in `filter` for JSON transformations or an installed `jq` for features beyond the built-in subset. To inspect sampled field metadata as a table:

```bash
schema --database=MyDatabase --container=MyContainer --fields-only | filter '.fields' | ftab
```

## Troubleshoot editor integration

- **Launch command missing.** Confirm that the Microsoft Azure Cosmos DB extension is installed and enabled for the current VS Code environment.
- **Wrong executable or old commands.** Check `cosmosDB.shell.path` and run `version` and `help` in the launched terminal. An extension-managed shell can differ from the executable on your terminal's `PATH`.
- **MCP server unavailable.** Enable the supported MCP setting, exit an existing non-MCP shell, and relaunch it. Use a different port if the selected one is already in use.
- **Database access fails.** Run `doctor --no-update-check`, `whoami`, and a scoped `can-i query` inside the shell. Separate credential, permission, and network problems before changing settings.
- **A command is waiting.** Check for an authentication or confirmation prompt. Use **Ctrl+C** to cancel a command when appropriate; inspect partial write outcomes before retrying.

For protocol configuration and paging, see [Shell MCP setup](model-context-protocol-setup). For shell diagnostics, see the [troubleshooting guide](troubleshooting).

## AI tools

Use these actions to discuss Shell integration in Visual Studio Code.

For documentation-only retrieval, use the [Microsoft Learn MCP server](/en-us/training/support/mcp). For a compact guide index, use the [Shell documentation index (`llms.txt`)](llms.txt). The index doesn't change crawler permissions or guarantee retrieval.

Shell MCP requires separate setup and can read or change data under the configured permissions, so review tool calls before approving them. Don't share credentials or sensitive data.

> 
> **[Connect your AI agent](/en-us/azure/cosmos-db/shell/model-context-protocol-setup)** Configure Shell MCP for authenticated database operations.
> 
> **[Read as Markdown](/en-us/azure/cosmos-db/shell/visual-studio-code?accept=text/markdown)** Open a text version to copy into your assistant.
> 
> **[Ask ChatGPT](https://chatgpt.com/?hint=search&amp;q=Read%20https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fazure%2Fcosmos-db%2Fshell%2Fvisual-studio-code%20and%20help%20me%20use%20Shell%20in%20Visual%20Studio%20Code.%20Ask%20for%20my%20extension%20version.%20Cite%20the%20source%20and%20state%20if%20you%20cannot%20access%20it.)** Get guidance for your extension workflow.
> 
> **[Ask Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fazure%2Fcosmos-db%2Fshell%2Fvisual-studio-code%20and%20help%20me%20use%20Shell%20in%20Visual%20Studio%20Code.%20Ask%20for%20my%20extension%20version.%20Cite%20the%20source%20and%20state%20if%20you%20cannot%20access%20it.)** Get guidance for your extension workflow.

ChatGPT and Claude receive only the public article URL and a starter prompt. You might need to sign in. If retrieval fails, copy the Markdown text. These links don't configure database access.