prepare-deployment.sh•6.72 kB
#!/bin/bash
# Prepare Aptos MCP for Smithery.ai deployment
# This script checks everything is ready for deployment
echo "🚀 Preparing Aptos MCP for Smithery.ai Deployment"
echo "=================================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print status
print_status() {
if [ $1 -eq 0 ]; then
echo -e "${GREEN}✅ $2${NC}"
else
echo -e "${RED}❌ $2${NC}"
fi
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_info() {
echo -e "${BLUE}ℹ️ $1${NC}"
}
# Check prerequisites
echo ""
echo "🔍 Checking Prerequisites..."
echo "============================"
# Check Node.js
if command -v node &> /dev/null; then
NODE_VERSION=$(node --version)
print_status 0 "Node.js found: $NODE_VERSION"
else
print_status 1 "Node.js not found"
echo "Please install Node.js 18+ from https://nodejs.org/"
exit 1
fi
# Check npm
if command -v npm &> /dev/null; then
NPM_VERSION=$(npm --version)
print_status 0 "npm found: $NPM_VERSION"
else
print_status 1 "npm not found"
exit 1
fi
# Check git
if command -v git &> /dev/null; then
GIT_VERSION=$(git --version)
print_status 0 "Git found: $GIT_VERSION"
else
print_status 1 "Git not found"
echo "Please install Git from https://git-scm.com/"
exit 1
fi
# Check project structure
echo ""
echo "📁 Checking Project Structure..."
echo "================================"
# Check required files
required_files=("package.json" "tsconfig.json" "smithery.yaml" "README.md" "LICENSE" "src/index.ts")
for file in "${required_files[@]}"; do
if [ -f "$file" ]; then
print_status 0 "$file exists"
else
print_status 1 "$file missing"
exit 1
fi
done
# Check src directory structure
if [ -d "src/tools" ]; then
print_status 0 "src/tools directory exists"
else
print_status 1 "src/tools directory missing"
exit 1
fi
# Check dependencies
echo ""
echo "📦 Checking Dependencies..."
echo "=========================="
if [ -d "node_modules" ]; then
print_status 0 "node_modules exists"
else
print_warning "node_modules not found, installing dependencies..."
npm install
if [ $? -eq 0 ]; then
print_status 0 "Dependencies installed successfully"
else
print_status 1 "Failed to install dependencies"
exit 1
fi
fi
# Build the project
echo ""
echo "🔨 Building Project..."
echo "====================="
npm run build
if [ $? -eq 0 ]; then
print_status 0 "Build successful"
else
print_status 1 "Build failed"
echo "Please fix build errors before deploying"
exit 1
fi
# Check build output
if [ -d "build" ] && [ -f "build/index.js" ]; then
print_status 0 "Build output exists"
else
print_status 1 "Build output missing"
exit 1
fi
# Run tests
echo ""
echo "🧪 Running Tests..."
echo "=================="
if [ -f "test-mcp.js" ]; then
node test-mcp.js > /dev/null 2>&1
if [ $? -eq 0 ]; then
print_status 0 "Tests passed"
else
print_warning "Tests failed - this might be expected if you don't have a real private key"
print_info "Tests will work better with a real Aptos private key"
fi
else
print_warning "Test file not found"
fi
# Validate smithery.yaml
echo ""
echo "⚙️ Validating Smithery Configuration..."
echo "======================================="
if [ -f "smithery.yaml" ]; then
# Basic YAML syntax check (if yq is available)
if command -v yq &> /dev/null; then
yq eval . smithery.yaml > /dev/null 2>&1
if [ $? -eq 0 ]; then
print_status 0 "smithery.yaml syntax is valid"
else
print_status 1 "smithery.yaml has syntax errors"
exit 1
fi
else
print_info "yq not found, skipping YAML validation"
fi
# Check required fields
if grep -q "startCommand:" smithery.yaml && grep -q "configSchema:" smithery.yaml; then
print_status 0 "smithery.yaml has required fields"
else
print_status 1 "smithery.yaml missing required fields"
exit 1
fi
else
print_status 1 "smithery.yaml not found"
exit 1
fi
# Check git status
echo ""
echo "📝 Checking Git Status..."
echo "========================"
if git rev-parse --git-dir > /dev/null 2>&1; then
print_status 0 "Git repository initialized"
# Check if there are uncommitted changes
if git diff-index --quiet HEAD --; then
print_status 0 "No uncommitted changes"
else
print_warning "You have uncommitted changes"
print_info "Consider committing changes before deploying"
fi
# Check if remote is set
if git remote get-url origin > /dev/null 2>&1; then
REMOTE_URL=$(git remote get-url origin)
print_status 0 "Git remote configured: $REMOTE_URL"
else
print_warning "No git remote configured"
print_info "You'll need to push to GitHub before deploying to Smithery"
fi
else
print_warning "Not a git repository"
print_info "Initialize git and push to GitHub before deploying"
fi
# Security check
echo ""
echo "🔒 Security Check..."
echo "==================="
# Check for hardcoded private keys
if grep -r "0x[a-fA-F0-9]\{64\}" src/ --exclude-dir=node_modules 2>/dev/null | grep -v "example\|test\|dummy"; then
print_warning "Potential hardcoded private keys found in source code"
print_info "Make sure no real private keys are committed to git"
else
print_status 0 "No hardcoded private keys found in source"
fi
# Check .gitignore
if [ -f ".gitignore" ]; then
if grep -q "node_modules" .gitignore && grep -q ".env" .gitignore; then
print_status 0 ".gitignore properly configured"
else
print_warning ".gitignore might be missing important entries"
fi
else
print_warning ".gitignore not found"
fi
# Final summary
echo ""
echo "📋 Deployment Readiness Summary"
echo "==============================="
echo ""
print_info "Your Aptos MCP server appears ready for deployment!"
echo ""
echo "Next steps:"
echo "1. 📤 Push your code to GitHub (if not already done)"
echo "2. 🌐 Go to https://smithery.ai"
echo "3. 🔗 Connect your GitHub account"
echo "4. ➕ Add your repository as a new MCP server"
echo "5. 🚀 Deploy from the Deployments tab"
echo ""
echo "📚 For detailed instructions, see DEPLOYMENT.md"
echo ""
echo "🔧 Configuration your users will need:"
echo " - aptosMcpPrivateKey: Their Aptos private key"
echo " - aptosMcpNetwork: testnet or mainnet (default: testnet)"
echo ""
print_info "Good luck with your deployment! 🎉"