#!/usr/bin/env node
/**
* Simple MCP Server Test with Local Video
* Based on previous testing approach from test_pipeline.py
*/
import { ClipSenseClient } from './dist/client.js';
import { existsSync, statSync } from 'fs';
const VIDEO_PATH = process.argv[2] || '/Users/jerlitaburanday/clipsense/test-video.mp4';
const API_KEY = process.env.CLIPSENSE_API_KEY;
async function testMCPServer() {
console.log('๐งช ClipSense MCP Server - Video Analysis Test\n');
console.log('='.repeat(70));
// Step 1: Check API key
console.log('\n๐ Step 1: Verifying API Key...');
if (!API_KEY) {
console.error('โ No API key found!');
console.error('\nPlease set your API key:');
console.error(' export CLIPSENSE_API_KEY="cs_sk_YOUR_KEY_HERE"');
console.error('\nTo get an API key, provide your email below and check backend logs:');
console.error(' curl -X POST "https://api.clipsense.app/api/v1/keys/request" \\');
console.error(' -H "Content-Type: application/json" \\');
console.error(' -d \'{"email":"your-email@example.com"}\'');
process.exit(1);
}
console.log(`โ
API key found: ${API_KEY.substring(0, 15)}...`);
// Step 2: Check video file
console.log('\n๐ Step 2: Verifying Video File...');
if (!existsSync(VIDEO_PATH)) {
console.error(`โ Video file not found: ${VIDEO_PATH}`);
console.error('\nAvailable videos:');
console.error(' - /Users/jerlitaburanday/clipsense/test-video.mp4 (3.8MB)');
console.error(' - /Users/jerlitaburanday/clipsense/input.mov (13MB)');
console.error(' - /Users/jerlitaburanday/Pictures/ASUGradBlastClip2.mp4 (147MB)');
console.error('\nUsage: node test-with-video.js [video-path]');
process.exit(1);
}
const stats = statSync(VIDEO_PATH);
const sizeMB = (stats.size / 1024 / 1024).toFixed(2);
console.log(`โ
Video found: ${VIDEO_PATH}`);
console.log(`๐ Size: ${sizeMB} MB`);
if (stats.size > 500 * 1024 * 1024) {
console.error('โ Video exceeds 500MB limit');
process.exit(1);
}
// Step 3: Initialize MCP client
console.log('\n๐ Step 3: Initializing ClipSense Client...');
const client = new ClipSenseClient(API_KEY);
console.log('โ
Client initialized');
// Step 4: Analyze video
console.log('\n๐ Step 4: Starting Video Analysis...');
console.log('โณ This will take 2-3 minutes...\n');
const startTime = Date.now();
try {
const result = await client.analyzeVideo(
VIDEO_PATH,
'Analyze this video and describe what you see. Identify any issues or bugs.'
);
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
console.log('\n' + '='.repeat(70));
console.log('โ
ANALYSIS COMPLETE');
console.log('='.repeat(70));
console.log(`\n๐ Job ID: ${result.jobId}`);
console.log(`โฑ๏ธ Duration: ${duration}s\n`);
console.log('๐ Analysis Result:\n');
console.log(result.analysis);
console.log('\n' + '='.repeat(70));
console.log('โ
MCP Server Test PASSED');
console.log('='.repeat(70));
console.log('\n๐ก Next Steps:');
console.log(' โข View full analysis at: https://clipsense.app/results/' + result.jobId);
console.log(' โข Try another video with: node test-with-video.js <path>');
} catch (error) {
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
console.log('\n' + '='.repeat(70));
console.log('โ ANALYSIS FAILED');
console.log('='.repeat(70));
console.log(`\nโฑ๏ธ Duration: ${duration}s`);
console.log(`โ Error: ${error.message}\n`);
if (error.response) {
console.log(`HTTP Status: ${error.response.status}`);
console.log(`Response: ${JSON.stringify(error.response.data, null, 2)}`);
}
console.log('\n' + '='.repeat(70));
console.log('โ MCP Server Test FAILED');
console.log('='.repeat(70));
console.log('\n๐ Troubleshooting:');
console.log(' โข Check API key is valid');
console.log(' โข Verify backend is healthy: https://api.clipsense.app/health');
console.log(' โข Check worker is running for job processing');
console.log(' โข Review backend logs: railway logs --service clipsense');
process.exit(1);
}
}
testMCPServer().catch(error => {
console.error('โ Fatal error:', error);
process.exit(1);
});