manga-trans
Manga Trans Studio & MCP Server
一个本地优先的扫译(scanlation)后端,同时也是一个面向 Manga、Manhwa 和 Manhua 的 模型上下文协议(Model Context Protocol,MCP) 服务器。
本项目将本地化职责分摊给 AI 代理与本地引擎:
MCP 主机(Antigravity、Cursor、Claude Desktop、Codex):承担视觉与翻译引擎工作,直接通过
ImageContent检查原始页面,并返回以不可变的region_id标签为键的翻译结果。本地 Python 后端:负责气泡几何检测、本地 OCR(Manga-OCR / EasyOCR)、轮廓感知的文本擦除(inpainting)、完整支持越南语变音符号自动换行的排版布局,以及严格的像素级 QA 校验。
Studio 画布(FastAPI Web 应用):提供并排的双画布界面,支持实时视觉检查、手动文本调整、自定义对话气泡裁切和 PNG 导出。
核心功能
1. 主机原生视觉与本地化
标准 MCP 集成:以原生
ImageContent形式传输原始漫画页面,让主机模型直接读取视觉构图、角色情绪和阅读顺序。完全本地执行:服务端无需任何第三方 LLM API 密钥(OpenAI、Gemini、OpenRouter)。
2. 轮廓感知的图像修复(气泡清洁器)
使用连通域分析和主成分分析(PCA)来区分文字字形、线稿与画格轮廓。
在修复前锁定画格边框和思考气泡边界,防止白色渗漏或背景画面被破坏。
3. 自动化漫画排版器
动态字码计算,适配椭圆、矩形和尖角气泡。
智能自动换行,完整支持越南语变音符号和声调,不会产生断词瑕疵或缺字(豆腐块 / tofu)。
内置本地化漫画字体:
Itim、Pangolin、Patrick Hand、Mali Bold、Bangers、Saira Condensed、Be Vietnam Pro、Chakra Petch、Comic Neue等。文本描边、颜色填充、对齐(居中/左/右)以及粗体/斜体样式。
4. 严格的像素级 QA
渲染后的自动化验证:
box_alignment_score:渲染文本与目标气泡之间的几何贴合度(目标:100)。render_overflow_pixels与per_region_typeset_overflow_pixels:确保超出允许边界之外没有任何文本裁切(目标:0)。artwork_changes_outside_source_regions:强制要求对话区域之外的像素变化为 0%。
5. 双画布 Web 工作室
原始页面与翻译输出的并排对比。
与正在进行的 MCP 批量任务实时双向同步。
交互式气泡创建:直接在画布上绘制自定义边界框,触发局部 OCR。
工作区会话持久化保存在
.manga_trans_cache/studio-workspace.json中。
Related MCP server: Manga-Translation-MCP
安装
前置条件
Python 3.10+
操作系统:Windows / Linux / macOS
*(可选)*支持 CUDA 的 NVIDIA GPU,用于加速本地 OCR。
安装依赖
pip install -r requirements.txtGPU 加速(可选)
要启用 GPU 加速的本地 OCR,请安装带 CUDA 的 PyTorch:
# Example for CUDA 12.8:
pip install --upgrade --force-reinstall torch torchvision --index-url https://download.pytorch.org/whl/cu128环境变量:
MANGA_TRANS_DEVICE=auto(默认值:优先使用 CUDA,不可用时回退到 CPU)MANGA_TRANS_DEVICE=cpu(强制使用 CPU 执行)MANGA_OCR_BATCH_SIZE=8(本地 OCR 推理的批量大小)
快速开始
1. 启动 Web Studio
运行 start_app.bat(Windows)或执行:
python -m uvicorn backend.server:app --host 127.0.0.1 --port 8000 --reload然后在浏览器中打开 http://127.0.0.1:8000。
2. 配置 MCP 客户端
将服务器定义添加到你的 MCP 客户端配置中(claude_desktop_config.json、Antigravity、Cursor 等):
{
"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 工具参考
Tool | 描述 |
| 列出章节目录中的所有图片页。 |
| 裁剪黑色边框、检测对话气泡,并对单个页面运行本地 OCR。 |
| 处理整个章节并生成结构化 OCR 清单。 |
| 返回原始页面作为 |
| 擦除原始文本、排版本地化翻译,并对单个页面运行 QA。 |
| 使用预先构建的翻译 JSON 清单渲染整个章节。 |
| 擦除源文本并输出修复后的图像,不进行排版。 |
| 从 Web Studio 获取当前工作区状态和审核队列。 |
| 将用户的 Web Studio 视图同步并导航到指定页码。 |
| 列出排版引擎中注册的可用字体。 |
目录结构
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测试
运行测试套件以验证系统完整性:
python -m unittest tests/test_studio_workspace.py
python -m unittest tests/test_mcp_server.pyTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Screenshot, diff, audit and sitemap-capture any web page — 5 MCP tools for AI agents.
Agent-first task marketplace MCP — discover, claim, and deliver paid workspace tasks.
Web scraping, browser automation, screenshots and AI data extraction for AI agents via MCP.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables generating original English-dialogue manga with configurable Japanese art styles through an MCP server, including story scripting, panel image generation, and page composition.-
- FlicenseNot gradedqualityBmaintenanceAutomates manga translation by detecting text regions with YOLO, performing OCR, invoking a multimodal LLM with full-page context for translation, and rendering translated text back onto the original images.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to search, browse, inspect, download, convert, and manage manga albums, chapters, comments, favorites, account sessions, runtime configuration, and asynchronous download tasks through standardized MCP tools and resources.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to search, browse, and download comics via natural language, manage favorites, read comments and rankings, and convert downloaded content into ZIP, PDF, or long images. It also exposes download planning, background task progress, cancellation, retry, login/session handling, and runtime configuration as MCP tools and resources.-