Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1edc300
Add DocumentDB connection MCP tools
xingfan-git Mar 9, 2026
1f5ff7e
update pr number
xingfan-git Mar 9, 2026
2442f7d
try fix build pipeline
xingfan-git Mar 9, 2026
ba35d97
livetest files & resolve comments
xingfan-git Mar 9, 2026
08efc55
sync azmcp-commands.md
xingfan-git Mar 9, 2026
2c11d8c
dotnet format
xingfan-git Mar 9, 2026
383acaf
fix run recorded tests
xingfan-git Mar 9, 2026
9599980
resolve comments
xingfan-git Mar 10, 2026
bb42d4a
update azmcp-commands.md & dotnet format fix
xingfan-git Mar 10, 2026
2fe4f1c
fix build pipeline
xingfan-git Mar 10, 2026
6088353
merge main & resolve conflicts
xingfan-git Mar 12, 2026
c6fe9f7
resolve comments
xingfan-git Mar 13, 2026
225d9a3
update description in consolidated_tools
xingfan-git Mar 13, 2026
b084426
revert the metadata change and mark connection toggle tool as non-ope…
xingfan-git Mar 13, 2026
6bd0d18
remove connection tools and implement index tools
xingfan-git Mar 15, 2026
08d80c5
dotnet format
xingfan-git Mar 15, 2026
9e0b67d
sync metadata
xingfan-git Mar 15, 2026
ccea698
update destructive for create index
xingfan-git Mar 15, 2026
cdbc996
fix livetest
xingfan-git Mar 15, 2026
5ac4fc9
update live test
xingfan-git Mar 15, 2026
8dd8014
implement mcp tools for documentdb database commands
xingfan-git Mar 15, 2026
e166cef
remove legacy connect function
xingfan-git Mar 15, 2026
14dec4c
update yaml file
xingfan-git Mar 16, 2026
25edd6e
Merge branch 'users/xingfan/onboardingvcoremcp_connection' of https:/…
xingfan-git Mar 16, 2026
e9850fc
resolve comments
xingfan-git Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@
# ServiceLabel: %tools-Docker
# ServiceOwners: @conniey @microsoft/azure-mcp

# PRLabel: %tools-DocumentDb
/tools/Azure.Mcp.Tools.DocumentDb/ @xingfan-git @microsoft/azure-mcp

# ServiceLabel: %tools-DocumentDb
# ServiceOwners: @xingfan-git

# ServiceLabel: %tools-Eclipse
# ServiceOwners: @srnagar @microsoft/azure-mcp

Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.2" />
<PackageVersion Include="ModelContextProtocol" Version="1.0.0" />
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="1.0.0" />
<PackageVersion Include="MongoDB.Driver" Version="3.2.0" />
<PackageVersion Include="MySqlConnector" Version="2.4.0" />
<PackageVersion Include="Npgsql" Version="10.0.1" />
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
Expand Down
59 changes: 57 additions & 2 deletions eng/scripts/New-BuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,53 @@ function CheckVariable($name) {
return $value
}

function Test-ProjectUsesMongoDbDriver {
param(
[string] $ProjectPath
)

if (!(Test-Path $ProjectPath)) {
return $false
}

$projectContent = Get-Content $ProjectPath -Raw
return $projectContent -match '<PackageReference\s+Include="MongoDB\.Driver"'
}

