Skip to content

Conversation

@michaelmalave
Copy link
Contributor

@michaelmalave michaelmalave commented Jun 19, 2025

Description

This PR adds a new tool to the Heroku MCP Server that enables the removal of add-ons from Heroku applications. This functionality is essential for managing application resources and controlling costs by allowing users to remove unused or unnecessary add-ons.

Key Features

  • New destroy_addon tool for removing add-ons from Heroku apps
  • Comprehensive input validation with Zod schema
  • Automatic confirmation handling for safe deletion
  • Detailed error handling and user feedback
  • Support for multiple add-on identifier types (UUID, name, or attachment name)

Technical Details

Implementation

  • Added registerDestroyAddonTool function in src/tools/addons.ts
  • Created destroyAddonOptionsSchema for input validation:
    • Required app parameter for target application
    • Required addon parameter supporting multiple identifier formats
  • Integrated with Heroku CLI using addons:destroy command
  • Added automatic confirmation to prevent accidental deletions
  • Implemented standard error handling pattern

Error Handling

  • Validates input parameters before execution
  • Handles common error cases:
    • Non-existent add-ons
    • Permission issues
    • Invalid app names
  • Returns clear error messages to users

Testing Instructions

Prerequisites

  • Node.js 20 or higher
  • Heroku CLI installed and authenticated
  • Cursor

Testing

  • Checkout this branch with git pull && git checkout tool-destroy_addon
  • Ensure you're using the correct version of Node (>20.x)
  • If you have the AI plugin installed, uninstall it: heroku plugins:uninstall @heroku/plugin-ai
  • Run npm install && npm run build

Update and enable the mcp.json in Cursor.

{
  "mcpServers": {
    "heroku": {
      "command": "node --inspect Path/to/bin/heroku-mcp-server.mjs",
      "env": {
        "DEBUG": "true",
        "MCP_SERVER_REQUEST_TIMEOUT": 10000
      }
    }
  }
}
  • Test the destruction of an addon (you may add one before this), providing correct required parameters. Both should succeed.
  • Reinstall your Heroku CLI Plugin AI, if you uninstalled it: heroku plugins:install @heroku/plugin-ai
  1. Error Cases
    • Try removing non-existent add-on
    • Attempt removal without proper permissions
    • Use invalid app name
    • Use invalid add-on identifier

Impact

  • Enables complete add-on lifecycle management in MCP
  • Improves resource management capabilities
  • Reduces manual CLI operations
  • Enhances automation possibilities for add-on management

Future Considerations

  • Add batch deletion capability for multiple add-ons
  • Implement dry-run mode for validation
  • Add backup options before deletion for data-storing add-ons
  • Consider adding force flag for skipping confirmations

Related Documentation

@michaelmalave michaelmalave requested a review from a team as a code owner June 19, 2025 22:13
@michaelmalave michaelmalave changed the title feat: Add destroy_addon tool WIP: feat: Add destroy_addon tool Jun 20, 2025
@michaelmalave michaelmalave changed the title WIP: feat: Add destroy_addon tool feat: Add destroy_addon tool Jun 20, 2025
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