#!/bin/bash
# Cleanup script for removing Temporal namespaces and Nexus endpoints
# This script removes the Temporal infrastructure created for the calculator MCP application
set -e
echo "Cleaning up Temporal infrastructure for Nexus MCP Calculator..."
# Default values
HANDLER_NAMESPACE="my-handler-namespace"
CALLER_NAMESPACE="my-caller-namespace"
ENDPOINT_NAME="mcp-gateway"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--handler-namespace)
HANDLER_NAMESPACE="$2"
shift 2
;;
--caller-namespace)
CALLER_NAMESPACE="$2"
shift 2
;;
--endpoint-name)
ENDPOINT_NAME="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " --handler-namespace NAME Handler namespace (default: my-handler-namespace)"
echo " --caller-namespace NAME Caller namespace (default: my-caller-namespace)"
echo " --endpoint-name NAME Nexus endpoint name (default: mcp-gateway)"
echo " -h, --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo "Configuration:"
echo " Handler namespace: $HANDLER_NAMESPACE"
echo " Caller namespace: $CALLER_NAMESPACE"
echo " Endpoint name: $ENDPOINT_NAME"
echo ""
# Check if temporal CLI is available
if ! command -v temporal &> /dev/null; then
echo "Error: temporal CLI is not installed or not in PATH"
echo "Please install the Temporal CLI: https://docs.temporal.io/cli"
exit 1
fi
# Confirm cleanup
read -p "This will delete the specified Temporal namespaces and Nexus endpoint. Continue? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Cleanup cancelled."
exit 0
fi
# Delete Nexus endpoint
echo "Deleting Nexus endpoint: $ENDPOINT_NAME"
temporal operator nexus endpoint delete --name "$ENDPOINT_NAME" || {
echo "Note: Nexus endpoint may not exist or already deleted, continuing..."
}
# Delete namespaces
echo "Deleting handler namespace: $HANDLER_NAMESPACE"
temporal operator namespace delete --namespace "$HANDLER_NAMESPACE" || {
echo "Note: Handler namespace may not exist or already deleted, continuing..."
}
echo "Deleting caller namespace: $CALLER_NAMESPACE"
temporal operator namespace delete --namespace "$CALLER_NAMESPACE" || {
echo "Note: Caller namespace may not exist or already deleted, continuing..."
}
echo ""
echo "✅ Temporal infrastructure cleanup complete!"