add device list command#3055
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
@Iris20050110 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
@Iris20050110 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
This PR introduces an IoT Hub “device list” command in the Azure.Mcp.Tools.IoTHub toolset, along with a result model, options type, and a unit test suite intended to validate max-count and truncation behaviors.
Changes:
- Added
IoTHubDeviceListCommandto list device identities with an optional--max-countcap. - Added
DeviceListResultresponse model andIoTHubDeviceListOptionsoptions type. - Added unit tests for basic success, max-count capping, truncation messaging, and invalid max-count handling.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.IoTHub/src/Commands/Device/IoTHubDeviceListCommand.cs | New command implementation for listing IoT Hub devices (currently references multiple missing/incorrect types/namespaces). |
| tools/Azure.Mcp.Tools.IoTHub/src/Options/Device/IoTHubDeviceListOptions.cs | New options type for the device list command (currently doesn’t align with repo option patterns / missing required fields). |
| tools/Azure.Mcp.Tools.IoTHub/src/Models/DeviceListResult.cs | New response model for listing devices (depends on missing DeviceIdentity model). |
| tools/Azure.Mcp.Tools.IoTHub/tests/Azure.Mcp.Tools.IoTHub.UnitTests/Device/IoTHubDeviceListCommandTests.cs | Unit tests for the new command (currently depends on missing/incorrect namespaces and missing IoT Hub toolset types). |
| using Azure.Mcp.Core.Models.Command; | ||
| using Azure.Mcp.Core.Models.Option; | ||
| using Azure.Mcp.Core.Options; | ||
| using Azure.Mcp.Tools.IoTHub.Options; | ||
| using Azure.Mcp.Tools.IoTHub.Options.Device; |
| public sealed class IoTHubDeviceListCommand(IIoTHubDeviceService service, ILogger<IoTHubDeviceListCommand> logger) | ||
| : BaseIoTHubCommand<IoTHubDeviceListOptions> | ||
| { |
| options.RetryPolicy, | ||
| cancellationToken); | ||
|
|
||
| context.Response.Results = ResponseResult.Create(result, IoTHubJsonContext.Default.DeviceListResult); |
|
|
||
| if (result.Truncated) | ||
| { | ||
| context.Response.Message = $"Showing the first {options.MaxCount} devices. The hub contains more devices, but the results were truncated because the maximum is {options.MaxCount}."; |
| using Azure.Mcp.Core.Options; | ||
|
|
||
| namespace Azure.Mcp.Tools.IoTHub.Options.Device; | ||
|
|
||
| public class IoTHubDeviceListOptions : SubscriptionOptions |
| public record DeviceListResult( | ||
| [property: JsonPropertyName("devices")] List<DeviceIdentity> Devices, | ||
| [property: JsonPropertyName("truncated")] bool Truncated); |
| using System.CommandLine; | ||
| using Azure.Mcp.Core.Models.Command; | ||
| using Azure.Mcp.Tools.IoTHub.Commands.Device; | ||
| using Azure.Mcp.Tools.IoTHub.Models; | ||
| using Azure.Mcp.Tools.IoTHub.Services; |
What does this PR do?
[Provide a clear, concise description of the changes][Add additional context, screenshots, or information that helps reviewers]GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationREADME.mdchanges running the script./eng/scripts/Process-PackageReadMe.ps1. See Package READMEToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.jsonbreaking-changelabelservers/Azure.Mcp.Server/docs/azmcp-commands.md./eng/scripts/Update-AzCommandsMetadata.ps1to update tool metadata inazmcp-commands.md(required for CI)servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline