Skip to content
Merged
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 @@ -241,6 +241,12 @@
# ServiceLabel: %tools-Deploy
# ServiceOwners: @qianwens @xfz11 @wchigit

# PRLabel: %tools-DeviceProvisioning
/tools/Azure.Mcp.Tools.DeviceProvisioning/ @microsoft/azure-mcp

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

# PRLabel: %tools-DeviceRegistry
/tools/Azure.Mcp.Tools.DeviceRegistry/ @microsoft/azure-mcp

Expand Down
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
"deploymentid",
"deregistering",
"devbox",
"deviceprovisioning",
"deviceregistry",
"dfff",
"disasterrecovery",
Expand Down
7 changes: 7 additions & 0 deletions Microsoft.Mcp.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@
<Folder Name="/tools/Azure.Mcp.Tools.Deploy/tests/">
<Project Path="tools/Azure.Mcp.Tools.Deploy/tests/Azure.Mcp.Tools.Deploy.Tests/Azure.Mcp.Tools.Deploy.Tests.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DeviceProvisioning/" />
<Folder Name="/tools/Azure.Mcp.Tools.DeviceProvisioning/src/">
<Project Path="tools/Azure.Mcp.Tools.DeviceProvisioning/src/Azure.Mcp.Tools.DeviceProvisioning.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DeviceProvisioning/tests/">
<Project Path="tools/Azure.Mcp.Tools.DeviceProvisioning/tests/Azure.Mcp.Tools.DeviceProvisioning.Tests/Azure.Mcp.Tools.DeviceProvisioning.Tests.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DeviceRegistry/" />
<Folder Name="/tools/Azure.Mcp.Tools.DeviceRegistry/src/">
<Project Path="tools/Azure.Mcp.Tools.DeviceRegistry/src/Azure.Mcp.Tools.DeviceRegistry.csproj" />
Expand Down
7 changes: 7 additions & 0 deletions servers/Azure.Mcp.Server/Azure.Mcp.Server.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@
<Folder Name="/tools/Azure.Mcp.Tools.Deploy/tests/">
<Project Path="../../tools/Azure.Mcp.Tools.Deploy/tests/Azure.Mcp.Tools.Deploy.Tests/Azure.Mcp.Tools.Deploy.Tests.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DeviceProvisioning/" />
<Folder Name="/tools/Azure.Mcp.Tools.DeviceProvisioning/src/">
<Project Path="../../tools/Azure.Mcp.Tools.DeviceProvisioning/src/Azure.Mcp.Tools.DeviceProvisioning.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DeviceProvisioning/tests/">
<Project Path="../../tools/Azure.Mcp.Tools.DeviceProvisioning/tests/Azure.Mcp.Tools.DeviceProvisioning.Tests/Azure.Mcp.Tools.DeviceProvisioning.Tests.csproj" />
</Folder>
<Folder Name="/tools/Azure.Mcp.Tools.DeviceRegistry/" />
<Folder Name="/tools/Azure.Mcp.Tools.DeviceRegistry/src/">
<Project Path="../../tools/Azure.Mcp.Tools.DeviceRegistry/src/Azure.Mcp.Tools.DeviceRegistry.csproj" />
Expand Down
7 changes: 7 additions & 0 deletions servers/Azure.Mcp.Server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,12 @@ For customer-hosted ADME instances, pass the resource application ID or App ID U
* "Generate insights about my Azure environment to help me plan a new data analytics platform"
* "What insights can you derive about my subscription to help me plan a containerized microservices workload on AKS?"

### 🔧 Azure Device Provisioning Service

* "Show me Device Provisioning Service 'my-dps' in resource group 'my-resource-group' of my subscription 'my-subscription'"
* "Get the ID scope, allocation policy, endpoints, and linked IoT Hubs for DPS instance 'my-dps'"
* "Show the configuration of DPS instance 'my-dps' without returning connection strings or keys"

### 🌐 Azure IoT Hub

* "Show me IoT Hub 'my-iot-hub' in resource group 'my-resource-group' of my subscription 'my-subscription'"
Expand Down Expand Up @@ -1438,6 +1444,7 @@ The Azure MCP Server provides tools for interacting with **45+ Azure service are
- 🧮 **Azure Data Explorer** - Analytics queries and KQL
- 🐬 **Azure Database for MySQL** - MySQL database management
- 🐘 **Azure Database for PostgreSQL** - PostgreSQL database management
- 🔧 **Azure Device Provisioning Service** - Device Provisioning Service resource configuration and linked IoT Hub metadata
- 🏭 **Azure Device Registry** - Device Registry namespace management
- 📊 **Azure Event Grid** - Event routing and management
- ⚡ **Azure Event Hubs** - Namespace, event hub, and consumer group management
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changes:
- section: "Features Added"
description: "Added a read-only Azure Device Provisioning Service tool for retrieving service configuration and linked IoT Hub metadata without exposing connection strings or keys."
11 changes: 11 additions & 0 deletions servers/Azure.Mcp.Server/docs/azmcp-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3161,6 +3161,17 @@ azmcp insights get --scope tenant \
--nocache
```

### Azure Device Provisioning Service Operations

```bash
# Get Azure Device Provisioning Service details by service name in a specific resource group.
# The response excludes linked-hub connection strings, authorization policies, and keys.
# ❌ Destructive | ✅ Idempotent | ❌ OpenWorld | ✅ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp deviceprovisioning service get --subscription <subscription> \
--resource-group <resource-group> \
--service <device-provisioning-service-name>
```

### Azure IoT Hub Operations

```bash
Expand Down
8 changes: 8 additions & 0 deletions servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,14 @@ The `Interaction` column describes whether a prompt can invoke its tool immediat
| insights_get | Generate insights about my Azure environment to help me plan a new data analytics platform | none |
| insights_get | What insights can you derive about my subscription to help me plan a containerized microservices workload on AKS? | none |