function Test-ServerHasMongoDbDependency {
param(
[System.IO.FileInfo] $ServerProject
)

$serverProjectDirectory = Split-Path $ServerProject.FullName -Parent
$serverProjectContent = Get-Content $ServerProject.FullName -Raw
$projectReferenceMatches = [regex]::Matches($serverProjectContent, '<ProjectReference\s+Include="([^"]+)"')

foreach ($projectReferenceMatch in $projectReferenceMatches) {
$projectReference = $projectReferenceMatch.Groups[1].Value
if (-not $projectReference) {
continue
}

$expandedReference = $projectReference.Replace('$(RepoRoot)', $RepoRoot)
$expandedReference = $expandedReference.Replace('$(MSBuildThisFileDirectory)', "$serverProjectDirectory/")
$expandedReference = $expandedReference.Replace('\', '/')

if (-not [System.IO.Path]::IsPathRooted($expandedReference)) {
$expandedReference = (Join-Path $serverProjectDirectory $expandedReference).Replace('\', '/')
}

$referencedProjects = @(Get-ChildItem -Path $expandedReference -File -ErrorAction SilentlyContinue)
foreach ($referencedProject in $referencedProjects) {
if (Test-ProjectUsesMongoDbDriver -ProjectPath $referencedProject.FullName) {
return $true
}
}
}

return $false
}

$windowsPool = CheckVariable 'WINDOWSPOOL'
$linuxPool = CheckVariable 'LINUXPOOL'
$linuxArm64Pool = CheckVariable 'LINUXARM64POOL'
Expand Down Expand Up @@ -387,6 +434,13 @@ function Get-ServerDetails {
$version.PrereleaseNumber = $BuildId
}

# Check if this server depends on MongoDB.Driver (incompatible with IL trimming)
$hasMongoDbDependency = Test-ServerHasMongoDbDependency -ServerProject $serverProject

if ($hasMongoDbDependency) {
Write-Host "Server $serverName depends on DocumentDb (with MongoDB.Driver) - trimming will be disabled" -ForegroundColor Yellow
}

# Calculate VSIX version based on server version
$vsixVersion = $null
$vsixIsPrerelease = $false
Expand Down Expand Up @@ -473,7 +527,8 @@ function Get-ServerDetails {
architecture = $arch
extension = $os.extension
native = $false
trimmed = $true
# Disable trimming for servers with MongoDB.Driver dependency (uses extensive reflection)
trimmed = !$hasMongoDbDependency
}
}
}
Expand All @@ -498,7 +553,7 @@ function Get-ServerDetails {
architecture = $additionalPlatform.architecture
extension = $os.extension
native = $additionalPlatform.native
trimmed = $additionalPlatform.trimmed
trimmed = $additionalPlatform.trimmed -and !$hasMongoDbDependency
specialPurpose = $additionalPlatform.specialPurpose
}
}
Expand Down
8 changes: 8 additions & 0 deletions servers/Azure.Mcp.Server/Azure.Mcp.Server.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@
<Project Path="../../tools/Azure.Mcp.Tools.DeviceRegistry/tests/Azure.Mcp.Tools.DeviceRegistry.UnitTests/Azure.Mcp.Tools.DeviceRegistry.UnitTests.csproj" />
<Project Path="../../tools/Azure.Mcp.Tools.DeviceRegistry/tests/Azure.Mcp.Tools.DeviceRegistry.LiveTests/Azure.Mcp.Tools.DeviceRegistry.LiveTests.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DocumentDb/" />
<Folder Name="/tools/Azure.Mcp.Tools.DocumentDb/src/">
<Project Path="../../tools/Azure.Mcp.Tools.DocumentDb/src/Azure.Mcp.Tools.DocumentDb.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DocumentDb/tests/">
<Project Path="../../tools/Azure.Mcp.Tools.DocumentDb/tests/Azure.Mcp.Tools.DocumentDb.LiveTests/Azure.Mcp.Tools.DocumentDb.LiveTests.csproj" />
<Project Path="../../tools/Azure.Mcp.Tools.DocumentDb/tests/Azure.Mcp.Tools.DocumentDb.UnitTests/Azure.Mcp.Tools.DocumentDb.UnitTests.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.EventGrid/" />
<Folder Name="/tools/Azure.Mcp.Tools.EventGrid/src/">
<Project Path="../../tools/Azure.Mcp.Tools.EventGrid/src/Azure.Mcp.Tools.EventGrid.csproj" />
Expand Down
12 changes: 12 additions & 0 deletions servers/Azure.Mcp.Server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,18 @@ Example prompts that generate Azure CLI commands:
* "Get Azure Data Explorer databases in cluster 'mycluster'"
* "Sample 10 rows from table 'StormEvents' in Azure Data Explorer database 'db1'"

