Skip to main content

Pencil2D Model Context Protocol (MCP) Server

License: MIT Python 3.8+ PyPI Website Maintainer

An open-source Model Context Protocol (MCP) server and automation toolkit that empowers AI agents (Claude Desktop, Google Antigravity, Cursor, Cline, etc.) to programmatically create, inspect, edit, and render traditional 2D hand-drawn animations using Pencil2D.


✨ Features

  • ⚡ Zero Heavyweight Runtime Dependencies: Pure Python implementation with standard library + Pillow.
  • 🎬 Headless & Pure-Python Dual Rendering: Leverages Pencil2D AppImage CLI or built-in pure-Python Pillow fallback to render animations to MP4 (H.264), animated GIF, or PNG image sequences—even in headless environments without an X server.
  • 🎨 Complete Project (.pclx) Support: Read, construct, and modify native .pclx archives, layer structures (Bitmap, Vector, Sound, Camera, Palette), frame timings, and camera transformations.
  • ⚡ Batch Frame Operations: Import whole animations from directories or structured lists in a single operation.
  • 🔊 Sound & Audio Integration: Embed voiceovers and sound effects (WAV/MP3) directly into sound layers.
  • 🎥 Dynamic Camera Controls: Keyframe camera pan (dx, dy), zoom (scale), and rotation angles.
  • 🖼️ Spritesheet Generator: Pack animated frames into game-ready spritesheet PNGs with coordinate metadata.
  • 🩺 Project Health & Validation: Sanity check .pclx projects for broken links, missing frame gaps, and XML errors.
  • 🖥️ Dual Execution Modes: Automated background pipelines or live visual GUI launching (pencil2d_launch_gui).
  • 🔌 Standard MCP Compatibility: Speaks JSON-RPC 2.0 over standard I/O (stdio transport).

🛠️ Complete MCP Toolset (14 Tools)

Every tool is exposed as a first-class AI tool over MCP:

Tool Name Parameters Description
pencil2d_inspect project_path Inspect a .pclx project file to inspect canvas resolution, framerate (FPS), total keyframes, layer breakdown, and color palette.
pencil2d_create project_path, width, height, fps, layer_names Create a fresh, valid .pclx project ready for drawing keyframes.
pencil2d_add_frame project_path, frame, image_path / base64_data, layer_name, top_left_x, top_left_y Insert or replace an animation frame in a bitmap layer using an image file or base64 data.
pencil2d_add_frames_batch project_path, frames (list), directory_path (str), layer_name, start_frame, step, auto_create_layers Batch import multiple animation frames from a folder or list in a single call with auto-layer creation.
pencil2d_add_layer project_path, name, layer_type (bitmap, vector, sound, camera), visible Add a new layer to the project timeline.
pencil2d_remove_layer project_path, layer_name_or_id Delete a layer and its keyframes from the project.
pencil2d_add_audio project_path, audio_path, frame, layer_name Embed an audio track/clip (WAV/MP3) into a sound layer at a specific keyframe.
pencil2d_set_camera project_path, frame, dx, dy, scale, rotation Keyframe camera pan, zoom, and rotation angle at any frame.
pencil2d_manage_palette project_path, color_name, red, green, blue, alpha Add or update a color swatch in the project palette.
pencil2d_create_spritesheet project_path, output_image, layer_name, columns Pack animated frames into a sprite sheet with coordinate grid metadata.
pencil2d_validate project_path Deep project integrity test checking XML syntax, asset references, and frame continuity.
pencil2d_extract_frames project_path, output_dir Unpack all PNG frames from a .pclx file into a directory for AI inspection or external editing.
pencil2d_export project_path, output_path, width, height, fps, start_frame, end_frame, transparency, camera, timeout, force_pure_python Headlessly render an animation project to video (MP4), animated GIF, or PNG sequence (via AppImage CLI or pure-Python fallback).
pencil2d_launch_gui project_path Open the project in the visual Pencil2D GUI for interactive editing.

🚀 Installation

Option 1: From PyPI

pip install pencil2d-mcp

Option 2: From Source

git clone https://github.com/chriz-3656/pencil2d-mcp.git
cd pencil2d-mcp
pip install -e .

Pencil2D Executable Prerequisite

Download the official Pencil2D Linux AppImage (v0.7.2 or newer) and make it executable:

chmod +x ~/Downloads/pencil2d-linux-amd64-v0.7.2.AppImage

⚙️ Client Configuration

1. Google Antigravity (~/.gemini/config/mcp_config.json)

{
  "mcpServers": {
    "pencil2d": {
      "command": "python3",
      "args": ["-m", "pencil2d_mcp", "serve"],
      "env": {
        "PYTHONPATH": "/home/demo/pencil2d-mcp/src",
        "PENCIL2D_APPIMAGE": "/home/demo/Downloads/pencil2d-linux-amd64-v0.7.2.AppImage",
        "DISPLAY": ":0.0"
      }
    }
  }
}

2. Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "pencil2d": {
      "command": "python3",
      "args": ["-m", "pencil2d_mcp", "serve"],
      "env": {
        "PENCIL2D_APPIMAGE": "/path/to/pencil2d-linux-amd64-v0.7.2.AppImage"
      }
    }
  }
}

3. Cursor / Cline / Roo-Code

{
  "mcpServers": {
    "pencil2d": {
      "command": "pencil2d-mcp",
      "args": ["serve"]
    }
  }
}

💻 CLI Usage

# Verify system setup, AppImage detection, and display
pencil2d-mcp check

# Inspect a .pclx project
pencil2d-mcp inspect animation.pclx

# Headlessly export animation to MP4 or GIF (supports AppImage CLI or pure-Python fallback)
pencil2d-mcp export animation.pclx -o output.mp4 --fps 24
pencil2d-mcp export animation.pclx -o preview.gif --width 800 --height 600 --pure-python

# Open project in GUI
pencil2d-mcp gui animation.pclx

# Start the MCP stdio server manually
pencil2d-mcp serve

🧪 Testing

python -m unittest discover tests

📜 License

Distributed under the MIT License. See LICENSE for details.

Maintained with ❤️ by chriz-3656.

Metadata

Release files for pencil2d-mcp 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pencil2d-mcp 0.3.0
File Size Uploaded Provenance Actions
pencil2d_mcp-0.3.0.tar.gz 25.0 kB Without provenance Details for pencil2d_mcp-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pencil2d-mcp 0.3.0
File Interpreter ABI Platform Actions
pencil2d_mcp-0.3.0-py3-none-any.whl Python 3 none any Details for pencil2d_mcp-0.3.0-py3-none-any.whl

Total release size: 46.4 kB

Release files / pencil2d_mcp-0.3.0.tar.gz

Download URL pencil2d_mcp-0.3.0.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
09972a7e21849b17d245514b9f713032b13d5f90ecab613760277869e95e19aa
BLAKE2b-256 checksum
How to use checksums
de376a488d83e62b8bfe29bfd8a9f38e7df7b18681f3243dcf82a5b21a7cb27b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pencil2d_mcp-0.3.0-py3-none-any.whl

Download URL pencil2d_mcp-0.3.0-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc0c950402fa10183147964955d40764cee5280638289e62f12c2c133cbada4f
BLAKE2b-256 checksum
How to use checksums
d3c7ac31fe28ec941561d40225bca763efee7d5c7601283f117b4bef01b409f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pencil2d-mcp 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page