Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Copy link
Contributor

Choose a reason for hiding this comment

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

@hallipr could you review this change, as I don't know the trimmed build usage well enough and this PR is added a dependency which doesn't support trimming.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we see a CI failure for this ?

Copy link
Member

@hallipr hallipr Mar 16, 2026

Choose a reason for hiding this comment

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

I think because they're disabling trimming in New-BuildInfo. We just stop trimming the server instead of failing to trim it

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
Copy link
Member

Choose a reason for hiding this comment

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

This is a odd place to put this test. If we know a server shouldn't be trimmed, we should just add a property to the project file like <ShouldTrim>false</ShouldTrim>. Adding dependency-specific special casing here would become unsupportable.


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
8 changes: 8 additions & 0 deletions servers/Azure.Mcp.Server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,14 @@ 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"

### 📣 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"
36 changes: 36 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,42 @@ 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> \
--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> \
--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> \
--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> \
--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> \
[--ops <json-filter>]
```

### Azure Event Grid Operations

```bash
Expand Down
15 changes: 15 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,21 @@ 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> |

## 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
69 changes: 69 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,75 @@
"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."
},
Comment on lines +239 to +242
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The manage_azure_documentdb_connections consolidated tool entry has "secret": { "value": false } with description "This tool does not handle sensitive or secret information." However, this tool accepts a connection string as input, which typically contains credentials (username and password). The secret flag should be true to signal that this tool handles sensitive data.

Copilot uses AI. Check for mistakes.
"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": "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")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsAotCompatible>true</IsAotCompatible>
<!-- Disable trim analyzer warnings for MongoDB.Driver which uses extensive reflection -->
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="**\Resources\*.txt" />
<EmbeddedResource Include="**\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\core\Azure.Mcp.Core\src\Azure.Mcp.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.ResourceManager" />
<PackageReference Include="MongoDB.Driver" />

<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="ModelContextProtocol" />
<PackageReference Include="System.CommandLine" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.CommandLine;
using System.Diagnostics.CodeAnalysis;
using Azure.Mcp.Core.Commands;
using Azure.Mcp.Core.Extensions;
using Azure.Mcp.Tools.DocumentDb.Options;

namespace Azure.Mcp.Tools.DocumentDb.Commands;

public abstract class BaseDocumentDbCommand<
[DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] TOptions>
: GlobalCommand<TOptions> where TOptions : BaseDocumentDbOptions, new()
{
protected override void RegisterOptions(Command command)
{
base.RegisterOptions(command);
command.Options.Add(DocumentDbOptionDefinitions.ConnectionString);
}

protected override TOptions BindOptions(ParseResult parseResult)
{
return new TOptions
{
ConnectionString = parseResult.GetValueOrDefault<string>(DocumentDbOptionDefinitions.ConnectionString.Name)
};
}
}
Loading
Loading