### 🗄️ Azure DocumentDB (with MongoDB compatibility)

* "List indexes for collection 'items' in DocumentDB database 'test'"
* "Create an index on field 'category' for collection 'items' in DocumentDB database 'test'"
* "Drop index 'category_1' from collection 'items' in DocumentDB database 'test'"
* "Show index statistics for collection 'items' in DocumentDB database 'test'"
* "Show current DocumentDB operations"
* "List all databases in DocumentDB"
* "Get statistics for database 'mydb'"
* "Get details for database 'analytics' in DocumentDB"
* "Drop database 'testdb'"

### 📣 Azure Event Grid

* "List all Event Grid topics in subscription 'my-subscription'"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pr: 1968
changes:
- section: "Features Added"
description: "Added mcp tools for managing Azure DocumentDB (with MongoDB compatibility) index"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changes:
- section: "Features Added"
description: "Added mcp tools for managing Azure DocumentDB (with MongoDB compatibility) database"
51 changes: 51 additions & 0 deletions servers/Azure.Mcp.Server/docs/azmcp-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,57 @@ azmcp deviceregistry namespace list --subscription <subscription> \
[--resource-group <resource-group>]
```

### Azure DocumentDB (with MongoDB compatibility) Operations

```bash
# List all indexes on a collection
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb index list indexes --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
azmcp documentdb index list indexes --connection-string <connection-string> \
azmcp documentdb index list --connection-string <connection-string> \

Don't need indexes again, we already know we're targeting indexes as we're in the index group and this is a root command in that group.

Also, optionally, call this command get and make collection-name optional to allow listing many indexes or getting an individual index. This is a common pattern throughout the commands in this repo to reduce the number of tools we have.

--db-name <db-name> \
--collection-name <collection-name>

# Create an index on a collection
# ✅ Destructive | ❌ Idempotent | ❌ OpenWorld | ❌ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb index create index --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
azmcp documentdb index create index --connection-string <connection-string> \
azmcp documentdb index create --connection-string <connection-string> \

Same as above.

--db-name <db-name> \
--collection-name <collection-name> \
--keys <json-index-keys> \
[--options <json-index-options>]

# Drop an index from a collection
# ✅ Destructive | ❌ Idempotent | ❌ OpenWorld | ❌ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb index drop index --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
azmcp documentdb index drop index --connection-string <connection-string> \
azmcp documentdb index drop --connection-string <connection-string> \

--db-name <db-name> \
--collection-name <collection-name> \
--index-name <index-name>

# Get index statistics for a collection
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb index index stats --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

index index stats is a bit odd, should this just be index stats? index index-stats would also be more preferable to index index stats as well.

Suggested change
azmcp documentdb index index stats --connection-string <connection-string> \
azmcp documentdb index stats --connection-string <connection-string> \

--db-name <db-name> \
--collection-name <collection-name>

# Get current DocumentDB operations
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb index current ops --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

If there aren't other concepts that will be put in the current grouping, current-ops would be a better command name.

Suggested change
azmcp documentdb index current ops --connection-string <connection-string> \
azmcp documentdb index current-ops --connection-string <connection-string> \

[--ops <json-filter>]

# List all databases or inspect a single database
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb database list databases --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
azmcp documentdb database list databases --connection-string <connection-string> \
azmcp documentdb database get --connection-string <connection-string> \

Given this command already has db-name as optional rename it to get.

[--db-name <db-name>]

# Get statistics for a database
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb database db stats --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
azmcp documentdb database db stats --connection-string <connection-string> \
azmcp documentdb database stats --connection-string <connection-string> \

