Skip to main content

MCP server group wrapping FFmpeg/OTIO. Provides primitives to manipulate video editing workflows from AI agents.

Project description

Clipwright

For Japanese, see README.ja.md.

MCP server group wrapping FFmpeg/OTIO. Provides primitives to manipulate video editing workflows from AI agents.

Prerequisite: FFmpeg

Clipwright requires ffprobe (runtime) and ffmpeg (test fixture generation) on PATH. Binaries are not included.

Installation (Windows / WinGet)

winget install Gyan.FFmpeg

PATH takes effect after shell restart. When using with Claude Code, restart the app for PATH to become active.

If you cannot wait for a restart, specify environment variables directly:

# runtime: ffprobe only
export CLIPWRIGHT_FFPROBE="C:/Users/<user>/AppData/Local/Microsoft/WinGet/Packages/Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe/ffmpeg-8.1.1-full_build/bin/ffprobe.exe"

# test: both ffmpeg + ffprobe (for test fixture generation)
export CLIPWRIGHT_FFMPEG="C:/Users/<user>/AppData/Local/Microsoft/WinGet/Packages/Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe/ffmpeg-8.1.1-full_build/bin/ffmpeg.exe"

Environment Variable Usage

Variable Purpose
CLIPWRIGHT_FFPROBE Runtime only. Used by the clipwright_inspect_media tool
CLIPWRIGHT_FFMPEG Test only. Used by the sample_media fixture in conftest.py

Runtime depends only on ffprobe. ffmpeg is used only for test fixture generation (design: [DC-AM-008]).


Development Environment Setup

# Install dependencies
uv sync --dev

# Run tests (with coverage)
uv run pytest --cov=clipwright --cov-report=term-missing

# lint / format
uv run ruff check src tests
uv run ruff format src tests

# Type checking
uv run mypy src

Integration Test Prerequisites

To run integration tests (tests that actually invoke ffprobe/ffmpeg), ffmpeg / ffprobe must exist on PATH or the following environment variables must be set:

# Specify path to ffprobe (used by runtime and integration tests)
export CLIPWRIGHT_FFPROBE="/path/to/ffprobe"

# Specify path to ffmpeg (used for test fixture generation)
export CLIPWRIGHT_FFMPEG="/path/to/ffmpeg"

If ffmpeg / ffprobe are already registered in PATH, setting environment variables is not required. If neither is found, integration tests are automatically skipped.


Development Notes: MCP Package

Adopted Package

Official MCP Python SDK (mcp[cli]) is adopted (ADR-5 confirmed).

mcp[cli]>=1.27.2

Importable via from mcp.server.fastmcp import FastMCP. Verified to work on Python 3.11 / Windows.

Annotation Syntax (Adopted Version)

from mcp.server.fastmcp import FastMCP
from mcp.types import ToolAnnotations

mcp = FastMCP("clipwright")

@mcp.tool(
    annotations=ToolAnnotations(
        readOnlyHint=True,
        destructiveHint=False,
        idempotentHint=True,
        openWorldHint=False,
    )
)
def clipwright_inspect_media(path: str) -> dict:
    """Probe a media file and return its information."""
    ...

ToolAnnotations fields: title, readOnlyHint, destructiveHint, idempotentHint, openWorldHint

outputSchema / structured_output

When mcp.tool(structured_output=True) is specified, Pydantic model return values are reflected in outputSchema as JSON Schema.

from pydantic import BaseModel

class MediaResult(BaseModel):
    ok: bool
    summary: str

@mcp.tool(structured_output=True)
def clipwright_inspect_media(path: str) -> MediaResult:
    ...

MCP Inspector Communication Procedure

How to manually verify the server using MCP Inspector (@modelcontextprotocol/inspector).

Setup (Node.js Required)

# Verify Node.js is installed
node --version
npx --version

Starting the Server and Connecting

# Start MCP Inspector and connect the server via stdio
npx @modelcontextprotocol/inspector uv run python -m clipwright.server

Browser opens automatically at http://localhost:5173 (or access manually).

The tool list (clipwright_init_project / clipwright_inspect_media / clipwright_read_timeline / clipwright_write_timeline) appears in Inspector, and you can manually execute each tool.

Expected Behavior

  • 4 tools appear in the tool list
  • Passing a non-existent path to clipwright_inspect_media returns an error envelope with ok=false
  • If ffprobe is not set in PATH / environment variables, a DEPENDENCY_MISSING error is returned

Architecture Overview

src/clipwright/
  __init__.py       # Version definition
  schemas.py        # Shared Pydantic types (contract surface)
  envelope.py       # Return value envelope + error formatting
  errors.py         # Error codes + ClipwrightError exception
  process.py        # Subprocess runner (shell=False / timeout required)
  media.py          # ffprobe wrapper
  otio_utils.py     # OTIO helpers
  operations.py     # Declarative edit operation types + application logic
  project.py        # Project directory management
  server.py         # FastMCP server (4 tools exposed)

Dependency direction: schemas / envelope / errors (contract surface) → process / media / otio_utils / projectoperationsserver

For details, see docs/clipwright-spec.md.


License

MIT — See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clipwright-0.1.1.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clipwright-0.1.1-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file clipwright-0.1.1.tar.gz.

File metadata

  • Download URL: clipwright-0.1.1.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clipwright-0.1.1.tar.gz
Algorithm Hash digest
SHA256 861c76f906d87e30fa7482b003b3af91849a6029acbfe9cda262dba278a31c52
MD5 319ba8b5a68708ab5386da70b3ac8138
BLAKE2b-256 c47d8ec2f584c782730403e73a557cb85c0d0517558e7337a6582c130ea5b4aa

See more details on using hashes here.

File details

Details for the file clipwright-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: clipwright-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for clipwright-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5094a1398d632b8c3c311fae4be1d19622ff46f569ffe14eaeb5cbc752c47d21
MD5 3c6530fd213d17069b521d5399c8184a
BLAKE2b-256 bf57beed9157c45e1b0def665574998c25240a419f08b01e047ce43fdbc720f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page