Add IoT Hub device list command - #3074
Conversation
Adds the `azmcp iothub device list` command to list device identities in an Azure IoT Hub device registry. Returns device metadata without authentication keys, supports --max-count (default 100, maximum 100) with a truncated flag when more devices exist, and returns a validation error when --max-count is less than 1. Includes the Azure.Mcp.Tools.IoTHub project (device list command, options, models, services, unit and live tests) and wires it into the server registration, command docs, e2e prompts, CHANGELOG, and consolidated-tools.json.
There was a problem hiding this comment.
Pull request overview
Adds a new Azure IoT Hub toolset and wires it into Azure MCP Server so users can run azmcp iothub device list to list device identities (metadata-only) from an IoT Hub device registry.
Changes:
- Introduces
Azure.Mcp.Tools.IoTHubwith a device-list command, models, and services for IoT Hub device registry listing. - Adds unit + live test projects and live-test infrastructure (Bicep + post-deploy script) for the IoT Hub toolset.
- Registers the new area/tool and updates server docs, e2e prompts, consolidated tool mapping, and changelog.
Invoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with write access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.
Reviewed changes
Copilot reviewed 36 out of 37 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.IoTHub/tests/test-resources.bicep | Adds Bicep template to provision an IoT Hub for live tests. |
| tools/Azure.Mcp.Tools.IoTHub/tests/test-resources-post.ps1 | Adds post-deploy script to create test devices. |
| tools/Azure.Mcp.Tools.IoTHub/tests/Azure.Mcp.Tools.IoTHub.UnitTests/Device/IoTHubDeviceListCommandTests.cs | Adds unit tests for the device list command behavior. |
| tools/Azure.Mcp.Tools.IoTHub/tests/Azure.Mcp.Tools.IoTHub.UnitTests/Azure.Mcp.Tools.IoTHub.UnitTests.csproj | Adds unit test project for the IoT Hub toolset. |
| tools/Azure.Mcp.Tools.IoTHub/tests/Azure.Mcp.Tools.IoTHub.LiveTests/IoTHubCommandTests.cs | Adds live test coverage for iothub_device_list. |
| tools/Azure.Mcp.Tools.IoTHub/tests/Azure.Mcp.Tools.IoTHub.LiveTests/Azure.Mcp.Tools.IoTHub.LiveTests.csproj | Adds live test project for IoT Hub toolset. |
| tools/Azure.Mcp.Tools.IoTHub/src/Services/IoTHubService.cs | Implements ARM-side IoT Hub discovery and key retrieval helpers. |
| tools/Azure.Mcp.Tools.IoTHub/src/Services/IoTHubDeviceService.cs | Implements data-plane device registry listing via IoT Hub REST + SAS auth. |
| tools/Azure.Mcp.Tools.IoTHub/src/Services/IIoTHubService.cs | Adds IoT Hub service contract (hub lookup + keys). |
| tools/Azure.Mcp.Tools.IoTHub/src/Services/IIoTHubDeviceService.cs | Adds device registry service contract (list devices). |
| tools/Azure.Mcp.Tools.IoTHub/src/Options/IoTHubOptionDefinitions.cs | Defines CLI options for IoT Hub commands (name, max-count). |
| tools/Azure.Mcp.Tools.IoTHub/src/Options/Device/IoTHubDeviceListOptions.cs | Adds options POCO for the device list command. |
| tools/Azure.Mcp.Tools.IoTHub/src/Models/IoTHubKey.cs | Adds model to represent IoT Hub SAS policies/keys (internal plumbing). |
| tools/Azure.Mcp.Tools.IoTHub/src/Models/IoTHubDescription.cs | Adds model for IoT Hub metadata returned from ARM query. |
| tools/Azure.Mcp.Tools.IoTHub/src/Models/DeviceListResult.cs | Adds response model (devices + truncated flag). |
| tools/Azure.Mcp.Tools.IoTHub/src/Models/DeviceIdentity.cs | Adds device identity DTO (intentionally excluding auth keys). |
| tools/Azure.Mcp.Tools.IoTHub/src/IoTHubSetup.cs | Registers IoT Hub services + commands into the area system. |
| tools/Azure.Mcp.Tools.IoTHub/src/GlobalUsings.cs | Adds global usings for the new toolset. |
| tools/Azure.Mcp.Tools.IoTHub/src/Commands/IoTHubJsonContext.cs | Adds STJ source-gen context for IoT Hub models (AOT-safe). |
| tools/Azure.Mcp.Tools.IoTHub/src/Commands/Device/IoTHubDeviceListCommand.cs | Adds azmcp iothub device list command implementation. |
| tools/Azure.Mcp.Tools.IoTHub/src/Commands/BaseIoTHubCommand.cs | Adds IoT Hub command base to share common subscription/resource-group options. |
| tools/Azure.Mcp.Tools.IoTHub/src/Azure.Mcp.Tools.IoTHub.csproj | Adds new toolset project and dependencies. |
| tools/Azure.Mcp.Tools.IoTHub/src/AssemblyInfo.cs | Adds InternalsVisibleTo for new test projects. |
| servers/Azure.Mcp.Server/src/Program.cs | Registers the new IoT Hub area and adjusts console logging behavior. |
| servers/Azure.Mcp.Server/README.md | Adds IoT Hub to the supported services list. |
| servers/Azure.Mcp.Server/docs/e2eTestPrompts.md | Adds e2e prompts for IoT Hub device list tool. |
| servers/Azure.Mcp.Server/docs/azmcp-commands.md | Documents the new azmcp iothub device list command. |
| servers/Azure.Mcp.Server/CHANGELOG.md | Adds changelog entry for the new IoT Hub command. |
| package.json | Adds root Node dependency on @azure/mcp. |
| package-lock.json | Locks root Node dependency graph for @azure/mcp. |
| dotnet-tools.json | Adds a dotnet tool manifest with the azmcp tool. |
| Directory.Packages.props | Adds IoTHub ARM SDK package version and bumps OTel exporter version. |
| core/Azure.Mcp.Core/src/Services/Http/HttpClientService.cs | Redirects debug output to stderr to avoid corrupting stdout JSON. |
| core/Azure.Mcp.Core/src/Areas/Server/Resources/consolidated-tools.json | Adds consolidated mapping entry for the new IoT Hub device list tool. |
| .vscode/settings.json | Adds VS Code MCP sampling config for a local IoT Hub-only server profile. |
| .vscode/mcp.json | Adds a local MCP server config to run Azure.Mcp.Server filtered to iothub. |
| .github/CODEOWNERS | Adds CODEOWNERS entries for the new IoT Hub toolset. |
|
@microsoft-github-policy-service agree company="Microsoft" |
The tenant and credential are removed because they are never being used. Removed unused dependencies Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Remove unused namespace Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Remove unused namespace Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Update agent description Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Removed unused logger Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Removed nonexist dependency Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Update Absolute Path to Relative Path Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Try dotnet build, if failed, install the relevant packages Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| @@ -0,0 +1,16 @@ | |||
| { | |||
| "servers": { | |||
| "iris-local-mcp": { | |||
There was a problem hiding this comment.
remove the files in .vscode
| ``` | ||
| ### Azure IoT Hub Operations | ||
|
|
||
| #### Device Registry Operations |
There was a problem hiding this comment.
Add all IoT Hub Operations in one place.
There's an Azure service named 'Azure Device Registry' so lets not use the same command group name. Could you please sync with Adarsh if sth like 'Device Identity' works
| { | ||
| "name": "get_azure_iot_hub", | ||
| "description": "Get details about an Azure IoT Hub.", | ||
| "description": "Get details about an Azure IoT Hub and list devices registered in its device registry.", |
There was a problem hiding this comment.
Does this mean 'get iot hub' command also pulls devices?
| @@ -0,0 +1,16 @@ | |||
| { | |||
There was a problem hiding this comment.
Could you please capture a screenshot of the evaluator run with the ranking score and post to the PR description
Adds the
azmcp iothub device listcommand to list device identities in an Azure IoT Hub device registry. Returns device metadata without authentication keys, supports --max-count (default 100, maximum 100) with a truncated flag when more devices exist, and returns a validation error when --max-count is less than 1.Includes the Azure.Mcp.Tools.IoTHub project (device list command, options, models, services, unit and live tests) and wires it into the server registration, command docs, e2e prompts, CHANGELOG, and consolidated-tools.json.
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