vtt-vietsub-mcp

v1.1.0
vtt-vietsub-mcp Checked 4 days ago Published 1 month ago

MCP server for translating VTT subtitle files to Vietnamese using configurable LLM providers

MCP server that translates .vtt subtitle files to Vietnamese using any OpenAI-compatible LLM (Ollama, Gemini, OpenRouter, etc.). Add to your MCP config and you're ready. No installation needed — npx handles it automatically. Scan a directory recursively and list all .vtt files with translation status.

Summary extracted from the README.

vtt-vietsub-mcp

MCP server that translates .vtt subtitle files to Vietnamese using any OpenAI-compatible LLM (Ollama, Gemini, OpenRouter, etc.).

Quick Start

Add to your MCP config and you're ready. No installation needed — npx handles it automatically.

Configuration

Environment Variables

Variable Required Description
LLM_BASE_URL ✓ Base URL of the OpenAI-compatible endpoint
LLM_API_KEY ✓ API key (use any non-empty string for local models)
LLM_MODEL ✓ Model name to use
TRANSLATION_RULES — Custom translation rules (see Customizing Translation)

Provider Examples

Ollama (local):

{
  "LLM_BASE_URL": "http://localhost:11434/v1",
  "LLM_API_KEY": "ollama",
  "LLM_MODEL": "llama3"
}

Gemini (via OpenAI-compat endpoint):

{
  "LLM_BASE_URL": "https://generativelanguage.googleapis.com/v1beta/openai/",
  "LLM_API_KEY": "YOUR_GEMINI_API_KEY",
  "LLM_MODEL": "gemini-3.5-flash-lite"
}

Claude via OpenRouter:

{
  "LLM_BASE_URL": "https://openrouter.ai/api/v1",
  "LLM_API_KEY": "YOUR_OPENROUTER_KEY",
  "LLM_MODEL": "anthropic/claude-3-5-haiku"
}

Kiro / Cursor (.kiro/settings/mcp.json)

{
  "mcpServers": {
    "vtt-vietsub": {
      "command": "npx",
      "args": ["-y", "vtt-vietsub-mcp@latest"],
      "env": {
        "LLM_BASE_URL": "https://generativelanguage.googleapis.com/v1beta/openai/",
        "LLM_API_KEY": "YOUR_GEMINI_API_KEY",
        "LLM_MODEL": "gemini-3.5-flash-lite"
      },
      "disabled": false
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "vtt-vietsub": {
      "command": "npx",
      "args": ["-y", "vtt-vietsub-mcp@latest"],
      "env": {
        "LLM_BASE_URL": "https://generativelanguage.googleapis.com/v1beta/openai/",
        "LLM_API_KEY": "YOUR_GEMINI_API_KEY",
        "LLM_MODEL": "gemini-3.5-flash-lite"
      }
    }
  }
}

Tools

list_vtt_files

Scan a directory recursively and list all .vtt files with translation status.

Input:

  • dir_path (string, required): Absolute path to the directory

Output:

[
  { "file": "D:\\courses\\01.intro.vtt", "status": "pending" },
  { "file": "D:\\courses\\02.basics.vtt", "status": "translated" }
]

translate_vtt_file

Translate a single .vtt file to Vietnamese. Creates {stem}-vietsub.vtt alongside the original.

Input:

  • file_path (string, required): Absolute path to the .vtt file
  • force (boolean, optional): Overwrite existing translation (default: false)

Output on success:

{ "status": "done", "output_path": "D:\\courses\\01.intro-vietsub.vtt", "cues_translated": 53 }

Output when skipped:

{ "status": "skipped", "output_path": "D:\\courses\\01.intro-vietsub.vtt" }

translate_vtt_dir

Translate all .vtt files in a directory (recursively) to Vietnamese.

Input:

  • dir_path (string, required): Absolute path to the directory
  • force (boolean, optional): Overwrite existing translations (default: false)

Output:

{
  "translated": 3,
  "skipped": 1,
  "errors": 0,
  "details": [
    { "file": "D:\\courses\\01.vtt", "status": "done", "cues_translated": 53 },
    { "file": "D:\\courses\\02.vtt", "status": "done", "cues_translated": 47 },
    { "file": "D:\\courses\\03.vtt", "status": "done", "cues_translated": 61 },
    { "file": "D:\\courses\\04.vtt", "status": "skipped" }
  ]
}

Customizing Translation

By default, the server applies these translation rules:

  • Preserve multi-line cue structure (line breaks within a cue are kept)
  • Keep proper nouns, product names, and brand names in English (e.g., "Photography Masterclass", "iPhone")

You can override these via the TRANSLATION_RULES environment variable. Each rule goes on its own line, starting with - .

Example — add formal tone + keep course titles untranslated:

"TRANSLATION_RULES": "- The symbol ⏎ represents a line break — preserve it.\n- Keep proper nouns and course names in their original English form.\n- Use formal Vietnamese (\"bạn\"/\"chúng tôi\" style, no slang)."

If TRANSLATION_RULES is not set, the built-in defaults apply.


promote_vietsub

Promote translated files to primary: rename {stem}.vtt → {stem}-backup.vtt and {stem}-vietsub.vtt → {stem}.vtt. Files without a -vietsub.vtt counterpart are skipped.

Input:

  • dir_path (string, required): Absolute path to the directory
  • force (boolean, optional): Replace existing -backup.vtt if present (default: false)

Output:

{
  "promoted": 4,
  "skipped": 0,
  "errors": 0,
  "details": [
    { "file": "D:\\courses\\01.vtt", "status": "promoted", "backup_path": "D:\\courses\\01-backup.vtt" },
    { "file": "D:\\courses\\02.vtt", "status": "promoted", "backup_path": "D:\\courses\\02-backup.vtt" }
  ]
}

Notes on force=true: The old backup is not deleted until both renames succeed. If a failure occurs mid-operation, the tool attempts to rollback to preserve all files.

Typical Workflow

1. list_vtt_files      → see which files are pending / translated
2. translate_vtt_dir   → translate all pending files → creates *-vietsub.vtt
3. (review the translations)
4. promote_vietsub     → rename pairs so translated file becomes the primary .vtt

Customizing Translation

By default, the server applies these translation rules:

  • Preserve multi-line cue structure (line breaks within a cue are kept)
  • Keep proper nouns, product names, and brand names in English (e.g., "Photography Masterclass", "iPhone")

You can override these via the TRANSLATION_RULES environment variable. Each rule goes on its own line, starting with - .

Example — add formal tone + keep course titles untranslated:

"TRANSLATION_RULES": "- The symbol ⏎ represents a line break — preserve it.\n- Keep proper nouns and course names in their original English form.\n- Use formal Vietnamese (\"bạn\"/\"chúng tôi\" style, no slang)."

If TRANSLATION_RULES is not set, the built-in defaults apply.

Notes

  • API key is never logged or exposed in tool responses
  • LLM config errors are returned as tool-level errors (server does not crash)
  • Translations are chunked automatically for large files (>150 cues per batch)
  • UNC paths (\\server\share) are rejected for security reasons
  • -vietsub.vtt and -backup.vtt files are excluded from all scanning operations