Skip to main content
Glama
uninstall.sh2.56 kB
#!/usr/bin/env bash set -euo pipefail # Improved repo-level uninstall wrapper (home-only by default) SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # Default to per-user install path, NOT the repository root (safety) INSTALL_DIR="${INSTALL_DIR:-$HOME/MCPServer}" if [ -n "${INSTALL_TARGET:-}" ] && [ -x "$INSTALL_TARGET/bin/uninstall.sh" ]; then exec "$INSTALL_TARGET/bin/uninstall.sh" "$@" fi # If a standard home install exists, prefer its own uninstall if [ -x "$HOME/MCPServer/bin/uninstall.sh" ] && [ "${INSTALL_DIR}" = "$HOME/MCPServer" ]; then exec "$HOME/MCPServer/bin/uninstall.sh" "$@" fi FORCE="${FORCE:-no}" echo "Stopping any running MCP server in $INSTALL_DIR..." # Prefer run-level pid file if [ -f "$INSTALL_DIR/run/mcp-server.pid" ]; then PID=$(cat "$INSTALL_DIR/run/mcp-server.pid" 2>/dev/null || echo "") if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then echo "Stopping PID $PID" kill "$PID" 2>/dev/null || true sleep 1 if kill -0 "$PID" 2>/dev/null; then kill -9 "$PID" 2>/dev/null || true fi fi rm -f "$INSTALL_DIR/run/mcp-server.pid" || true fi echo "Removing helper wrapper (if present)..." rm -f "$HOME/.local/bin/mcp-server" || true # Safety guard: refuse to remove the repository directory by default IS_REPO_DIR="no" if [ -f "$INSTALL_DIR/server.py" ] || [ -d "$INSTALL_DIR/.git" ] || [ -f "$INSTALL_DIR/scripts/setup.sh" ]; then IS_REPO_DIR="yes" fi if [ "$IS_REPO_DIR" = "yes" ] && [ "$INSTALL_DIR" = "$PROJECT_ROOT" ] && [ "${FORCE_REPO:-no}" != "yes" ]; then echo "Refusing to remove what looks like the source repository: $INSTALL_DIR" >&2 echo "Hint: The installed runtime lives under: $HOME/MCPServer" >&2 echo "Set INSTALL_DIR to that path, or run: $HOME/MCPServer/bin/uninstall.sh" >&2 echo "To override this safety check, re-run with FORCE_REPO=yes and explicit confirmation." exit 1 fi if [ "$FORCE" = "yes" ]; then echo "FORCE=yes set; removing installation and logs without prompting: $INSTALL_DIR" rm -rf "$INSTALL_DIR" || true echo "Installation directory removed" else echo "You are about to remove: $INSTALL_DIR" read -p "Type the exact path to confirm deletion: " -r CONFIRM_PATH if [ "$CONFIRM_PATH" != "$INSTALL_DIR" ]; then echo "Confirmation did not match. Aborting without changes." exit 1 fi rm -rf "$INSTALL_DIR" echo "Installation directory removed" fi echo "Uninstallation complete"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dnchandra/mcp_linux'

If you have feedback or need assistance with the MCP directory API, please join our Discord server