## Azure Device Provisioning Service

| Tool Name | Test Prompt | Interaction |
|:----------|:------------|:------------|
| deviceprovisioning_service_get | Get details for Device Provisioning Service <service_name> in resource group <resource_group_name> | none |
| deviceprovisioning_service_get | Show the configuration of DPS instance <service_name> in subscription <subscription_id> | none |
| deviceprovisioning_service_get | Retrieve the ID scope, allocation policy, endpoints, and linked IoT Hubs for DPS instance <service_name> | none |

## Azure IoT Hub

| Tool Name | Test Prompt | Interaction |
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 @@ -194,6 +194,7 @@ internal static IAreaSetup[] RegisterAreas()
new Azure.Mcp.Tools.AzureTerraform.AzureTerraformSetup(),
new Azure.Mcp.Tools.AzureTerraformBestPractices.AzureTerraformBestPracticesSetup(),
new Azure.Mcp.Tools.Deploy.DeploySetup(),
new Azure.Mcp.Tools.DeviceProvisioning.DeviceProvisioningSetup(),
new Azure.Mcp.Tools.DeviceRegistry.DeviceRegistrySetup(),
new Azure.Mcp.Tools.EventGrid.EventGridSetup(),
new Azure.Mcp.Tools.Acr.AcrSetup(),
Expand Down
33 changes: 33 additions & 0 deletions servers/Azure.Mcp.Server/src/Resources/consolidated-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2944,6 +2944,39 @@
"eventhubs_eventhub_consumergroup_get"
]
},
{
"name": "get_azure_device_provisioning_service",
"description": "Get details about an Azure Device Provisioning Service instance, including service state, endpoints, ID scope, allocation policy, network access, data residency, and linked IoT Hub metadata. Connection strings, authorization policies, and keys are not returned.",
"toolMetadata": {
"destructive": {
"value": false,
"description": "This tool only retrieves information about an Azure Device Provisioning Service instance without deleting or modifying existing resources."
},
"idempotent": {
"value": true,
"description": "Calling this tool multiple times with the same parameters returns the current resource details without causing side effects."
},
"openWorld": {
"value": false,
"description": "This tool interacts only with Azure Resource Manager."
},
"readOnly": {
"value": true,
"description": "This tool only reads Azure Device Provisioning Service resource information."
},
"secret": {
"value": false,
"description": "This tool excludes connection strings, authorization policies, and keys from its response."
},
"localRequired": {
"value": false,
"description": "This tool is available in both local and remote server modes."
}
},
"mappedToolList": [
"deviceprovisioning_service_get"
]
},
{
"name": "get_azure_iot_hub",
"description": "Get details about an Azure IoT Hub.",
Expand Down
9 changes: 9 additions & 0 deletions tools/Azure.Mcp.Tools.DeviceProvisioning/cspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Spell-check overrides for this toolset/server.
# Inherits the global config at the repo root.
version: "0.2"
import:
- ../../.vscode/cspell.json
words:
- idscope
- iothubs
- provisioningserviceowner
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(RepoRoot)core\Azure.Mcp.Core\src\Azure.Mcp.Core.csproj" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="$(AssemblyName).Tests" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.ResourceManager" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="ModelContextProtocol" />
</ItemGroup>
</Project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Text.Json.Serialization;
using Azure.Mcp.Tools.DeviceProvisioning.Commands.Service;
using Azure.Mcp.Tools.DeviceProvisioning.Models;

namespace Azure.Mcp.Tools.DeviceProvisioning.Commands;

[JsonSerializable(typeof(DeviceProvisioningProperties))]
[JsonSerializable(typeof(DeviceProvisioningServiceDescription))]
[JsonSerializable(typeof(LinkedIoTHubDescription))]
[JsonSerializable(typeof(List<LinkedIoTHubDescription>))]
[JsonSerializable(typeof(DeviceProvisioningServiceGetCommand.DeviceProvisioningServiceGetCommandResult))]
[JsonSourceGenerationOptions(
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
internal sealed partial class DeviceProvisioningJsonContext : JsonSerializerContext
{
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Core.Commands.Subscription;
using Azure.Mcp.Core.Services.Azure.Subscription;
using Azure.Mcp.Tools.DeviceProvisioning.Models;
using Azure.Mcp.Tools.DeviceProvisioning.Options.Service;
using Azure.Mcp.Tools.DeviceProvisioning.Services;
using Microsoft.Extensions.Logging;
using Microsoft.Mcp.Core.Commands;
using Microsoft.Mcp.Core.Models.Command;

namespace Azure.Mcp.Tools.DeviceProvisioning.Commands.Service;

[CommandMetadata(
Id = "3bf66226-33b8-438b-9f71-3abe62a6bf6c",
Name = "get",
Title = "Get Device Provisioning Service",
Description = """
Get an Azure Device Provisioning Service instance by name in a resource group.
Returns resource identity, SKU, service state, endpoints, ID scope, allocation policy,
public network access, data residency, and linked IoT Hub metadata.
Connection strings, authorization policies, and keys are not returned.
""",
Comment thread
khalilCodeX marked this conversation as resolved.
OperationPlane = ToolOperationPlane.Control,
Destructive = false,
Idempotent = true,
OpenWorld = false,
ReadOnly = true,
Secret = false,
LocalRequired = false)]
public sealed class DeviceProvisioningServiceGetCommand(
ILogger<DeviceProvisioningServiceGetCommand> logger,
IDeviceProvisioningService service,
ISubscriptionResolver subscriptionResolver)
: SubscriptionCommand<DeviceProvisioningServiceGetOptions, DeviceProvisioningServiceGetCommand.DeviceProvisioningServiceGetCommandResult>(subscriptionResolver)
{
private readonly ILogger<DeviceProvisioningServiceGetCommand> _logger = logger;
private readonly IDeviceProvisioningService _service = service;

public override void ValidateOptions(
DeviceProvisioningServiceGetOptions options,
ValidationResult validationResult)
{
base.ValidateOptions(options, validationResult);

if (!IsValidServiceName(options.Service))
{
validationResult.Errors.Add(
"--service must be 3-64 characters long, contain only letters, numbers, or hyphens, and start and end with a letter or number.");
}
}

public override async Task<CommandResponse> ExecuteAsync(
CommandContext context,
DeviceProvisioningServiceGetOptions options,
CancellationToken cancellationToken)
{
try
{
var provisioningService = await _service.GetService(
options.Service,
options.ResourceGroup,
options.Subscription!,
options.Tenant,
cancellationToken);

context.Response.Results = ResponseResult.Create(
new DeviceProvisioningServiceGetCommandResult(
provisioningService,
AreResultsTruncated: false),
DeviceProvisioningJsonContext.Default.DeviceProvisioningServiceGetCommandResult);
}
catch (Exception ex)
{
_logger.LogError(
ex,
"Error getting Device Provisioning Service '{ServiceName}' in resource group '{ResourceGroup}' and subscription '{Subscription}'.",
options.Service,
options.ResourceGroup,
options.Subscription);
HandleException(context, ex);
}

return context.Response;
}

public record DeviceProvisioningServiceGetCommandResult(
DeviceProvisioningServiceDescription DeviceProvisioningService,
bool AreResultsTruncated);

private static bool IsValidServiceName(string value)
{
if (value.Length is < 3 or > 64 ||
value[0] == '-' ||
value[^1] == '-')
{
return false;
}

foreach (var ch in value)
{
var isAlphaNumeric = (ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') ||
(ch >= '0' && ch <= '9');
if (!isAlphaNumeric && ch != '-')
{
return false;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Mcp.Tools.DeviceProvisioning.Commands.Service;
using Azure.Mcp.Tools.DeviceProvisioning.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Mcp.Core.Areas;
using Microsoft.Mcp.Core.Commands;

namespace Azure.Mcp.Tools.DeviceProvisioning;

public class DeviceProvisioningSetup : IAreaSetup
{
public string Name => "deviceprovisioning";

public string Title => "Manage Azure Device Provisioning Service";

public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IDeviceProvisioningService, DeviceProvisioningService>();
services.AddSingleton<DeviceProvisioningServiceGetCommand>();
}

public CommandGroup RegisterCommands(IServiceProvider serviceProvider)
{
var deviceProvisioning = new CommandGroup(
Name,
"Azure Device Provisioning Service operations.",
Title);

var service = new CommandGroup(
"service",
"Azure Device Provisioning Service resource operations.");
deviceProvisioning.AddSubGroup(service);
service.AddCommand<DeviceProvisioningServiceGetCommand>(serviceProvider);

return deviceProvisioning;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace Azure.Mcp.Tools.DeviceProvisioning.Models;

public class DeviceProvisioningProperties
{
public string? State { get; set; }

public string? ProvisioningState { get; set; }

public string? ServiceOperationsHostName { get; set; }

public string? DeviceProvisioningHostName { get; set; }

public string? IdScope { get; set; }

public string? AllocationPolicy { get; set; }

public string? PublicNetworkAccess { get; set; }

public bool? EnableDataResidency { get; set; }

public List<LinkedIoTHubProperties>? IotHubs { get; set; }
}
Loading
Loading