Add MCP tools to delete an instance and roll back a hosted instance - #8693
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8693 +/- ##
==========================================
+ Coverage 77.86% 77.87% +0.01%
==========================================
Files 474 474
Lines 25582 25594 +12
Branches 6810 6814 +4
==========================================
+ Hits 19920 19932 +12
Misses 5662 5662
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…t the rollback description The instance id went straight into the inject URL, which resolves dot segments, so an id like ../applications/<id> deleted an application. The handler now takes only a hosted instance UUID or a device hashid matching instanceType. Rollback replies before the triggered restart finishes, and skips settings the template locks. Devices of a deleted hosted instance are left without an application.
andypalmi
left a comment
There was a problem hiding this comment.
Thanks, this looks good. Delete goes through the real project and device routes, so container removal, device notifications, billing and audit logging are all handled there. Rollback matches the route's snapshot ownership check.
A heads up on merge order: this and #8692 both add tools at the end of instances.js and shared-instances-devices.js (and their specs). Whichever merges second will conflict there, and keeping both sides should be enough. Both PRs also add the same hosted-UUID-or-device-hashid check, so once both are in, it might be worth pulling that into a shared helper in schemas.js.
Co-authored-by: Andrea Palmieri <76187074+andypalmi@users.noreply.github.com>
# Conflicts: # forge/ee/lib/mcp/tools/instances.js # forge/ee/lib/mcp/tools/shared-instances-devices.js # test/unit/forge/ee/lib/mcp/tools/instances_spec.js # test/unit/forge/ee/lib/mcp/tools/shared-instances-devices_spec.js
Closes #7686
Adds
platform_delete_instance(hosted or remote, like the other shared instance tools) andplatform_rollback_hosted_instance.Both are marked destructive, so they're served as delete tools and read-only tokens can't reach them. Rollback isn't a delete, but it overwrites what's running, so it goes behind the same gate.
What I found when I tried deleting against the real routes:
For rollback: it replaces flows, credentials, settings, env vars (replaced, not merged) and modules. If the instance is running it restarts the flows before replying. A snapshot that isn't this instance's gets a 400
invalid_snapshot. The current state isn't saved anywhere first, so the description suggests taking a snapshot before rolling back. The input is calledsnapshotIdto match the other snapshot tools, where the issue draft hadsnapshot.Heads up: this touches the same spots in
instances.js,shared-instances-devices.jsand their specs as #8692, so whichever lands second will need a quick rebase.