Command Palette

Search for a command to run...

UnylyUnyly
Browse all

Thai Text

FreeNot checked

MCP server giving AI agents correct Thai text handling: word segmentation, caption line wrapping, and tone-mark-safe rendering

GitHubEmbed

About

MCP server giving AI agents correct Thai text handling: word segmentation, caption line wrapping, and tone-mark-safe rendering

README

CI

An MCP server that gives AI agents correct Thai text handling: word segmentation, caption line wrapping, and tone-mark-safe text rendering.

Why

Agents working with Thai run into three problems that do not exist in English:

  1. No spaces between words. Splitting on whitespace returns the whole sentence as one token. Anything that needs word boundaries (wrapping, counting, alignment to speech) needs a dictionary-based tokenizer.
  2. Line breaking is a language problem, not a length problem. Breaking captions on character count splits words in half. And even at word boundaries, a line that ends on a lead-in word (เพราะ, แล้ว, คือ) or starts with an enclitic (ครับ, นะ, ไหม) reads wrong on screen.
  3. Renderers silently misspell Thai. Pillow without libraqm and libass subtitle burn-in both drop stacked tone marks: เนื่อง comes out as เนือง, นี้ as นี. No error is raised. The output is just wrong.

This server packages the fixes as three MCP tools so any client (Claude Code, Claude Desktop, or your own agent loop) can call them.

Tools

tool input output
segment_words Thai text list of words (PyThaiNLP newmm)
wrap_caption_lines Thai text, max chars per line caption lines broken at word boundaries, with lead-in and enclitic rules applied
render_text_png text, output path, font, size, color, glow a PNG with HarfBuzz-shaped, correctly stacked Thai text

Install

pip install -r requirements.txt

Register with Claude Code:

claude mcp add thai-text -- python /path/to/mcp-thai-text/server.py

Or in any MCP client config:

{
  "mcpServers": {
    "thai-text": {
      "command": "python",
      "args": ["/path/to/mcp-thai-text/server.py"]
    }
  }
}

render_text_png needs a Thai-capable font (Kanit, Sarabun, Noto Sans Thai). It checks common install locations and takes an explicit font_path otherwise.

Test

python test_client.py

Spawns the server over stdio as a real MCP client, lists the tools, and exercises all three, including writing an actual PNG and asserting it exists.

Example

wrap_caption_lines on a sentence with max_chars: 14:

เพราะภาษาไทย
ไม่มีช่องว่าง
ระหว่างคำการ
ตัดบรรทัดจึง
ต้องตัด
ที่ขอบเขตของคำ
จริง

Every break lands on a word boundary, no line starts with an enclitic, and no line ends on a lead-in.

Related

  • thai-text-render: the standalone rendering library this server's render_text_png is built on, with a visual before/after of the tone-mark bug.
  • thai-talkinghead-autocut: the video pipeline where these rules were battle-tested against real footage.

License

MIT

from github.com/anthonychkwn/mcp-thai-text

Install Thai Text in Claude Desktop, Claude Code & Cursor

Recommended · one command, every IDE
unyly install thai-text

Installs into Claude Desktop, Claude Code, Cursor & VS Code — handles npx, uvx and build-from-source repos for you.

First time? Get the CLI: curl -fsSL https://unyly.org/install | sh

Or configure manually

Run in your terminal:

claude mcp add thai-text -- uvx --from git+https://github.com/anthonychkwn/mcp-thai-text mcp-thai-text

Step-by-step: how to install Thai Text

FAQ

Is Thai Text MCP free?

Yes, Thai Text MCP is free — one-click install via Unyly at no cost.

Does Thai Text need an API key?

No, Thai Text runs without API keys or environment variables.

Is Thai Text hosted or self-hosted?

Self-hosted: the server runs locally on your machine via the install command above.

How do I install Thai Text in Claude Desktop, Claude Code or Cursor?

Open Thai Text on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.

Related MCPs

Compare Thai Text with

Not sure what to pick?

Find your stack in 60 seconds

Author?

Embed badge for your README

Browse similar

All ai MCPs