mirror of
https://github.com/awslabs/iam-policy-autopilot.git
synced 2026-04-26 00:15:57 +03:00
[PR #145] [CLOSED] feat(mcp): enable policy explanations in generate_policy tool #264
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/iam-policy-autopilot#264
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/awslabs/iam-policy-autopilot/pull/145
Author: @Oluwatobi-Mustapha
Created: 2/9/2026
Status: ❌ Closed
Base:
main← Head:feat/mcp-explanations📝 Commits (10+)
5b7adcefeat(mcp): enable policy explanations in generate_policy toolcb6cf34refactor(mcp): reduce visibility and harden tests278dce5refactor(mcp): reduce visibility and harden tests87608fddocs: update Operation struct docs to match fields5ea6a14style: fix clippy manual-non-exhaustive and apply cargo fmt3e2c690Merge branch 'main' into feat/mcp-explanations2ba54d9Merge branch 'main' into feat/mcp-explanations034eb37docs: update tool prompt with explanation instructions3a67a3cdocs: fix formatting in mcp.rsb3a0937chore: apply clippy fixes and resolve url deserialization📊 Changes
5 files changed (+155 additions, -428 deletions)
View changed files
📝
iam-policy-autopilot-mcp-server/src/mcp.rs(+7 -6)📝
iam-policy-autopilot-mcp-server/src/tools/generate_policy.rs(+113 -5)📝
iam-policy-autopilot-policy-generation/src/enrichment/mod.rs(+13 -10)📝
iam-policy-autopilot-policy-generation/src/enrichment/service_reference.rs(+13 -405)📝
iam-policy-autopilot-policy-generation/src/lib.rs(+9 -2)📄 Description
Description of changes
Context
The core
iam-policy-autopilotengine can generate reasoning data (mapping permissions to source code lines), but the MCP server was previously discarding this data. This limited AI agents’ ability to understand why a specific permission was granted.Changes
GeneratePoliciesInputto accept an optionalexplainboolean, andGeneratePoliciesOutputto return a serializedexplanationsstring.generate_application_policieslogic to pass the explanation filter to the core engine and serialize the results.enrichmentmodule iniam-policy-autopilot-policy-generationfrompub(crate)topubto enable robust integration testing of explanation data structures.#![deny(missing_docs)]).test_generate_application_policies_with_explanationsto verify end-to-end data flow.Visual proof
Before (Gap Identified): Output contains only the policy, lacking context.

After: Output now includes detailed reasoning mapping actions (e.g.,

s3:ListBucket) to source locations.Testing
Ran:
✅ Result: All tests passed, including the new
test_generate_application_policies_with_explanations.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.