Don't really need db as it isn't adding anything as we already know we're targeting a database from the database group.

--db-name <db-name>

# Drop a database
# ✅ Destructive | ❌ Idempotent | ❌ OpenWorld | ❌ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb database drop database --connection-string <connection-string> \
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use database drop, we don't need the second database word. And if there are concepts under database that can also be dropped, when adding those in the future use database <resource>... drop (where ... could be sub-sub resources).

Suggested change
azmcp documentdb database drop database --connection-string <connection-string> \
azmcp documentdb database drop --connection-string <connection-string> \

--db-name <db-name>
```

### Azure Event Grid Operations

```bash
Expand Down
22 changes: 22 additions & 0 deletions servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,28 @@ This file contains prompts used for end-to-end testing to ensure each tool is in
| deviceregistry_namespace_list | List Device Registry namespaces in resource group <resource_group_name> |
| deviceregistry_namespace_list | What Device Registry namespaces do I have in my Azure subscription? |

## Azure DocumentDB (with MongoDB compatibility)

| Tool Name | Test Prompt |
|:----------|:----------|
| documentdb_index_list_indexes | List indexes for collection <collection-name> in DocumentDB database <db-name> |
| documentdb_index_list_indexes | Show me all indexes on collection <collection-name> in database <db-name> |
| documentdb_index_create_index | Create an index on collection <collection-name> in DocumentDB database <db-name> using keys <keys> |
| documentdb_index_create_index | Add a DocumentDB index for collection <collection-name> in database <db-name> with keys <keys> and options <options> |
| documentdb_index_drop_index | Drop index <index-name> from collection <collection-name> in DocumentDB database <db-name> |
| documentdb_index_drop_index | Remove the <index-name> index from DocumentDB collection <collection-name> in database <db-name> |
| documentdb_index_index_stats | Show index statistics for collection <collection-name> in DocumentDB database <db-name> |
| documentdb_index_index_stats | Get DocumentDB index stats for collection <collection-name> in database <db-name> |
| documentdb_index_current_ops | Show current DocumentDB operations |
| documentdb_index_current_ops | Get current DocumentDB operations filtered by <ops> |
| documentdb_database_db_stats | Get statistics for database <db-name> |
| documentdb_database_db_stats | Show me stats for DocumentDB database <db-name> |
| documentdb_database_drop_database | Drop database <db-name> |
| documentdb_database_drop_database | Delete the database <db-name> from DocumentDB |
| documentdb_database_list_databases | List all databases in DocumentDB |
| documentdb_database_list_databases | Show me all DocumentDB databases |
| documentdb_database_list_databases | Get details for database <db-name> in DocumentDB |

## Azure Event Grid

