#!/usr/bin/env bash # ============================================================================== # NexAIz CLI — Universal Agent Skills & MCP Config Installer # Usage: # curl -fsSL https://nexaiz.com/install.sh | bash -s -- # e.g. curl -fsSL https://nexaiz.com/install.sh | bash -s -- cursor-ai # ============================================================================== set -e SLUG="${1:-}" if [ -z "$SLUG" ]; then echo "⚡ NexAIz CLI — Universal AI Tools, Agent Skills & MCP Config Installer" echo "Usage: curl -fsSL https://nexaiz.com/install.sh | bash -s -- " echo "Example:" echo " curl -fsSL https://nexaiz.com/install.sh | bash -s -- paperless-ngx" echo " curl -fsSL https://nexaiz.com/install.sh | bash -s -- figma-context-mcp" exit 0 fi echo "🔍 Fetching configuration for '$SLUG' from NexAIz..." API_URL="https://nexaiz.com/api.php?action=cli&slug=${SLUG}" RESPONSE=$(curl -fsSL "$API_URL" 2>/dev/null || true) SUCCESS=$(printf '%s' "$RESPONSE" | grep -o '"success":true' || true) if [ -z "$SUCCESS" ]; then echo "⚠️ Tool or skill '$SLUG' not found in NexAIz catalog." echo "Browse 116,000+ AI tools and MCP servers at https://nexaiz.com/marketplace" exit 1 fi NAME=$(printf '%s' "$RESPONSE" | sed -n 's/.*"name":"\([^"]*\)".*/\1/p') CATEGORY=$(printf '%s' "$RESPONSE" | sed -n 's/.*"category":"\([^"]*\)".*/\1/p') INSTALL_CMD=$(printf '%s' "$RESPONSE" | sed -n 's/.*"installCmd":"\([^"]*\)".*/\1/p') SOURCE_URL=$(printf '%s' "$RESPONSE" | sed -n 's/.*"url":"\([^"]*\)".*/\1/p') DESC=$(printf '%s' "$RESPONSE" | sed -n 's/.*"description":"\([^"]*\)".*/\1/p') echo "✅ Found: $NAME ($CATEGORY)" # 1. Create .cursor/rules and write contextual rule file mkdir -p .cursor/rules 2>/dev/null || true RULE_FILE=".cursor/rules/${SLUG}.mdc" cat < "$RULE_FILE" --- description: ${NAME} (${CATEGORY}) — Context & integration rule globs: ["**/*"] --- # ${NAME} - **Category**: ${CATEGORY} - **Catalog URL**: https://nexaiz.com/tool/${SLUG} ${SOURCE_URL:+- **Upstream URL**: ${SOURCE_URL}} ${DESC:+- **Overview**: ${DESC}} ${INSTALL_CMD:+- **Setup / Run Command**: \`${INSTALL_CMD}\`} EOF echo "📄 Wrote Cursor context rule: $RULE_FILE" # 2. Register mcpServers entry in .cursor/mcp.json so Cursor / Claude Desktop can load it directly MCP_FILE=".cursor/mcp.json" if command -v python3 >/dev/null 2>&1; then python3 - "$MCP_FILE" "$SLUG" "$NAME" "$INSTALL_CMD" "$SOURCE_URL" <<'PY' import json, os, shlex, sys mcp_path, slug, name, install_cmd, source_url = sys.argv[1:6] data = {} if os.path.exists(mcp_path): try: with open(mcp_path, "r", encoding="utf-8") as f: data = json.load(f) except Exception: data = {} if not isinstance(data, dict): data = {} servers = data.setdefault("mcpServers", {}) parts = shlex.split(install_cmd) if install_cmd else [] if parts and parts[0] in ("npx", "uvx", "node", "python", "python3", "docker"): entry = {"command": parts[0], "args": parts[1:]} else: entry = { "command": "npx", "args": ["-y", slug], "metadata": { "name": name, "nexaizUrl": f"https://nexaiz.com/tool/{slug}", "upstreamUrl": source_url or f"https://nexaiz.com/tool/{slug}" } } servers[slug] = entry with open(mcp_path, "w", encoding="utf-8") as f: json.dump(data, f, indent=2) print(f"⚙️ Updated MCP config in {mcp_path} under mcpServers[\"{slug}\"]") PY fi if [ -n "$INSTALL_CMD" ]; then echo "💡 Upstream install / run command:" echo " $INSTALL_CMD" fi echo "🎉 Setup complete for ${NAME} (https://nexaiz.com/tool/${SLUG})"