manga-trans
Enables AI agents to perform local-first manga/comic scanlation by inspecting raw pages, translating text, cleaning speech bubbles, and typesetting localized content through MCP tools.
README
Manga Trans Studio & MCP Server
A local-first scanlation backend and Model Context Protocol (MCP) server for Manga, Manhwa, and Manhua.
This project splits localization responsibilities between the AI agent and the local engine:
- MCP Host (Antigravity, Cursor, Claude Desktop, Codex): Operates as the vision and translation engine, directly inspecting raw pages via
ImageContentand returning translations keyed to immutableregion_idtags. - Local Python Backend: Handles bubble geometry detection, local OCR (Manga-OCR / EasyOCR), contour-aware text erasure (inpainting), typography layout with full Vietnamese diacritics word wrapping, and strict pixel QA validation.
- Studio Canvas (FastAPI Web App): Provides a side-by-side dual-canvas interface for real-time visual inspection, manual text adjustments, custom speech-bubble cropping, and PNG export.
Key Capabilities
1. Host-Native Vision & Localization
- Standard MCP integration: Transmits raw manga pages as native
ImageContentso the host model reads visual panels, character emotions, and reading order directly. - Fully local execution: No third-party LLM API keys (OpenAI, Gemini, OpenRouter) required on the server side.
2. Contour-Aware Inpainting (Bubble Cleaner)
- Uses Connected-Component Analysis and Principal Component Analysis (PCA) to distinguish speech glyphs from line art and panel contours.
- Locks panel borders and thought-bubble perimeters prior to inpainting, preventing white bleed or destruction of background artwork.
3. Automated Manga Typesetter
- Dynamic font sizing calculated to fit elliptical, rectangular, and spike balloons.
- Smart word wrapping supporting Vietnamese diacritics and tones without word-breaking artifacts or missing glyphs (tofu).
- Built-in localized comic fonts:
Itim,Pangolin,Patrick Hand,Mali Bold,Bangers,Saira Condensed,Be Vietnam Pro,Chakra Petch,Comic Neue, and more. - Text stroke, color fill, alignment (center/left/right), and bold/italic styles.
4. Strict Pixel QA
Automated post-render verification:
box_alignment_score: Geometric fit between rendered text and target balloon (Target: 100).render_overflow_pixels&per_region_typeset_overflow_pixels: Ensures zero text clipping outside allowable bounds (Target: 0).artwork_changes_outside_source_regions: Enforces 0% pixel alterations outside speech regions.
5. Dual-Canvas Web Studio
- Side-by-side comparison of original raw pages and translated outputs.
- Live two-way synchronization with ongoing MCP batches.
- Interactive bubble creation: Draw custom bounding boxes directly on the canvas to trigger localized OCR.
- Persistent workspace sessions saved in
.manga_trans_cache/studio-workspace.json.
Installation
Prerequisites
- Python 3.10+
- OS: Windows / Linux / macOS
- (Optional) NVIDIA GPU with CUDA support for accelerated local OCR.
Install Dependencies
pip install -r requirements.txt
GPU Acceleration (Optional)
To enable GPU-accelerated local OCR, install PyTorch with CUDA:
# Example for CUDA 12.8:
pip install --upgrade --force-reinstall torch torchvision --index-url https://download.pytorch.org/whl/cu128
Environment variables:
MANGA_TRANS_DEVICE=auto(Default: Uses CUDA if available, falls back to CPU)MANGA_TRANS_DEVICE=cpu(Forces CPU execution)MANGA_OCR_BATCH_SIZE=8(Batch size for local OCR inference)
Quickstart
1. Launch Web Studio
Run start_app.bat (Windows) or execute:
python -m uvicorn backend.server:app --host 127.0.0.1 --port 8000 --reload
Open your browser at http://127.0.0.1:8000.
2. Configure MCP Client
Add the server definition to your MCP client configuration (claude_desktop_config.json, Antigravity, Cursor, etc.):
{
"mcpServers": {
"manga-trans": {
"command": "python",
"args": [
"D:\\Code\\manga-trans\\backend\\mcp_server.py"
],
"cwd": "D:\\Code\\manga-trans",
"env": {
"PYTHONIOENCODING": "utf-8",
"PYTHONUNBUFFERED": "1",
"PYTHONUTF8": "1",
"HF_HOME": "D:\\Code\\manga-trans\\.models\\huggingface",
"MANGA_TRANS_DEVICE": "auto",
"MANGA_OCR_BATCH_SIZE": "8"
}
}
}
}
MCP Tools Reference
| Tool | Description |
|---|---|
manga_list_pages |
Lists all image pages inside a raw chapter folder. |
manga_analyze_page |
Crops black borders, detects speech balloons, and runs local OCR for a single page. |
manga_analyze_chapter |
Processes and generates structured OCR manifests for an entire chapter batch. |
manga_load_page |
Returns the raw page as ImageContent for host vision inspection. |
manga_render_page |
Erases original text, typesets localized translations, and runs QA for a single page. |
manga_render_chapter |
Renders an entire chapter using a pre-built translations JSON manifest. |
manga_clean_page |
Erases source text and outputs inpainted images without typesetting. |
manga_studio_status |
Retrieves current workspace status and review queue from Web Studio. |
manga_studio_show_page |
Syncs and navigates the user's Web Studio view to a specific page number. |
manga_list_fonts |
Lists available fonts registered in the typesetting engine. |
Directory Structure
manga-trans/
├── backend/
│ ├── engine/
│ │ ├── detector.py # Offline bubble geometry & bounding box heuristics
│ │ ├── geometry.py # Contour analysis, panel line rules, coordinate calculations
│ │ ├── inpainter.py # Line-preserving text erasure & inpainting
│ │ ├── models.py # Pydantic schemas for manifests & QA reports
│ │ ├── ocr.py # Manga-OCR & EasyOCR wrappers
│ │ ├── pipeline.py # End-to-end clean, OCR, and render pipeline
│ │ ├── preprocess.py # Image normalization & black border cropping
│ │ ├── qa.py # Strict Pixel QA algorithms
│ │ └── typesetter.py # Typography layout, font sizing, word wrapping
│ ├── fonts/ # Localized TrueType (.ttf) comic fonts
│ ├── mcp_server.py # MCP Server entrypoint (JSON-RPC over stdio)
│ ├── server.py # FastAPI REST & WebSocket backend for Web Studio
│ └── studio_workspace.py # Persistent workspace session manager
├── frontend/
│ ├── index.html # Web Studio Canvas App (HTML5/Canvas/CSS/JS)
│ └── sample/ # Sample test assets
├── tests/
│ ├── render_mcp_qa.py # Pipeline render & QA regression test
│ ├── test_mcp_server.py # MCP Server test suite (38 unit tests)
│ └── test_studio_workspace.py # Web Studio workspace unit tests
├── .agent/
│ └── skills/
│ └── manga-translate/ # Manga translation skill for AI agents
│ └── SKILL.md
├── AGENTS.md # Universal CLI and agent operational instructions
├── GEMINI.md # Model-specific guidelines & rules
├── mcp_config.json # Sample MCP client configuration
├── requirements.txt # Python package dependencies
└── start_app.bat # Windows launcher for Web Studio
Testing
Run the test suite to verify system integrity:
python -m unittest tests/test_studio_workspace.py
python -m unittest tests/test_mcp_server.py
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。