Skip to main content
Glama
deploy.sh•5.73 kB
#!/bin/bash # kivv Production Deployment Script # Usage: ./scripts/deploy.sh set -e # Exit on error echo "==================================================" echo " kivv Production Deployment Script" echo "==================================================" echo "" # Colors for output GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # No Color # Check prerequisites echo "šŸ“‹ Checking prerequisites..." # Check bun if ! command -v bun &> /dev/null; then echo -e "${RED}āŒ Bun not found. Install from https://bun.sh${NC}" exit 1 fi echo -e "${GREEN}āœ… Bun installed: $(bun --version)${NC}" # Check wrangler if ! command -v wrangler &> /dev/null; then echo -e "${RED}āŒ Wrangler not found. Installing...${NC}" bun install -g wrangler fi echo -e "${GREEN}āœ… Wrangler installed: $(wrangler --version)${NC}" # Check authentication if ! wrangler whoami &> /dev/null; then echo -e "${RED}āŒ Not authenticated with Cloudflare${NC}" echo "Run: wrangler login" exit 1 fi echo -e "${GREEN}āœ… Authenticated with Cloudflare${NC}" echo "" # Verify infrastructure echo "šŸ—ļø Verifying infrastructure..." if ! wrangler d1 list | grep -q "kivv-db"; then echo -e "${RED}āŒ Database 'kivv-db' not found${NC}" echo "Create database first:" echo " wrangler d1 create kivv-db" exit 1 fi echo -e "${GREEN}āœ… Database exists${NC}" if ! wrangler kv:namespace list | grep -q "KIVV_CACHE"; then echo -e "${YELLOW}āš ļø KV namespace 'KIVV_CACHE' not found${NC}" echo "Create KV namespace:" echo " wrangler kv:namespace create KIVV_CACHE" fi if ! wrangler r2 bucket list | grep -q "kivv-papers"; then echo -e "${YELLOW}āš ļø R2 bucket 'kivv-papers' not found${NC}" echo "Create R2 bucket:" echo " wrangler r2 bucket create kivv-papers" fi echo "" # Check secrets echo "šŸ” Checking secrets..." cd automation if ! wrangler secret list | grep -q "CLAUDE_API_KEY"; then echo -e "${YELLOW}āš ļø CLAUDE_API_KEY not set${NC}" echo "" echo "Please set your Claude API key:" wrangler secret put CLAUDE_API_KEY fi if ! wrangler secret list | grep -q "CRON_SECRET"; then echo -e "${YELLOW}āš ļø CRON_SECRET not set (optional)${NC}" read -p "Set CRON_SECRET for manual triggers? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo "Generating random secret..." SECRET=$(openssl rand -hex 32 2>/dev/null || node -e "console.log(require('crypto').randomBytes(32).toString('hex'))") echo "$SECRET" | wrangler secret put CRON_SECRET echo -e "${GREEN}āœ… CRON_SECRET set to: $SECRET${NC}" echo "Save this secret for manual triggers!" fi fi cd .. echo "" # Deploy automation worker echo "šŸš€ Deploying automation worker..." cd automation if wrangler deploy; then echo -e "${GREEN}āœ… Automation worker deployed${NC}" AUTOMATION_URL=$(wrangler deployments list --json | head -1 | grep -o 'https://[^"]*' | head -1 || echo "https://kivv-automation.<username>.workers.dev") echo " URL: $AUTOMATION_URL" else echo -e "${RED}āŒ Automation worker deployment failed${NC}" exit 1 fi cd .. echo "" # Deploy MCP server echo "šŸš€ Deploying MCP server..." cd mcp-server if wrangler deploy; then echo -e "${GREEN}āœ… MCP server deployed${NC}" MCP_URL=$(wrangler deployments list --json | head -1 | grep -o 'https://[^"]*' | head -1 || echo "https://kivv-mcp.<username>.workers.dev") echo " URL: $MCP_URL" else echo -e "${RED}āŒ MCP server deployment failed${NC}" exit 1 fi cd .. echo "" # Verify deployments echo "āœ… Verifying deployments..." echo "Testing automation worker health..." if curl -sf "${AUTOMATION_URL}/health" > /dev/null 2>&1; then echo -e "${GREEN}āœ… Automation worker healthy${NC}" else echo -e "${YELLOW}āš ļø Automation worker health check failed${NC}" fi echo "Testing MCP server health..." if curl -sf "${MCP_URL}/health" > /dev/null 2>&1; then echo -e "${GREEN}āœ… MCP server healthy${NC}" else echo -e "${YELLOW}āš ļø MCP server health check failed${NC}" fi echo "" # Get API key for Claude Desktop config echo "šŸ”‘ Retrieving API key for Claude Desktop..." API_KEY=$(wrangler d1 execute kivv-db --command "SELECT api_key FROM users LIMIT 1" 2>/dev/null | tail -1 | tr -d ' ' || echo "<API_KEY_FROM_DATABASE>") # Generate Claude Desktop config echo "==================================================" echo " šŸŽ‰ Deployment Complete!" echo "==================================================" echo "" echo "Next steps:" echo "" echo "1. Configure Claude Desktop" echo " File: ~/.config/claude/claude_desktop_config.json" echo " (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json)" echo "" echo " Add this configuration:" echo "" echo ' { "mcpServers": { "kivv": { "url": "'"$MCP_URL"'/mcp", "headers": { "x-api-key": "'"$API_KEY"'" } } } }' echo "" echo "2. Restart Claude Desktop" echo "" echo "3. Test in Claude:" echo ' Type: "List my research papers using kivv MCP"' echo "" echo "4. Monitor deployment:" echo " Automation logs: wrangler tail kivv-automation" echo " MCP logs: wrangler tail kivv-mcp" echo "" echo "5. Verify cron schedule:" echo " Go to: https://dash.cloudflare.com" echo " Workers → kivv-automation → Triggers" echo " Should show: 0 6 * * * (daily at 6 AM UTC)" echo "" echo "For troubleshooting, see: TROUBLESHOOTING.md" echo "For full documentation, see: DEPLOYMENT.md" echo "" echo "==================================================" echo -e "${GREEN}āœ… Ready to use!${NC}" echo "=================================================="

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/jeffaf/kivv'

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