# How to Test ClipSense MCP Server with Local Video
**Date:** December 5, 2025
**Status:** Ready for Testing
**Video:** test-video.mp4 (3.8MB recommended)
---
## Quick Start
### Step 1: Get Your API Key
Since the email system isn't working, we need to retrieve the API key directly from Railway database:
```bash
# Go to Railway dashboard
# Navigate to: clipsense project → clipsense service → Data tab
# Run this SQL query:
SELECT key, user_id, created_at
FROM api_keys
WHERE is_active = true
ORDER BY created_at DESC
LIMIT 1;
```
The API key will look like: `cs_sk_abc123def456...`
**Alternative**: Use your email address that has an existing key:
```bash
# If you've already requested a key before for your email:
curl -X POST "https://api.clipsense.app/api/v1/keys/request" \
-H "Content-Type: application/json" \
-d '{"email":"YOUR_EXISTING_EMAIL@example.com"}'
# The key was created but email failed - check Railway Data tab for the key
```
### Step 2: Set the API Key
```bash
export CLIPSENSE_API_KEY="cs_sk_YOUR_KEY_HERE"
```
### Step 3: Run the Test
```bash
cd /Users/jerlitaburanday/clipsense-mcp-server
# Test with smallest video (recommended)
node test-with-video.js /Users/jerlitaburanday/clipsense/test-video.mp4
# Or with other videos:
# node test-with-video.js /Users/jerlitaburanday/clipsense/input.mov
# node test-with-video.js /Users/jerlitaburanday/Pictures/ASUGradBlastClip2.mp4
```
---
## Available Test Videos
| File | Size | Path | Recommended |
|------|------|------|------------|
| test-video.mp4 | 3.8MB | `/Users/jerlitaburanday/clipsense/test-video.mp4` | ✅ BEST |
| input.mov | 13MB | `/Users/jerlitaburanday/clipsense/input.mov` | ✅ Good |
| ASUGradBlastClip2.mp4 | 147MB | `/Users/jerlitaburanday/Pictures/ASUGradBlastClip2.mp4` | ⚠️ Large |
| ASUGradBlastClip.mp4 | 180MB | `/Users/jerlitaburanday/Pictures/ASUGradBlastClip.mp4` | ⚠️ Large |
---
## Expected Output
```
🧪 ClipSense MCP Server - Video Analysis Test
======================================================================
📋 Step 1: Verifying API Key...
✅ API key found: cs_sk_abc123def...
📋 Step 2: Verifying Video File...
✅ Video found: /Users/jerlitaburanday/clipsense/test-video.mp4
📊 Size: 3.80 MB
📋 Step 3: Initializing ClipSense Client...
✅ Client initialized
📋 Step 4: Starting Video Analysis...
⏳ This will take 2-3 minutes...
======================================================================
✅ ANALYSIS COMPLETE
======================================================================
📊 Job ID: job_xyz123
⏱️ Duration: 127.3s
📝 Analysis Result:
## Mobile Bug Analysis
[Detailed analysis of the video content]
---
**Analysis Details:**
- Frames analyzed: 127
- Tokens used: 45234
- Cost: $0.2345
======================================================================
✅ MCP Server Test PASSED
======================================================================
💡 Next Steps:
• View full analysis at: https://clipsense.app/results/job_xyz123
• Try another video with: node test-with-video.js <path>
```
---
## Troubleshooting
### Error: "No API key found"
**Solution:**
```bash
# Make sure you've exported the key in your current terminal:
export CLIPSENSE_API_KEY="cs_sk_YOUR_KEY"
# Verify it's set:
echo $CLIPSENSE_API_KEY
```
### Error: "Video file not found"
**Solution:**
```bash
# Use full absolute path:
node test-with-video.js /Users/jerlitaburanday/clipsense/test-video.mp4
# Check file exists:
ls -lh /Users/jerlitaburanday/clipsense/test-video.mp4
```
### Error: "Authentication failed" (401)
**Possible Causes:**
1. API key is incorrect or expired
2. API key format is wrong (should start with `cs_sk_`)
3. Backend security fixes broke JWT-less API key auth
**Solution:**
```bash
# Test API key directly:
curl -X POST "https://api.clipsense.app/api/v1/upload/presign" \
-H "Authorization: Bearer $CLIPSENSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"test.mp4","content_type":"video/mp4","file_size":1000}'
# If this returns 401, the API key is invalid
# Get a new one from Railway Data tab
```
### Error: "Analysis timeout after 10 minutes"
**Possible Causes:**
1. Celery worker is not running
2. Video is too long or complex
3. Backend processing is stuck
**Solution:**
```bash
# Check worker status:
railway logs --service worker | tail -20
# Check if jobs are processing:
# Go to Railway Data tab, run:
SELECT id, status, progress, error_message
FROM jobs
ORDER BY created_at DESC
LIMIT 5;
```
### Error: "Upload failed"
**Possible Causes:**
1. Firebase R2 storage issue
2. Network connection problem
3. Video file corrupted
**Solution:**
```bash
# Test video file integrity:
ffmpeg -v error -i /path/to/video.mp4 -f null - 2>&1
# Try smaller video:
node test-with-video.js /Users/jerlitaburanday/clipsense/test-video.mp4
```
---
## How This Relates to Previous Testing
**Previous Test (test_pipeline.py):**
- Used mock JWT token (security vulnerability!)
- Tested against localhost:8000
- Direct Python HTTP requests
**Current Test (test-with-video.js):**
- Uses real API key authentication ✅
- Tests against production API (api.clipsense.app) ✅
- Uses MCP Client SDK (same code as IDE integration) ✅
- Validates all security fixes are working ✅
**Key Differences:**
1. **Authentication:** Mock JWT → Real API Key
2. **Environment:** Localhost → Production
3. **Client:** Raw HTTP → MCP SDK
4. **Security:** Vulnerable → Hardened
---
## What This Test Validates
### ✅ MCP Server Functionality
- API key authentication works
- Video upload to Firebase R2 succeeds
- Presigned URL generation correct
- Video key format validated
- Job submission successful
### ✅ Backend Security Fixes
- Path traversal prevention (filename sanitization)
- Video ownership validation (user can only analyze own videos)
- Debug mode disabled (generic error messages)
- CORS hardening (specific methods/headers)
- Error disclosure prevention (logs vs user messages)
### ✅ End-to-End Flow
- Upload → Analyze → Poll → Results
- Job status polling works
- Result formatting correct
- Cost tracking accurate
---
## Next Steps After Testing
1. **If Test Passes:**
- MCP server is production-ready ✅
- Security fixes didn't break functionality ✅
- Can proceed with DevHunt launch ✅
2. **If Test Fails:**
- Check worker logs for job processing errors
- Verify backend deployment is latest commit
- Test with different video file
- Review backend logs for detailed errors
3. **Additional Testing:**
- Test with larger video (147MB)
- Test concurrent uploads
- Test rate limiting (when implemented)
- Test error scenarios (invalid files, etc.)
---
## Manual Alternative (Without Script)
If the Node.js test doesn't work, test the API directly:
```bash
# 1. Get presigned URL
curl -X POST "https://api.clipsense.app/api/v1/upload/presign" \
-H "Authorization: Bearer $CLIPSENSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filename": "test-video.mp4",
"content_type": "video/mp4",
"file_size": 3980000
}'
# Save the upload_url and video_key from response
# 2. Upload video
curl -X PUT "UPLOAD_URL_FROM_STEP_1" \
-H "Content-Type: video/mp4" \
--data-binary "@/Users/jerlitaburanday/clipsense/test-video.mp4"
# 3. Start analysis
curl -X POST "https://api.clipsense.app/api/v1/analyze/start" \
-H "Authorization: Bearer $CLIPSENSE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"video_key": "VIDEO_KEY_FROM_STEP_1",
"filename": "test-video.mp4",
"question": "What is shown in this video?"
}'
# Save the job ID from response
# 4. Poll for status (repeat every 5 seconds)
curl -X GET "https://api.clipsense.app/api/v1/analyze/jobs/JOB_ID/status" \
-H "Authorization: Bearer $CLIPSENSE_API_KEY"
# 5. Get results when status = "completed"
curl -X GET "https://api.clipsense.app/api/v1/analyze/jobs/JOB_ID" \
-H "Authorization: Bearer $CLIPSENSE_API_KEY"
```
---
**Created:** December 5, 2025
**Test Script:** test-with-video.js
**Video:** test-video.mp4 (3.8MB)
**API:** https://api.clipsense.app