Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Cosmos DB Shell is an open-source command-line interface (CLI) for Azure Cosmos DB. Explore databases and containers with bash-like navigation, run queries, and automate data operations. Use it independently or launch it from the Azure Cosmos DB extension for Visual Studio Code. An optional local Model Context Protocol (MCP) server exposes shell tools to compatible AI clients.
Key features
- Navigation and inspection. Use
connect,cd,ls,pwd, andinfoto explore an account. - Diagnostics and discovery. Use
doctor,whoami,can-i, and sampledschemadiscovery to investigate connections and permissions. - Queries and point reads. Run Azure Cosmos DB queries, inspect observed index usage with
query --explain, or retrieve an item by ID and partition key withprint. - Item operations. Create, replace, patch, or delete documents with explicit database and container targets.
- Transactions and bulk writes. Use
batchfor atomic operations in one partition, orbulkfor independent operations across partitions, with dry runs, concurrency controls, and resumable journals. - Import and export. Stream JSON or CSV files, validate imports offline, and export JSON arrays without a conversion step.
- Container management. Inspect or change indexing, throughput, TTL, and conflict-resolution policies.
- Server-side programming and change feed. Manage stored procedures, user-defined functions, and triggers, or follow changes with
watch. - Pipelines and scripting. Transform structured JSON with built-in
filter, format tables, and automate workflows with variables, loops, and functions. - Local AI integration. Enable the optional MCP server to let trusted clients use tools with the shell's connection and permissions.
- Terminal customization and tracing. Select or edit themes and enable OpenTelemetry tracing.
System requirements
- Use Windows, macOS, or Linux, with an x64 or ARM64 package that matches your platform.
- For the .NET global tool, install .NET SDK 10.0 or later. Self-contained binaries include their runtime.
- For editor integration, install a supported Visual Studio Code version and the Azure Cosmos DB extension.
- Use Microsoft Entra ID, managed identity, or an account key, with the permissions required for your operations.
- Allow network access from your machine to the intended account. The shell doesn't bypass account firewall or private-network restrictions.
Installation options
Choose one of three installation methods:
- Visual Studio Code extension. Install the extension, run Launch Azure Cosmos DB Shell, and follow the installation flow. See Visual Studio Code setup.
- .NET global tool. Install the NuGet package for terminal access. See the installation guide.
- Self-contained binary. Download a release archive for your platform without installing .NET. See the installation guide.
Quick start
Start the shell from your operating-system terminal:
cosmosdbshell
Then run these commands inside the shell, replacing the account, tenant, database, and container values with your own:
connect https://<account-name>.documents.azure.com/ --tenant=<tenant-id>
info --format=json
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
Verify the account-root info result before accessing data. These reads consume RUs. For a complete first session and optional sample writes, see Get started.
Use cases
- Inspect data and schemas during development.
- Diagnose identity, connection, and permission problems before changing settings.
- Plan and review data migrations before applying writes.
- Manage databases, containers, and policies with explicit targets.
- Enable trusted AI assistants to use selected database tools through local MCP.
Available distributions
| Distribution | Location |
|---|---|
| .NET global tool | CosmosDBShell on NuGet.org |
| Visual Studio Code extension | Visual Studio Marketplace |
| Self-contained binaries and release notes | Azure/CosmosDBShell releases |
Use version inside the shell or cosmosdbshell --version in your terminal to check the installed version. Run help <command> for version-specific syntax.
Documentation
- Install the shell by using your preferred distribution.
- Get started with a scoped first session.
- Look up commands for diagnostics, data operations, and policies.
- Configure local MCP for compatible AI clients.
- Use Visual Studio Code for editor integration.
- Troubleshoot problems with bounded diagnostics.
- Review security guidance before sharing access or changing data.
Support and feedback
- Report a shell issue or request a feature.
- Review the shell source and release notes.
- Review security considerations before reporting diagnostics that might contain resource names.
AI tools
Use these actions to explore Shell capabilities with your assistant.
For documentation-only retrieval, use the Microsoft Learn MCP server. For a compact guide index, use the Shell documentation index (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
Configure Shell MCP for authenticated database operations.Read as Markdown
Open a text version to copy into your assistant.Ask ChatGPT
Explore Shell capabilities and requirements.Ask Claude
Explore Shell capabilities and requirements.
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.