| Tool Name | Test Prompt |
Expand Down
1 change: 1 addition & 0 deletions servers/Azure.Mcp.Server/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ private static IAreaSetup[] RegisterAreas()
new Azure.Mcp.Tools.AzureTerraformBestPractices.AzureTerraformBestPracticesSetup(),
new Azure.Mcp.Tools.Deploy.DeploySetup(),
new Azure.Mcp.Tools.DeviceRegistry.DeviceRegistrySetup(),
new Azure.Mcp.Tools.DocumentDb.DocumentDbSetup(),
new Azure.Mcp.Tools.EventGrid.EventGridSetup(),
new Azure.Mcp.Tools.Acr.AcrSetup(),
new Azure.Mcp.Tools.Advisor.AdvisorSetup(),
Expand Down
136 changes: 136 additions & 0 deletions servers/Azure.Mcp.Server/src/Resources/consolidated-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,142 @@
"cosmos_database_container_item_query"
]
},
{
"name": "inspect_azure_documentdb_indexes_and_diagnostics",
"description": "Inspect Azure DocumentDB collection indexes, index statistics, and current operations by supplying a connection string for each request.",
"toolMetadata": {
"destructive": {
"value": false,
"description": "This tool performs only additive updates without deleting or modifying existing resources."
},
"idempotent": {
"value": true,
"description": "Running this operation multiple times with the same arguments produces the same result without additional effects."
},
"openWorld": {
"value": false,
"description": "This tool's domain of interaction is closed and well-defined, limited to a specific set of entities (like memory access)."
},
"readOnly": {
"value": true,
"description": "This tool only performs read operations without modifying any state or data."
},
"secret": {
"value": false,
"description": "This tool does not handle sensitive or secret information."
},
"localRequired": {
"value": false,
"description": "This tool is available in both local and remote server modes."
}
},
"mappedToolList": [
"documentdb_index_list_indexes",
"documentdb_index_index_stats",
"documentdb_index_current_ops"
]
},
{
"name": "manage_azure_documentdb_indexes",
"description": "Create or drop indexes in Azure DocumentDB collections by supplying a connection string for each request.",
"toolMetadata": {
"destructive": {
"value": true,
"description": "This tool may delete or modify existing resources in its environment."
},
"idempotent": {
"value": false,
"description": "Running this operation multiple times with the same arguments may have additional effects or produce different results."
},
"openWorld": {
"value": false,
"description": "This tool's domain of interaction is closed and well-defined, limited to a specific set of entities (like memory access)."
},
"readOnly": {
"value": false,
"description": "This tool may modify its environment and perform write operations (create, update, delete)."
},
"secret": {
"value": false,
"description": "This tool does not handle sensitive or secret information."
},
"localRequired": {
"value": false,
"description": "This tool is available in both local and remote server modes."
}
},
"mappedToolList": [
"documentdb_index_create_index",
"documentdb_index_drop_index"
]
},
{
"name": "get_azure_documentdb_database_details",
"description": "List DocumentDB databases, inspect a specific database, and retrieve database statistics including collection counts and storage usage.",
"toolMetadata": {
"destructive": {
"value": false,
"description": "This tool performs only additive updates without deleting or modifying existing resources."
},
"idempotent": {
"value": true,
"description": "Running this operation multiple times with the same arguments produces the same result without additional effects."
},
"openWorld": {
"value": false,
"description": "This tool's domain of interaction is closed and well-defined, limited to a specific set of entities (like memory access)."
},
"readOnly": {
"value": true,
"description": "This tool only performs read operations without modifying any state or data."
},
"secret": {
"value": false,
"description": "This tool does not handle sensitive or secret information."
},
"localRequired": {
"value": false,
"description": "This tool is available in both local and remote server modes."
}
},
"mappedToolList": [
"documentdb_database_list_databases",
"documentdb_database_db_stats"
]
},
{
"name": "delete_azure_documentdb_databases",
"description": "Delete DocumentDB databases by dropping a database and all of its collections and data.",
"toolMetadata": {
"destructive": {
"value": true,
"description": "This tool may delete or modify existing resources in its environment."
},
"idempotent": {
"value": false,
"description": "Running this operation multiple times with the same arguments may have additional effects or produce different results."
},
"openWorld": {
"value": false,
"description": "This tool's domain of interaction is closed and well-defined, limited to a specific set of entities (like memory access)."
},
"readOnly": {
"value": false,
"description": "This tool may modify its environment and perform write operations (create, update, delete)."
},
"secret": {
"value": false,
"description": "This tool does not handle sensitive or secret information."
},
"localRequired": {
"value": false,
"description": "This tool is available in both local and remote server modes."
}
},
"mappedToolList": [
"documentdb_database_drop_database"
]
},
{
"name": "create_azure_sql_databases_and_servers",
"description": "Create new Azure SQL databases and SQL servers with configurable performance tiers and settings.",
Expand Down
6 changes: 6 additions & 0 deletions tools/Azure.Mcp.Tools.DocumentDb/src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Azure.Mcp.Tools.DocumentDb.UnitTests")]
Loading
Loading