Skip to content

fix: clear mcp.json gateways during remove-all to prevent orphaned AWS resources#484

Merged
tejaskash merged 1 commit intoaws:mainfrom
aidandaly24:fix/gw08-remove-all-clears-gateways
Mar 3, 2026
Merged

fix: clear mcp.json gateways during remove-all to prevent orphaned AWS resources#484
tejaskash merged 1 commit intoaws:mainfrom
aidandaly24:fix/gw08-remove-all-clears-gateways

Conversation

@aidandaly24
Copy link
Contributor

Description

remove -> All only reset agentcore.json, leaving mcp.json untouched. This caused gateway resources (Gateway, Gateway Target, IAM Role) to survive removal — subsequent agentcore deploy saw hasGateways=true, skipped teardown, and kept gateway resources alive in AWS.

This PR adds mcp.json gateway cleanup to both the CLI and TUI remove-all paths:

  • handleRemoveAll() (CLI): resets mcp.json gateways after writeProjectSpec()
  • useRemoveFlow() (TUI): resets mcp.json gateways in runRemoval() + enumerates gateways/targets in the confirmation list so users see what's being removed

No changes to preflight, teardown, or CDK logic — the existing teardown detection already works correctly once mcp.json is cleared.

Related Issue

Documentation PR

N/A — no user-facing docs changes needed. The behavior now matches what users already expect.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Added a new test in remove-all.test.ts that writes mcp.json with a gateway and target, runs remove all --force --json, and verifies agentCoreGateways is cleared to an empty array. All 1892 unit tests pass with 0 failures.

Also manually tested creating a gateway, gateway target, agent. I deployed these resources, then did remove all, and it worked.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

…S resources

remove-all only reset agentcore.json, leaving mcp.json untouched. This caused
gateways to survive removal, and subsequent deploys would keep gateway resources
alive in AWS instead of triggering teardown.

Changes:
- handleRemoveAll (CLI path): reset mcp.json gateways after writeProjectSpec
- useRemoveFlow (TUI path): reset mcp.json gateways + enumerate gateways/targets
  in the confirmation list
- Add test verifying mcp.json gateways are cleared during remove-all

Fixes GW-08
@aidandaly24 aidandaly24 requested a review from a team March 3, 2026 16:14
@github-actions github-actions bot added the size/s PR size: S label Mar 3, 2026
@tejaskash tejaskash merged commit d4aa281 into aws:main Mar 3, 2026
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants