Repository navigation
Add Azure RBAC PIM approval tools - #2722
Arthur Ma (ArthurMa1978) with Copilot wants to merge 18 commits into
Conversation
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/mcp/sessions/eff3061d-dbec-4724-b1bf-047846d6d0a8 Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
|
Closing this, due to no activity. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
|
Copilot resolve the merge conflicts in this pull request |
Co-authored-by: ArthurMa1978 <20514459+ArthurMa1978@users.noreply.github.com>
Addressed in |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
Copilot , please address all ci errors |
There was a problem hiding this comment.
🟡 Changes recommended
Pending-stage filtering, pagination, and consolidated discovery remain incomplete, and the new Azure operations lack required recorded coverage.
4 open issues
What changed in this PR
Adds Azure RBAC PIM approval workflows to the Authorization toolset, helping approvers discover and approve activation requests without Azure Portal handoffs.
Changes:
- Adds
role approval listandrole approval approvecommands. - Implements ARM REST calls, tenant resolution, and AOT-safe response models.
- Adds mocked command tests, usage documentation, test prompts, and a changelog entry.
| File | Description |
|---|---|
| tools/Azure.Mcp.Tools.Authorization/tests/Azure.Mcp.Tools.Authorization.Tests/RoleAssignmentApprovalListCommandTests.cs | Tests list results, empty responses, and errors. |
| tools/Azure.Mcp.Tools.Authorization/tests/Azure.Mcp.Tools.Authorization.Tests/RoleAssignmentApprovalApproveCommandTests.cs | Tests approval results and errors. |
| tools/Azure.Mcp.Tools.Authorization/src/Services/IAuthorizationService.cs | Declares approval service operations. |
| tools/Azure.Mcp.Tools.Authorization/src/Services/AuthorizationService.cs | Implements approval REST requests and response mapping. |
| tools/Azure.Mcp.Tools.Authorization/src/Options/RoleAssignmentApprovalListOptions.cs | Defines scope and authentication options. |
| tools/Azure.Mcp.Tools.Authorization/src/Options/RoleAssignmentApprovalApproveOptions.cs | Defines approval, stage, and justification inputs. |
| tools/Azure.Mcp.Tools.Authorization/src/Models/RoleAssignmentApprovalStage.cs | Models approval-stage details. |
| tools/Azure.Mcp.Tools.Authorization/src/Models/RoleAssignmentApproval.cs | Models approvals and their stages. |
| tools/Azure.Mcp.Tools.Authorization/src/Commands/RoleAssignmentApprovalListCommand.cs | Exposes pending-approval discovery. |
| tools/Azure.Mcp.Tools.Authorization/src/Commands/RoleAssignmentApprovalApproveCommand.cs | Exposes stage approval. |
| tools/Azure.Mcp.Tools.Authorization/src/Commands/AuthorizationJsonContext.cs | Registers response types for source-generated serialization. |
| tools/Azure.Mcp.Tools.Authorization/src/AuthorizationSetup.cs | Registers both commands and their group. |
| servers/Azure.Mcp.Server/docs/e2eTestPrompts.md | Adds prompts for both tools. |
| servers/Azure.Mcp.Server/docs/azmcp-commands.md | Documents command syntax and safety metadata. |
| servers/Azure.Mcp.Server/changelog-entries/copilot-pim-role-approvals.yaml | Announces the new approval tools. |
Review effort: Balanced
| using var responseDocument = await SendArmRequestAsync( | ||
| HttpMethod.Patch, | ||
| requestUri, | ||
| resolvedTenantId, | ||
| content, |
There was a problem hiding this comment.
Partially addressed in da57dd3; leaving this thread open because genuine recording validation is still blocked. Added AuthorizationApprovalCommandTests.Should_discover_and_approve_controlled_role_request on RecordedCommandTestsBase, with recorded deployment variables for the exact controlled approval/stage. It verifies discovery IDs, assigned approver, pending state, then approval status/result/justification/timestamp. It is explicitly opt-in because it grants Azure access. Setup and the exact Record/Playback invocation are documented in docs/recorded-tests.md. Existing IAzureService.GetClient uses the shared factory/recording transport. HTTP contract tests also exposed and fixed an incorrect PATCH properties wrapper: ARM expects top-level reviewResult and justification. These tests pass, but they are not genuine recordings. No Authorization test settings, controlled pending request, or requester/approver test identities are provisioned here, so no unrelated request was approved and no recording/assets tag was fabricated. A maintainer needs to provision the documented test-only request, run Record then Playback, sanitize/publish assets, and commit the updated assets.json before this thread can be closed.
There was a problem hiding this comment.
Added and pushed genuine recordings in 6e19dce, captured against the user-selected subscription:
Should_list_pending_role_approvals: actual ARM GET, HTTP 200 (the subscription currently returns no approvals assigned to the signed-in approver).Should_reject_missing_role_approval_stage: actual ARM PATCH of verified nonexistent approval/stage IDs, HTTP 404. This exercises the approval command without granting anyone access.
The published asset tag is Azure.Mcp.Tools.Authorization.Tests_dbcf027633 in Azure/azure-sdk-assets, and assets.json now references it. Added an ARM diagnostic-header sanitizer to remove tenant/principal identifiers, checked token/subscription/identity sanitization, and passed the test-proxy secret scan before publishing. The published tag restores cleanly and contains exactly the two new recording files.
Validation:
dotnet build tools\Azure.Mcp.Tools.Authorization\tests\Azure.Mcp.Tools.Authorization.Tests --nologo -v quiet: passed, zero warnings/errors.- Record mode:
dotnet test --project tools\Azure.Mcp.Tools.Authorization\tests\Azure.Mcp.Tools.Authorization.Tests --no-build -- --filter-class '*AuthorizationApprovalCommandTests': 2 passed; the opt-in successful lifecycle was skipped. - Published-tag playback with
AZURE_TOKEN_CREDENTIALS=PlaybackTokenCredential,MCP_TEST_TRANSPORT=stdio, and no local test settings:dotnet test --project tools\Azure.Mcp.Tools.Authorization\tests\Azure.Mcp.Tools.Authorization.Tests --no-build: 46 passed, 1 intentional lifecycle skip. - Published-tag playback with
AZURE_TOKEN_CREDENTIALS=PlaybackTokenCredentialandMCP_TEST_TRANSPORT=http: the approval-class command above passed 2 tests, with 1 intentional lifecycle skip. - Scoped formatting verification, spelling, and
git diff --check: passed.
Leaving this thread open: these recordings cover discovery and the approval error path, not a successful access grant. The existing opt-in lifecycle test still needs a controlled pending request from a separate requester, its approval/stage IDs assigned to the signed-in approver, and authorization to approve that request. No pending request is currently available in the supplied subscription; no successful recording was fabricated or arbitrary approval performed.
I checked the latest PR run: the platform build jobs are failing (Linux/Windows/macOS and container variants), while both npm-wrapper checks passed. Their details point to Azure DevOps; the logs endpoint is inaccessible from this environment (DNS failure), and local |
Register approval tools in consolidated discovery, accept NotReviewed stages, follow and validate ARM continuation links, and correct the approval PATCH body. Add transport regressions and an opt-in recorded lifecycle test with controlled-request setup instructions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4b235fdb-584f-444d-89af-754cc29a6bb1
|
Pushed da57dd3 with the review/CI fixes: - Fixed the missing |
|
/azp run mcp - pullrequest |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
|
/azp run mcp - pullrequest |
|
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command. |
Resolve the shared insertion conflict in ConsolidatedToolMetadataTests by retaining both the PIM role discovery regressions and main's resilience goal assignment metadata coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4b235fdb-584f-444d-89af-754cc29a6bb1
Add genuine Azure HTTP recordings for approval discovery and safe missing-stage rejection, sanitize ARM diagnostic identity metadata, and publish the verified asset tag. Both recordings replay in stdio and HTTP modes. Successful approval remains opt-in pending a controlled request from a separate requester. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4b235fdb-584f-444d-89af-754cc29a6bb1


Fixes #2130
Approvers need a faster way to discover and approve pending Azure RBAC PIM activation requests without relying on Azure Portal handoffs. This adds MCP coverage for listing approvals assigned to the current approver and approving a selected request stage.
Commands
role approval listfor pending PIM role assignment approvals at a scope.role approval approvewith required approval, stage, and justification inputs.Authorization service
Microsoft.Authorization/roleAssignmentApprovals.Docs and coverage
Example usage: