#!/bin/bash
# Test MCP Content Analyzer connection and functionality
set -e
echo "π Testing MCP Content Analyzer..."
# Check if server is built
if [ ! -d "dist" ]; then
echo "β Server not built. Run 'npm run build' first."
exit 1
fi
# Check if Claude Desktop config exists
CLAUDE_CONFIG="$HOME/Library/Application Support/Claude/claude_desktop_config.json"
if [ ! -f "$CLAUDE_CONFIG" ]; then
echo "β Claude Desktop configuration not found. Run './scripts/generate-config.sh' first."
exit 1
fi
echo "β
Build directory exists"
echo "β
Claude Desktop configuration found"
# Test TypeScript compilation
echo "π Testing TypeScript compilation..."
npm run type-check
echo "β
TypeScript compilation successful"
# Test Node.js imports
echo "π Testing Node.js module imports..."
node -e "
import('./dist/index.js')
.then(() => console.log('β
Module imports successful'))
.catch(err => {
console.error('β Module import failed:', err.message);
process.exit(1);
});
" --input-type=module
# Check dependencies
echo "π Checking critical dependencies..."
node -e "
try {
require('@modelcontextprotocol/sdk/server/index.js');
require('pdfjs-dist');
require('mammoth');
require('playwright');
require('exceljs');
console.log('β
All critical dependencies available');
} catch (err) {
console.error('β Dependency check failed:', err.message);
process.exit(1);
}
"
# Test data directory
echo "π Testing data directory..."
if [ ! -d "data" ]; then
mkdir -p data
echo "β
Created data directory"
else
echo "β
Data directory exists"
fi
# Test logs directory
echo "π Testing logs directory..."
if [ ! -d "logs" ]; then
mkdir -p logs
echo "β
Created logs directory"
else
echo "β
Logs directory exists"
fi
# Test environment configuration
echo "π Testing environment configuration..."
if [ -f ".env" ]; then
echo "β
Environment file exists"
else
cp .env.template .env
echo "β
Created environment file from template"
fi
# Test Playwright browser installation
echo "π Testing Playwright browser..."
if npx playwright --version > /dev/null 2>&1; then
echo "β
Playwright installed"
# Check if chromium is available
node -e "
import('./dist/servers/web-scraper.js')
.then(module => {
console.log('β
Web scraper module loadable');
})
.catch(err => {
console.log('β οΈ Web scraper may need browser installation');
console.log('Run: npx playwright install chromium');
});
" --input-type=module
else
echo "β οΈ Playwright not found. Web scraping may not work."
fi
echo ""
echo "π― Connection Test Summary:"
echo "β
TypeScript compilation"
echo "β
Node.js module loading"
echo "β
Dependencies available"
echo "β
Directory structure"
echo "β
Configuration files"
echo ""
echo "π Manual Testing Steps:"
echo "1. Restart Claude Desktop completely"
echo "2. In Claude Desktop, try:"
echo ' "Please test the MCP connection by calling test_connection with message \"Test from script\""'
echo ' "Can you get the server information using get_server_info?"'
echo ""
echo "π If manual tests work, the MCP server is ready!"
echo "π Monitor logs: tail -f ~/Library/Logs/Claude/mcp-server-content-analyzer.log"