Fix import errors and type annotations
- Replace all Dict/List type hints with dict/list for Python 3.12+ compatibility - Add __main__.py to make package executable as module - Remove unused imports (cv2, numpy, ffmpeg) that were causing warnings - Fix bare except clause to use Exception - Server now starts successfully without import errors
This commit is contained in:
parent
9ccdc7782e
commit
d7b56da7c7
6
mcp_video_editor/__main__.py
Normal file
6
mcp_video_editor/__main__.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
"""Main entry point for mcp_video_editor package."""
|
||||||
|
|
||||||
|
from .server import main
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, Union
|
|
||||||
|
|
||||||
from fastmcp import FastMCP
|
from fastmcp import FastMCP
|
||||||
|
|
||||||
@ -71,12 +70,12 @@ recording_sessions: dict[str, VideoRecordingSession] = {}
|
|||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
def mcp_video_editor_status() -> dict[str, Union[str, bool, int]]:
|
def mcp_video_editor_status() -> dict[str, str | bool | int]:
|
||||||
"""
|
"""
|
||||||
Get the status of the MCP Video Editor server and available capabilities.
|
Get the status of the MCP Video Editor server and available capabilities.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with server status and available features
|
dict with server status and available features
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"server_name": "MCP Video Editor",
|
"server_name": "MCP Video Editor",
|
||||||
@ -94,8 +93,8 @@ def mcp_video_recorder_start(
|
|||||||
filename: str,
|
filename: str,
|
||||||
resolution: str = "1920x1080",
|
resolution: str = "1920x1080",
|
||||||
framerate: int = 30,
|
framerate: int = 30,
|
||||||
region: Optional[str] = None,
|
region: str | None = None,
|
||||||
) -> Dict[str, Union[str, int]]:
|
) -> dict[str, str | int]:
|
||||||
"""
|
"""
|
||||||
Start reliable video capture with persistent recording sessions.
|
Start reliable video capture with persistent recording sessions.
|
||||||
|
|
||||||
@ -106,7 +105,7 @@ def mcp_video_recorder_start(
|
|||||||
region: Optional screen region coordinates as "x,y,width,height"
|
region: Optional screen region coordinates as "x,y,width,height"
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with session_id for tracking and recording details
|
dict with session_id for tracking and recording details
|
||||||
"""
|
"""
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -129,7 +128,7 @@ def mcp_video_recorder_start(
|
|||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
def mcp_video_recorder_stop(session_id: str) -> Dict[str, Union[str, int, float]]:
|
def mcp_video_recorder_stop(session_id: str) -> dict[str, str | int | float]:
|
||||||
"""
|
"""
|
||||||
Stop recording and ensure file is saved.
|
Stop recording and ensure file is saved.
|
||||||
|
|
||||||
@ -137,7 +136,7 @@ def mcp_video_recorder_stop(session_id: str) -> Dict[str, Union[str, int, float]
|
|||||||
session_id: Recording session ID from start command
|
session_id: Recording session ID from start command
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with file path and recording statistics
|
dict with file path and recording statistics
|
||||||
"""
|
"""
|
||||||
if session_id not in recording_sessions:
|
if session_id not in recording_sessions:
|
||||||
return {"error": f"Session {session_id} not found"}
|
return {"error": f"Session {session_id} not found"}
|
||||||
@ -173,8 +172,8 @@ def mcp_video_recorder_stop(session_id: str) -> Dict[str, Union[str, int, float]
|
|||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
def mcp_video_concatenate(
|
def mcp_video_concatenate(
|
||||||
input_clips: List[str], output_path: str, transition_type: str = "cut"
|
input_clips: list[str], output_path: str, transition_type: str = "cut"
|
||||||
) -> Dict[str, Union[str, float]]:
|
) -> dict[str, str | float]:
|
||||||
"""
|
"""
|
||||||
Join multiple video clips into single file.
|
Join multiple video clips into single file.
|
||||||
|
|
||||||
@ -184,7 +183,7 @@ def mcp_video_concatenate(
|
|||||||
transition_type: Type of transition ("cut", "fade", "dissolve")
|
transition_type: Type of transition ("cut", "fade", "dissolve")
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with output path and total duration
|
dict with output path and total duration
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
clips = []
|
clips = []
|
||||||
@ -230,7 +229,7 @@ def mcp_video_concatenate(
|
|||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
def mcp_video_trim(
|
def mcp_video_trim(
|
||||||
input_path: str, start_time: float, end_time: float, output_path: str
|
input_path: str, start_time: float, end_time: float, output_path: str
|
||||||
) -> Dict[str, Union[str, float]]:
|
) -> dict[str, str | float]:
|
||||||
"""
|
"""
|
||||||
Cut video segments to specific timeframes.
|
Cut video segments to specific timeframes.
|
||||||
|
|
||||||
@ -241,7 +240,7 @@ def mcp_video_trim(
|
|||||||
output_path: Output video file path
|
output_path: Output video file path
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with output path and trimmed duration
|
dict with output path and trimmed duration
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(input_path):
|
if not os.path.exists(input_path):
|
||||||
@ -279,9 +278,9 @@ def mcp_video_speed_control(
|
|||||||
input_path: str,
|
input_path: str,
|
||||||
speed_multiplier: float,
|
speed_multiplier: float,
|
||||||
output_path: str,
|
output_path: str,
|
||||||
start_time: Optional[float] = None,
|
start_time: float | None = None,
|
||||||
end_time: Optional[float] = None,
|
end_time: float | None = None,
|
||||||
) -> Dict[str, Union[str, float]]:
|
) -> dict[str, str | float]:
|
||||||
"""
|
"""
|
||||||
Adjust playback speed for specific segments.
|
Adjust playback speed for specific segments.
|
||||||
|
|
||||||
@ -293,7 +292,7 @@ def mcp_video_speed_control(
|
|||||||
end_time: Optional end time for speed change
|
end_time: Optional end time for speed change
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with output path and new duration
|
dict with output path and new duration
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(input_path):
|
if not os.path.exists(input_path):
|
||||||
@ -339,12 +338,12 @@ def mcp_video_add_overlay(
|
|||||||
input_path: str,
|
input_path: str,
|
||||||
output_path: str,
|
output_path: str,
|
||||||
overlay_type: str,
|
overlay_type: str,
|
||||||
text: Optional[str] = None,
|
text: str | None = None,
|
||||||
position: str = "center",
|
position: str = "center",
|
||||||
duration: Optional[float] = None,
|
duration: float | None = None,
|
||||||
start_time: float = 0,
|
start_time: float = 0,
|
||||||
style: Optional[Dict] = None,
|
style: dict | None = None,
|
||||||
) -> Dict[str, str]:
|
) -> dict[str, str]:
|
||||||
"""
|
"""
|
||||||
Add graphics, text, shapes over video content.
|
Add graphics, text, shapes over video content.
|
||||||
|
|
||||||
@ -359,7 +358,7 @@ def mcp_video_add_overlay(
|
|||||||
style: Style properties (font, color, size, etc.)
|
style: Style properties (font, color, size, etc.)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with output path and overlay details
|
dict with output path and overlay details
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(input_path):
|
if not os.path.exists(input_path):
|
||||||
@ -416,7 +415,7 @@ def mcp_video_format_convert(
|
|||||||
output_format: str = "mp4",
|
output_format: str = "mp4",
|
||||||
quality_preset: str = "balanced",
|
quality_preset: str = "balanced",
|
||||||
compression_level: str = "medium",
|
compression_level: str = "medium",
|
||||||
) -> Dict[str, Union[str, int, float]]:
|
) -> dict[str, str | int | float]:
|
||||||
"""
|
"""
|
||||||
Export to different video formats and qualities.
|
Export to different video formats and qualities.
|
||||||
|
|
||||||
@ -428,7 +427,7 @@ def mcp_video_format_convert(
|
|||||||
compression_level: Compression level ("low", "medium", "high")
|
compression_level: Compression level ("low", "medium", "high")
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with conversion results and file info
|
dict with conversion results and file info
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(input_path):
|
if not os.path.exists(input_path):
|
||||||
@ -482,22 +481,22 @@ def mcp_video_format_convert(
|
|||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
def mcp_audio_mix_tracks(
|
def mcp_audio_mix_tracks(
|
||||||
audio_files: List[str],
|
audio_files: list[str],
|
||||||
output_path: str,
|
output_path: str,
|
||||||
volume_levels: Optional[List[float]] = None,
|
volume_levels: list[float] | None = None,
|
||||||
sync_timing: Optional[List[float]] = None,
|
sync_timing: list[float] | None = None,
|
||||||
) -> Dict[str, Union[str, float, int]]:
|
) -> dict[str, str | float | int]:
|
||||||
"""
|
"""
|
||||||
Combine multiple audio tracks with volume control and timing.
|
Combine multiple audio tracks with volume control and timing.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
audio_files: List of audio file paths to mix
|
audio_files: list of audio file paths to mix
|
||||||
output_path: Output audio file path
|
output_path: Output audio file path
|
||||||
volume_levels: Volume multipliers for each track (1.0 = original volume)
|
volume_levels: Volume multipliers for each track (1.0 = original volume)
|
||||||
sync_timing: Start times for each track in seconds
|
sync_timing: Start times for each track in seconds
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with output path and mixing details
|
dict with output path and mixing details
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not audio_files:
|
if not audio_files:
|
||||||
@ -556,7 +555,7 @@ def mcp_audio_sync_video(
|
|||||||
output_path: str,
|
output_path: str,
|
||||||
audio_start_time: float = 0.0,
|
audio_start_time: float = 0.0,
|
||||||
replace_audio: bool = True,
|
replace_audio: bool = True,
|
||||||
) -> Dict[str, Union[str, float]]:
|
) -> dict[str, str | float]:
|
||||||
"""
|
"""
|
||||||
Synchronize audio track with video timeline.
|
Synchronize audio track with video timeline.
|
||||||
|
|
||||||
@ -568,7 +567,7 @@ def mcp_audio_sync_video(
|
|||||||
replace_audio: Whether to replace existing audio or mix with it
|
replace_audio: Whether to replace existing audio or mix with it
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with output path and sync details
|
dict with output path and sync details
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(video_path):
|
if not os.path.exists(video_path):
|
||||||
@ -616,12 +615,12 @@ def mcp_audio_sync_video(
|
|||||||
def mcp_video_add_branding(
|
def mcp_video_add_branding(
|
||||||
input_path: str,
|
input_path: str,
|
||||||
output_path: str,
|
output_path: str,
|
||||||
logo_path: Optional[str] = None,
|
logo_path: str | None = None,
|
||||||
brand_colors: Optional[Dict] = None,
|
brand_colors: dict | None = None,
|
||||||
position: str = "bottom-right",
|
position: str = "bottom-right",
|
||||||
opacity: float = 0.8,
|
opacity: float = 0.8,
|
||||||
size_scale: float = 0.1,
|
size_scale: float = 0.1,
|
||||||
) -> Dict[str, Union[str, Dict]]:
|
) -> dict[str, str | dict]:
|
||||||
"""
|
"""
|
||||||
Apply consistent branding elements (logos, colors) to video.
|
Apply consistent branding elements (logos, colors) to video.
|
||||||
|
|
||||||
@ -635,7 +634,7 @@ def mcp_video_add_branding(
|
|||||||
size_scale: Logo size relative to video dimensions
|
size_scale: Logo size relative to video dimensions
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with output path and branding details
|
dict with output path and branding details
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(input_path):
|
if not os.path.exists(input_path):
|
||||||
@ -701,20 +700,20 @@ def mcp_video_add_branding(
|
|||||||
def mcp_video_resolution_optimizer(
|
def mcp_video_resolution_optimizer(
|
||||||
input_path: str,
|
input_path: str,
|
||||||
output_directory: str,
|
output_directory: str,
|
||||||
target_resolutions: List[str] = None,
|
target_resolutions: list[str] = None,
|
||||||
quality_settings: Optional[Dict] = None,
|
quality_settings: dict | None = None,
|
||||||
) -> Dict[str, Union[str, List, Dict]]:
|
) -> dict[str, str | list | dict]:
|
||||||
"""
|
"""
|
||||||
Generate multiple resolutions from source video.
|
Generate multiple resolutions from source video.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
input_path: Input video file path
|
input_path: Input video file path
|
||||||
output_directory: Directory to save optimized versions
|
output_directory: Directory to save optimized versions
|
||||||
target_resolutions: List of target resolutions (e.g., ["1080p", "720p", "480p"])
|
target_resolutions: list of target resolutions (e.g., ["1080p", "720p", "480p"])
|
||||||
quality_settings: Quality settings for each resolution
|
quality_settings: Quality settings for each resolution
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict with generated file paths and optimization details
|
dict with generated file paths and optimization details
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(input_path):
|
if not os.path.exists(input_path):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user