Fix MCP server startup issues and create minimal mode
- Fix TOML syntax error in pyproject.toml configuration - Simplify dependencies to only FastMCP by default - Create optional 'video' dependency group for full features - Add minimal test server (test_minimal.py) for fast startup - Add graceful import handling for optional video libraries - Create both full and minimal startup scripts - Ensure MCP server starts quickly without heavy dependencies Server now successfully starts and connects to Claude Code!
This commit is contained in:
parent
0d926c626f
commit
9ccdc7782e
@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
from fastmcp import FastMCP
|
from fastmcp import FastMCP
|
||||||
|
|
||||||
|
# Optional imports for video processing
|
||||||
|
try:
|
||||||
from moviepy.audio.fx import volumex
|
from moviepy.audio.fx import volumex
|
||||||
from moviepy.audio.io.AudioFileClip import AudioFileClip
|
from moviepy.audio.io.AudioFileClip import AudioFileClip
|
||||||
from moviepy.editor import (
|
from moviepy.editor import (
|
||||||
@ -14,11 +17,34 @@ from moviepy.editor import (
|
|||||||
concatenate_videoclips,
|
concatenate_videoclips,
|
||||||
)
|
)
|
||||||
from moviepy.video.fx import speedx
|
from moviepy.video.fx import speedx
|
||||||
|
MOVIEPY_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
MOVIEPY_AVAILABLE = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
CV2_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
CV2_AVAILABLE = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
import ffmpeg
|
||||||
|
FFMPEG_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
FFMPEG_AVAILABLE = False
|
||||||
|
|
||||||
# Initialize FastMCP server
|
# Initialize FastMCP server
|
||||||
mcp = FastMCP("MCP Video Editor")
|
mcp = FastMCP("MCP Video Editor")
|
||||||
|
|
||||||
|
|
||||||
|
def _check_moviepy_dependency():
|
||||||
|
"""Check if MoviePy is available for video processing."""
|
||||||
|
if not MOVIEPY_AVAILABLE:
|
||||||
|
return {"error": "MoviePy is not installed. Install with: pip install moviepy"}
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class VideoRecordingSession:
|
class VideoRecordingSession:
|
||||||
"""Manages video recording sessions."""
|
"""Manages video recording sessions."""
|
||||||
|
|
||||||
@ -41,7 +67,26 @@ class VideoRecordingSession:
|
|||||||
|
|
||||||
|
|
||||||
# Global recording sessions store
|
# Global recording sessions store
|
||||||
recording_sessions: Dict[str, VideoRecordingSession] = {}
|
recording_sessions: dict[str, VideoRecordingSession] = {}
|
||||||
|
|
||||||
|
|
||||||
|
@mcp.tool()
|
||||||
|
def mcp_video_editor_status() -> dict[str, Union[str, bool, int]]:
|
||||||
|
"""
|
||||||
|
Get the status of the MCP Video Editor server and available capabilities.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dict with server status and available features
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"server_name": "MCP Video Editor",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"status": "running",
|
||||||
|
"moviepy_available": MOVIEPY_AVAILABLE,
|
||||||
|
"opencv_available": CV2_AVAILABLE,
|
||||||
|
"ffmpeg_available": FFMPEG_AVAILABLE,
|
||||||
|
"active_sessions": len(recording_sessions),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
|
@ -7,17 +7,20 @@ authors = [
|
|||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastmcp>=2.12.2",
|
"fastmcp>=2.12.2",
|
||||||
"opencv-python>=4.8.0",
|
|
||||||
"moviepy>=1.0.3",
|
|
||||||
"pillow>=10.0.0",
|
|
||||||
"numpy>=1.24.0",
|
|
||||||
"ffmpeg-python>=0.2.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = {text = "MIT"}
|
license = {text = "MIT"}
|
||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
|
video = [
|
||||||
|
"moviepy>=1.0.3",
|
||||||
|
"opencv-python>=4.8.0",
|
||||||
|
"pillow>=10.0.0",
|
||||||
|
"numpy>=1.24.0",
|
||||||
|
"ffmpeg-python>=0.2.0",
|
||||||
|
]
|
||||||
dev = [
|
dev = [
|
||||||
"ruff>=0.1.0",
|
"ruff>=0.1.0",
|
||||||
"pytest>=7.0.0",
|
"pytest>=7.0.0",
|
||||||
|
35
start-mcp-video-editor-minimal.sh
Executable file
35
start-mcp-video-editor-minimal.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# MCP Video Editor Startup Script (Minimal Version)
|
||||||
|
# This script launches the MCP Video Editor server in minimal mode for fast startup
|
||||||
|
|
||||||
|
set -e # Exit on any error
|
||||||
|
|
||||||
|
# Get the directory where this script is located
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Change to the project directory
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
echo "🎬 Starting MCP Video Editor (Minimal Mode)..."
|
||||||
|
echo "📁 Working directory: $SCRIPT_DIR"
|
||||||
|
|
||||||
|
# Check if uv is installed
|
||||||
|
if ! command -v uv &> /dev/null; then
|
||||||
|
echo "❌ Error: UV is not installed or not in PATH"
|
||||||
|
echo "Please install UV: curl -LsSf https://astral.sh/uv/install.sh | sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if dependencies are installed
|
||||||
|
if [ ! -d ".venv" ] && [ ! -f "uv.lock" ]; then
|
||||||
|
echo "📦 Installing minimal dependencies with UV..."
|
||||||
|
uv sync
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "ℹ️ Running in minimal mode - video processing features require additional dependencies"
|
||||||
|
echo "ℹ️ To install full features: uv sync --extra video"
|
||||||
|
|
||||||
|
# Launch the minimal MCP Video Editor server with UV
|
||||||
|
echo "🚀 Launching MCP Video Editor server (minimal mode)..."
|
||||||
|
exec uv run python test_minimal.py
|
34
test_minimal.py
Normal file
34
test_minimal.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Minimal MCP Video Editor test - just FastMCP without heavy dependencies."""
|
||||||
|
|
||||||
|
from fastmcp import FastMCP
|
||||||
|
|
||||||
|
# Initialize FastMCP server
|
||||||
|
mcp = FastMCP("MCP Video Editor - Minimal")
|
||||||
|
|
||||||
|
|
||||||
|
@mcp.tool()
|
||||||
|
def mcp_video_editor_status():
|
||||||
|
"""Get the status of the MCP Video Editor server."""
|
||||||
|
return {
|
||||||
|
"server_name": "MCP Video Editor",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"status": "running",
|
||||||
|
"mode": "minimal"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@mcp.tool()
|
||||||
|
def echo_test(message: str):
|
||||||
|
"""Simple echo test to verify MCP functionality."""
|
||||||
|
return {"echo": message, "status": "success"}
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Main entry point for the minimal test server."""
|
||||||
|
print("🎬 Starting MCP Video Editor (Minimal Mode)...")
|
||||||
|
mcp.run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user