Skip to content

PsychQuant/che-cn2tw-mcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

che-cn2tw-mcp

Swift native MCP Server for converting Chinese Mainland terms to Taiwanese Mandarin equivalents.

Detects and replaces mainland Chinese vocabulary with Taiwan-standard phrasing, powered by dictionaries from g0v (MOE data) and Wikipedia.

Build

Requires Swift 5.9+ and macOS 13+.

git clone https://github.com/kiki830621/che-cn2tw-mcp.git
cd che-cn2tw-mcp
swift build -c release

Binary location: .build/release/CheCn2TwMCP

Installation

Option A: Claude Code CLI

claude mcp add che-cn2tw-mcp -s user -- /path/to/.build/release/CheCn2TwMCP

Verify:

claude mcp get che-cn2tw-mcp
# Should show: Status: ✓ Connected

Option B: Edit config directly

Add to ~/.claude.json:

{
  "mcpServers": {
    "che-cn2tw-mcp": {
      "type": "stdio",
      "command": "/path/to/.build/release/CheCn2TwMCP"
    }
  }
}

Option C: Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "che-cn2tw-mcp": {
      "command": "/path/to/.build/release/CheCn2TwMCP"
    }
  }
}

First Run

After connecting, run update_dictionary to download term data:

update_dictionary          # Download from all sources
update_dictionary source=g0v       # g0v only
update_dictionary source=wikipedia # Wikipedia only

Dictionary files are stored at ~/.che-cn2tw-mcp/.

Tools (8)

Text Conversion

Tool Description
convert_text Detect and replace mainland terms in text, returns converted text + change list
lookup_term Look up a single term (supports both CN→TW and TW→CN)
search_terms Fuzzy search the dictionary

Dictionary Management

Tool Description
update_dictionary Download/refresh dictionary from online sources (g0v, Wikipedia)
add_term Add a custom CN→TW mapping (saved to ~/.che-cn2tw-mcp/custom.json)
remove_term Remove a custom mapping

Info

Tool Description
list_categories List all term categories with counts
get_stats Show dictionary stats (entry count, sources, last update)

Data Sources

Source Format Scale
g0v/moedict-data-csld (=同實異名.json) JSON ~750 pairs
g0v/moedict-data-csld (同實異名.csv) CSV ~1,000 pairs
Wikipedia (兩岸四地用語差異, 海峽兩岸術語差異) Wikitext Community-maintained
User custom (~/.che-cn2tw-mcp/custom.json) JSON Unlimited

Usage Examples

Once connected, ask Claude things like:

  • "幫我把這段文字轉成台灣用語:这个视频的质量很高"
  • "查一下「軟件」的台灣說法"
  • "搜尋跟「網路」有關的對照詞彙"
  • "新增自訂對照:信息 → 資訊"
  • "更新詞庫"
  • "顯示詞庫統計"

Architecture

Sources/
├── CheCn2TwMCP/
│   └── main.swift                # Entry point
└── CheCn2TwMCPCore/
    ├── Server.swift              # MCP Server (8 tools + dispatch)
    ├── TermDictionary.swift      # Dictionary load/save/search/convert
    └── DictionaryUpdater.swift   # Online fetcher (g0v + Wikipedia)
  • No third-party dependencies beyond MCP Swift SDK
  • Uses URLSession for all HTTP requests
  • Longest-match-first algorithm prevents substring false positives
  • Custom terms override built-in dictionary entries

How It Works

The convert_text tool uses a longest-match-first algorithm:

  1. Sort all CN terms by length (descending)
  2. Scan through input text, matching the longest term first
  3. Track replaced positions to avoid overlapping replacements
  4. Return converted text + a change list with positions
Input:  "這個視頻的質量很高"
Output: "這個影片的品質很高"
Changes: [
  { "視頻" → "影片", position: 3 },
  { "質量" → "品質", position: 6 }
]

License

MIT

About

MCP Server for converting Chinese Mainland terms to Taiwanese Mandarin

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages