Skip to content
Open
Show file tree
Hide file tree
Changes from 11 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
6 changes: 6 additions & 0 deletions servers/Azure.Mcp.Server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,12 @@ 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)

* "Connect to my DocumentDB instance with provided connection string"
* "Disconnect from current DocumentDB connection"
* "Show me the DocumentDB connection status"

### 📣 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 DocumentDB tools for managing Azure DocumentDB (with MongoDB compatibility) connection"
20 changes: 20 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,26 @@ azmcp deviceregistry namespace list --subscription <subscription> \
[--resource-group <resource-group>]
```

### Azure DocumentDB (with MongoDB compatibility) Operations

```bash
# Connection Management

# Connect to an Azure Cosmos DB for MongoDB (vCore) instance
# ❌ Destructive | ❌ Idempotent | ❌ OpenWorld | ❌ ReadOnly | ✅ Secret | ❌ LocalRequired
azmcp documentdb connection toggle --action connect --connection-string <connection-string> \
[--test-connection <true|false>]

# Disconnect from the current DocumentDB instance
# ❌ Destructive | ❌ Idempotent | ❌ OpenWorld | ❌ ReadOnly | ✅ Secret | ❌ LocalRequired
azmcp documentdb connection toggle --action disconnect


# Get the current DocumentDB connection status and details
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp documentdb connection get connection status
```

### Azure Event Grid Operations

```bash
Expand Down
9 changes: 9 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,15 @@ 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_connection_toggle | Connect to my DocumentDB instance using <connection-string> |
| documentdb_connection_toggle | Close the DocumentDB connection |
| documentdb_connection_get_connection_status | Show me the DocumentDB connection status |
| documentdb_connection_get_connection_status | Is DocumentDB connected? |

## 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
66 changes: 66 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,72 @@
"cosmos_database_container_item_query"
]
},
{
"name": "get_azure_database_connection_status",
"description": "Get the current DocumentDB connection status and details for the active Azure Cosmos DB for MongoDB (vCore) session.",
"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_connection_get_connection_status"
]
},
{
"name": "manage_azure_documentdb_connections",
"description": "Connect to or disconnect from an Azure Cosmos DB for MongoDB (vCore) instance by managing the current DocumentDB session.",
"toolMetadata": {
"destructive": {
"value": false,
"description": "This tool performs only additive updates without deleting or modifying existing resources."
},
"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": true,
"description": "This tool handles sensitive data such as secrets, credentials, keys, or other confidential information."
},
"localRequired": {
"value": false,
"description": "This tool is available in both local and remote server modes."
}
},
"mappedToolList": [
"documentdb_connection_toggle"
]
},
{
"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,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Diagnostics.CodeAnalysis;
using Azure.Mcp.Core.Commands;
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()
{
}
Loading
Loading