Translate SRT MCP Server

Translate SRT MCP Server

Enables translation of SRT subtitle files from English to Japanese using local LLM servers like LM Studio. Parses SRT format files and returns translated subtitles in proper SRT format through OpenAI-compatible APIs.

Category
Visit Server

README

translate-srt-mcp

SRT字幕ファイルを日本語に翻訳するMCPサーバー。LM Studioの翻訳モデルを使用して高品質な字幕翻訳を提供します。

主な機能

  • SRT形式の完全サポート: タイムスタンプを保持したまま翻訳
  • チャンクベース処理: 大きなファイルも効率的に処理
  • LM Studio統合: ローカルLLMを使用した高品質な翻訳
  • エラーハンドリング: 翻訳失敗時の自動リトライと詳細なエラー報告
  • 統計情報: 翻訳履歴と使用状況の追跡
  • 分析ツール: SRTファイルの検証と詳細分析
  • 接続診断: LM Studioの状態確認機能

利用可能なツール

1. translate_srt

字幕を日本語に翻訳します。

# 基本的な使用法
translated = mcp__translate-srt__translate_srt(
    srt_content=content
)

# カスタム設定
translated = mcp__translate-srt__translate_srt(
    srt_content=content,
    model_name="llama-3.2-3b",
    chunk_size=500,
    preserve_formatting=True
)

2. analyze_srt

SRTファイルの統計情報を分析します。

stats = mcp__translate-srt__analyze_srt(
    srt_content=content,
    detailed=True  # 詳細な分析を含む
)

3. check_lm_studio_status

LM Studioの接続状態を確認します。

status = mcp__translate-srt__check_lm_studio_status(
    lm_studio_url="http://localhost:1234",
    model_name="llama-3.2-3b"
)

4. preview_srt

字幕のプレビューを生成します。

preview = mcp__translate-srt__preview_srt(
    srt_content=content,
    num_entries=5,
    show_start=True,
    show_end=True
)

5. get_server_info

サーバー情報と統計を取得します。

info = mcp__translate-srt__get_server_info()

使用例

MCPクライアントでの実際の使用手順

# 1. LM Studioの状態を確認
status = await check_lm_studio_status()
if not status["api_reachable"]:
    print("LM Studioが起動していません")
    
# 2. SRTファイルを読み込み
srt_content = read_file("movie.srt")

# 3. 分析して内容を確認
analysis = await analyze_srt(srt_content, detailed=True)
print(f"字幕数: {analysis['subtitle_count']}")
print(f"総時間: {analysis['duration_formatted']}")

# 4. プレビュー表示
preview = await preview_srt(srt_content, num_entries=3)
print("最初の3つの字幕:")
for entry in preview["preview_entries"]["start"]:
    print(f"{entry['time']}: {entry['text']}")

# 5. 翻訳実行
translated = await translate_srt(
    srt_content=srt_content,
    model_name="llama-3.2-3b-instruct",
    chunk_size=1000
)

# 6. 結果を保存
write_file("movie_ja.srt", translated)

# 7. 統計情報を確認
info = await get_server_info()
print(f"翻訳回数: {info['statistics']['total_translations']}")
print(f"処理文字数: {info['statistics']['total_characters']}")

必要要件

  • Python 3.13以上
  • LM Studio または OpenAI互換APIサーバー
  • uv パッケージマネージャー(推奨)

インストール

方法1: uvx を使用(推奨・最も簡単)

インストール不要!mcp.jsonの設定だけで使用できます。

# テスト実行したい場合
uvx --from git+https://github.com/sumik5/translate-srt-mcp translate-srt-mcp

# 環境変数を設定して実行
LM_STUDIO_URL="http://localhost:1234" \
LM_MODEL_NAME="grapevine-AI/plamo-2-translate-gguf" \
uvx --from git+https://github.com/sumik5/translate-srt-mcp translate-srt-mcp

方法2: ローカルインストール

# リポジトリをクローン
git clone https://github.com/yourusername/translate-srt-mcp.git
cd translate-srt-mcp

# 依存関係をインストール(uvを使用)
uv sync

# または pip を使用
pip install -r requirements.txt

環境変数

# LM StudioのAPI URL (デフォルト: http://localhost:1234/v1)
export LM_STUDIO_URL="http://localhost:1234"

# 使用する翻訳モデル名 (必須)
export LM_MODEL_NAME="llama-3.2-3b-instruct"

# デフォルトのチャンクサイズ (デフォルト: 1000)
export CHUNK_SIZE="1000"

Claude Codeでの設定例

To use this server with the Claude Desktop app, add the following configuration to the "MCP Servers" section of your Claude settings:

"mcpServers": {
  "translate-srt": {
    "command": "uv",
    "args": [
      "--directory",
      "/path/to/translate-srt-mcp",
      "run",
      "translate-srt-mcp"
    ],
    "env": {
      "LM_STUDIO_URL": "http://localhost:1234",
      "LM_MODEL_NAME": "llama-3.2-3b-instruct",
      "CHUNK_SIZE": "1000"
    }
  }
}

MCPクライアントでの使用時のベストプラクティス

  1. 使用前の準備

    • LM Studioを起動し、適切なモデルをロード
    • check_lm_studio_statusで接続確認
  2. 大きなファイルの処理

    • analyze_srtで事前にファイルサイズを確認
    • 適切なchunk_sizeを設定(500-2000を推奨)
  3. エラー対処

    • 接続エラー: LM Studioの起動状態を確認
    • モデルエラー: 正しいモデル名を指定
    • 翻訳エラー: チャンクサイズを調整
  4. 品質向上のヒント

    • 専門用語が多い場合は小さいチャンクサイズを使用
    • preserve_formatting=Trueで元の改行を保持
    • 翻訳後にpreview_srtで結果を確認

Development

Install dependencies:

uv install

For development with auto-reloading:

uv run fastmcp dev translate_srt_mcp.main:mcp

トラブルシューティング

LM Studioに接続できない

# 接続状態を確認
status = await check_lm_studio_status()
print(status["recommendation"])

モデルが見つからない

# 利用可能なモデルを確認
status = await check_lm_studio_status()
print("利用可能なモデル:", status["available_models"])

翻訳が途中で止まる

  • チャンクサイズを小さくする(例: 500)
  • タイムアウト時間を増やす(translator.pyで設定)

ライセンス

MIT License

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured