setup-test.sh•3.87 kB
#!/bin/bash
# Setup script for testing Aptos MCP Server
# This script helps you set up everything needed for testing
echo "🚀 Aptos MCP Server Test Setup"
echo "================================"
# Check if Node.js is installed
if ! command -v node &> /dev/null; then
echo "❌ Node.js is not installed. Please install Node.js 18+ first."
echo " Visit: https://nodejs.org/"
exit 1
fi
echo "✅ Node.js found: $(node --version)"
# Check if npm is installed
if ! command -v npm &> /dev/null; then
echo "❌ npm is not installed. Please install npm first."
exit 1
fi
echo "✅ npm found: $(npm --version)"
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
echo "📦 Installing dependencies..."
npm install
if [ $? -ne 0 ]; then
echo "❌ Failed to install dependencies"
exit 1
fi
else
echo "✅ Dependencies already installed"
fi
# Build the project
echo "🔨 Building project..."
npm run build
if [ $? -ne 0 ]; then
echo "❌ Build failed"
exit 1
fi
echo "✅ Build successful"
# Check if build directory exists
if [ ! -d "build" ]; then
echo "❌ Build directory not found"
exit 1
fi
echo "✅ Build directory found"
# Set up environment variables for testing
echo ""
echo "🔧 Environment Setup"
echo "===================="
# Check if private key is set
if [ -z "$APTOS_MCP_PRIVATE_KEY" ]; then
echo "⚠️ APTOS_MCP_PRIVATE_KEY not set"
echo " For testing, you can use a dummy key:"
echo " export APTOS_MCP_PRIVATE_KEY=\"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\""
echo ""
echo " For real testing, generate a key with Aptos CLI:"
echo " 1. Install Aptos CLI: https://aptos.dev/tools/aptos-cli/install-cli/"
echo " 2. Run: aptos init"
echo " 3. Use the private key from .aptos/config.yaml"
echo ""
# Set dummy key for basic testing
export APTOS_MCP_PRIVATE_KEY="0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
echo "🔧 Using dummy private key for basic testing"
else
echo "✅ APTOS_MCP_PRIVATE_KEY is set"
fi
# Set network to testnet if not set
if [ -z "$APTOS_MCP_NETWORK" ]; then
export APTOS_MCP_NETWORK="testnet"
echo "🔧 Using testnet (default)"
else
echo "✅ APTOS_MCP_NETWORK is set to: $APTOS_MCP_NETWORK"
fi
echo ""
echo "🧪 Running Tests"
echo "================"
# Run the automated test
echo "Running automated test suite..."
node test-mcp.js
if [ $? -eq 0 ]; then
echo ""
echo "🎉 Setup and testing completed successfully!"
echo ""
echo "📋 Next Steps:"
echo "=============="
echo "1. Manual testing:"
echo " node test-mcp.js"
echo ""
echo "2. Interactive example:"
echo " node example-usage.js"
echo ""
echo "3. Manual JSON-RPC testing:"
echo " echo '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\"}' | node build/index.js"
echo ""
echo "4. Integration with Claude Desktop:"
echo " See test-manual.md for configuration instructions"
echo ""
echo "5. For real Aptos operations:"
echo " - Get a real private key from Aptos CLI"
echo " - Set APTOS_MCP_PRIVATE_KEY environment variable"
echo " - Fund your account using the fund_account tool"
echo ""
echo "📚 Documentation:"
echo " - README.md - Complete documentation"
echo " - test-manual.md - Manual testing guide"
echo ""
else
echo ""
echo "❌ Tests failed. Please check the output above for errors."
echo ""
echo "🔍 Troubleshooting:"
echo " - Make sure all dependencies are installed: npm install"
echo " - Check that the build was successful: npm run build"
echo " - Verify environment variables are set correctly"
echo " - Check the error messages above for specific issues"
fi