Skip to content

feat(app-inspector): explain IAM denials and suggest fixes; recommend them over the IAM policy analyzer - #140

Draft
joe4dev wants to merge 1 commit into
devx-1089-update-the-app-inspector-mcp-tool-with-iamfrom
devx-1089-iam-actions
Draft

joe4dev wants to merge 1 commit into
devx-1089-update-the-app-inspector-mcp-tool-with-iamfrom
devx-1089-iam-actions

Conversation

@joe4dev

@joe4dev joe4dev commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Motivation

DEVX-1089: localstack-app-inspector should give an agent the same IAM data the App Inspector UI shows: the policies that decided a request, LocalStack's suggested fix, and least-privilege policies derived from a run. It should return them in a form an agent can act on without scraping free text. Until now, IAM went through localstack-iam-policy-analyzer, which parses container logs and synthesizes policies in the client, against the design rules in #136.

Stacked on #136 (design rules), whose "IAM policies" section this implements.

Solution

New actions on localstack-app-inspector:

Action What it returns
list-iam-denials One row per denied request (paginated): operation, principal, enforcement, the suggestion's outcome
explain-iam The deciding policies and matched statements, the suggested fix (suggestion v1: outcome, entries, near misses, hints) in the order of the UI's agent prompt, then the payload as LocalStack sent it
get-iam-policy The full documents of a policy the event truncated
get-auto-derived-iam-policies / reset-auto-derived-iam-policies Least-privilege policies LocalStack auto-derived from the requests since the last reset
get-iam-mode / set-iam-mode The enforcement mode through /_aws/iam/config
  • Render only. The responses show what the backend sends: no client-side IAM decisions and no fallback computation for older payloads. Payload text is escaped so it can't break the markdown.
  • Empty results explain themselves: licence suppression (span probe), the IAM mode, and the services App Inspector doesn't record (STS, IAM, CloudWatch Logs).
  • Server instructions (xmcp.config.ts) point agents to list-iam-denials before they change a policy, or conclude another account must change one.
  • localstack-iam-policy-analyzer stays, and recommends App Inspector. Whether to deprecate it is a pending product decision, recorded under "Open questions" in AGENTS.md. Until then it works unchanged; its description and every response recommend the localstack-app-inspector action for the same job, without saying it is deprecated.
  • CI: the tool tests and the MCP evals run localstack/localstack-pro:dev, which has the IAM event details before a release does.
  • Docs: README, manifest and the iam-troubleshooting prompt. AGENTS.md gets the IAM design ("Features → IAM policies"), which moved here from docs: add agent design rules and review checks (AGENTS.md, REVIEW.md) #136 and now describes what is built, plus its LocalStack gaps, the analyzer's deviation and the open deprecation decision. REVIEW.md §6 gets the IAM review checks.

New LocalStack APIs (maintainer approval needed)

Per AGENTS.md, adopting these needs a maintainer's approval recorded here:

  • GET /_localstack/appinspector/v1/events/{event_id}/policies/{policy_key} (get-iam-policy)
  • GET / DELETE /_aws/iam/policies/summary (get-auto-derived-iam-policies, reset-auto-derived-iam-policies)

Agentic evaluation

The end-to-end eval is in the follow-up PR (#141). Claude Code (Sonnet 5.5) fixed small CloudFormation projects with and without this server; both arms had the AWS CLI and LocalStack's log. There were 3 runs per scenario, on the Claude subscription and on OpenRouter.

Scenario Without server With server (App Inspector used)
01–05: every policy readable (missing permission, explicit deny, boundary, Lambda resource policy, not IAM) 30/30 30/30 (0)
06 central event bus (other account) 0/6 6/6 (6)
07 cross-account KMS key 0/6 6/6 (6)
08 cross-account bucket 0/6 6/6 (6)
  • Where the server makes the difference: when the deciding policy is in another account, the agent can't read it. Without the server it stops at "the other account must grant us".
  • No harm elsewhere: where the agent can read every policy, it doesn't call the server, and turns and cost are unchanged.
  • Cost: 06–08 cost about 20–25% more per run with the server, $0.09–0.135 against $0.06–0.09.

For the deprecation decision

A second run (Claude subscription, 3 runs per scenario) compared the analyzer with App Inspector:

Arm 01–05 06–08 Cost per run, 06–08
No server 15/15 0/9 $0.082
App Inspector, analyzer deprecated 15/15 9/9 $0.127
App Inspector, analyzer only recommended against (this PR) 15/15 9/9 $0.127
Analyzer only (instructions point to it) 15/15 0/9 $0.092
  • Deprecation label: with App Inspector available, agents never called the analyzer, whether it was labelled deprecated or not.
  • Analyzer only: pointed at the analyzer, agents called it in 4 of 9 cross-account runs. It only repeated the error message, because a log can't show another account's policy, and every run ended with "the other account must change its policy".

Testing

  • yarn test: 601/601. yarn build passes.
  • tests/mcp/direct.spec.mjs and tools.spec.mjs cover the new actions against a real LocalStack in CI.

Review

Advise review: this adds a user-facing IAM workflow, steers agents away from an existing tool, and adopts two LocalStack APIs.

🤖 Generated with Claude Code

@joe4dev joe4dev changed the title feat(app-inspector): explain IAM denials and suggest fixes; deprecate the IAM policy analyzer feat(app-inspector): explain IAM denials and suggest fixes; recommend them over the IAM policy analyzer Nov 23, 2026
joe4dev added a commit that referenced this pull request Nov 23, 2026
…nned runners

The IAM section, its LocalStack gaps, the agentic-eval follow-up and REVIEW §6's checks move to the IAM actions
PR (#140), which documents them as built. The runner pins and stripped model keys of #139 are on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joe4dev
joe4dev force-pushed the devx-1089-update-the-app-inspector-mcp-tool-with-iam branch from 756ad8d to f6aae77 Compare November 23, 2026 15:18
joe4dev added a commit that referenced this pull request Nov 23, 2026
…nned runners

The IAM section, its LocalStack gaps, the agentic-eval follow-up and REVIEW §6's checks move to the IAM actions
PR (#140), which documents them as built. The runner pins and stripped model keys of #139 are on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joe4dev
joe4dev force-pushed the devx-1089-update-the-app-inspector-mcp-tool-with-iam branch from f6aae77 to bf23440 Compare November 23, 2026 15:19
… them over the IAM policy analyzer

localstack-app-inspector gets task-shaped IAM actions that return what the App Inspector UI shows:

- list-iam-denials: one row per denied request, paginated, with the enforcement and the suggestion's outcome.
- explain-iam: the deciding policies and matched statements, LocalStack's suggested fix (suggestion v1:
  outcome, entries, near misses, hints) in the order the UI's agent prompt uses, then the payload as sent.
- get-iam-policy: a truncated policy's full documents.
- get-auto-derived-iam-policies / reset-auto-derived-iam-policies: least-privilege policies LocalStack derives
  from the requests it saw since the last reset.
- get-iam-mode / set-iam-mode: the enforcement mode through /_aws/iam/config.

The responses render only what the backend sends (no client-side IAM decisions) and escape payload text so it
can't break the markdown. The server instructions point agents to list-iam-denials before they change a policy
or conclude that another account must change one.

localstack-iam-policy-analyzer is not deprecated (a pending product decision): it works unchanged, and its
description and every response recommend the app-inspector action for the same job.

AGENTS.md documents the IAM actions ("Features"), their LocalStack gaps and the open deprecation decision;
REVIEW.md §6 gets the IAM checks. CI's tool tests and the MCP evals run the nightly image, which has the IAM
event details.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant