subtitle-translation-mcp

subtitle-translation-mcp

An offline MCP server for translating movie subtitles, providing persistent translation sessions, a glossary, and modular format adapters so LLM agents can translate while timing is never altered.

Category
访问服务器

README

subtitle-translation-mcp

Offline MCP server for subtitle translation with a persistent translation session, a translation-memory glossary, and modular format adapters. Built for LLM agents (e.g. Cline) — the server structures and persists, the agent translates.

  • Timing is never touched. The source timing/order is stored once at parse time; translate_batch sends only { index, text }, so cues can never drift or merge.
  • Persistent session. Interrupted translation? Resume exactly where you left off (translation_status → missingRanges).
  • Glossary (translation memory). Names and fixed terms are translated consistently across movies and series.
  • Whole-film context. subtitle_overview gives the agent the full plain text first, so names/terminology stay consistent.
  • Encoding-safe. Auto-detects UTF-8 / Windows-1250 / ISO-8859-2 / Windows-1251 / ISO-8859-1 — mojibake is never silently translated.

Languages: English · Slovenčina

Layout

<server dir>/
├── Subtitles\        # SUBTITLES_ROOT — movie folders (Subtitles/<movie>/<file>)
│   ├── Movie A\
│   │   ├── movie-a.srt
│   │   └── glossary.json     # movie/series-scoped glossary
│   └── Movie B\
│       └── movie-b.srt
└── data\             # SRT_DATA_ROOT — session.json + global glossary.json (+ .bak)

Override the roots with the SUBTITLES_ROOT and SRT_DATA_ROOT env vars.

Quick start

Requires Node.js 20+ (tested on 20/22).

npm install
npm run build   # tsc → build/
npm test        # vitest run

MCP config (VS Code / Cline):

{
  "mcpServers": {
    "subtitle-translation-mcp": {
      "command": "node",
      "args": ["<path-to-repo>/build/index.js"],
      "env": {
        "SUBTITLES_ROOT": "<path-to-repo>/Subtitles",
        "SRT_DATA_ROOT": "<path-to-repo>/data"
      }
    }
  }
}

Tools (19)

Tool Purpose
list_movies List movie folders and their subtitle files
list_formats List supported subtitle formats (SRT, MicroDVD .sub)
info_subtitles Block count, first/last timecodes, validation issues; reports detected encoding + detectionConfidence
parse_subtitles Return a page of blocks (startBlock/blockCount); stores the full source (timing/order) into the session on first call
subtitle_overview Whole-movie plain text (no indexes/timecodes); outFile writes a .txt, maxLines caps output
search_cues Find cues by text/regex, with optional surrounding context — check name/term consistency
replace_cues Replace text/regex across cues (literal or regex); outFile writes the result; timing untouched
translate_batch Store translated blocks — send only { index, text }; reports unknown/empty indexes
build_subtitles Assemble the full file from the session; outFile write / format conversion, includeContent/preview
translation_status Session status: total/stored/remaining + missingRanges (resume after interruption)
clear_translation Clear the persistent session for a file
glossary_get Read the translation memory (global + movie-scoped entries; optional srcLang filter)
glossary_add Add/update a term (term → translation, srcLang, scope) — write only after explicit user consent
validate_subtitles Structural validation: duplicates, inverted timecodes, overlaps, empty cues
write_subtitles Write subtitle content to a file inside the root (UTF-8, overwrite guard)
shift_timecodes Shift all timecodes by ±ms
reindex_subtitles Re-number cues sequentially
clean_sound_cues Remove sound-effect cues (e.g. [krik]); mode "cues+lines" (default) also strips [...] from mixed lines; writes to a new outFile, dryRun preview
generate_release_note Write the three-version README.txt release note for a finished translation

Translation workflow (EN→SK example)

  1. info_subtitles → sanity check + encoding.
  2. subtitle_overview → read the whole film (identify characters/terminology).
  3. glossary_get → load the translation memory; propose new terms, start only after approval.
  4. parse_subtitles in batches (e.g. 100 blocks) — stores full source.
  5. Agent translates and sends only { index, text } via translate_batch.
  6. Repeat until remaining: 0 (track with translation_status).
  7. build_subtitles with outFile → merged result.
  8. validate_subtitles on the result.
  9. generate_release_note → three-version README.txt in the movie folder.

Agent translation rules

The server structures and persists, but the actual translation is done by an LLM agent (e.g. Cline). Quality depends on the agent following a strict rule set: review the whole film first, no mojibake, correct audio-track language, glossary priority, informal T-form, no Czechisms, name transliteration per Slovak rules, ~37–42 chars per line, source-language selection (CZ > Slavic > DE/FR > EN for Western films; original ZH/JA/KO > Slavic > EN for Asian films).

The quality also depends on the LLM model itself: it should handle at least 256k context (above 512k recommended — a single full-movie overview can be large), and it should be linguistically strong in Slovak. The project is developed and tested with DeepSeek-V4-Flash.

The public version is in docs/translation-rules.en.md (English) and docs/translation-rules.sk.md (Slovak). The private working copy lives in .clinerules/ and is not part of this repository.

Docs

Adding a new format (modular)

  1. Create src/formats/<name>.ts exporting an adapter implementing SubtitleFormat.
  2. Register it in src/core/formats.ts:
import { assAdapter } from "../formats/ass.js";
export const ADAPTERS: SubtitleFormat[] = [srtAdapter, assAdapter];

No other code changes — all tools are format-agnostic.

Safety

  • All movie/file/outFile paths are validated to stay inside the configured root; inner separators are rejected (flat Subtitles/<movie>/<file> layout).
  • No shell execution — everything uses Node.js fs APIs.
  • Writes happen only via the write tools (with the overwrite guard on write_subtitles).

Development

npm install
npm run build   # tsc
npm test        # vitest run (149 tests)

License

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选