Skip to main content
Glama

jieba-mcp

English | 简体中文

Chinese text processing for any MCP client: word segmentation, keyword extraction, part-of-speech tagging, a user dictionary and Simplified/Traditional conversion. It is built on jieba and runs locally over stdio with a single uvx jieba-mcp.

LLMs can read Chinese, but they cannot reliably count, split or rank Chinese words. These tools give them deterministic answers that are the same on every run.

Tools

Tool

What it does

segment

Split text into words. Modes: precise (default), full, search

extract_keywords

Top keywords by tfidf (default) or textrank, with optional weights and POS filter

pos_tag

Words plus part-of-speech tags (n, v, ns, nr, …)

add_user_words

Add domain words (names, jargon, brands) so later calls keep them whole

convert_chinese

Simplified ⇄ Traditional via OpenCC configs (s2t, t2s, s2tw, tw2s, s2twp, tw2sp, s2hk, hk2s)

Every tool returns structured JSON (structuredContent) and declares an output schema. Parameters are described in each tool's JSON Schema, so clients can show them.

Related MCP server: MCP Jieba Server

Install

Requires Python 3.10+ and uv.

uvx jieba-mcp            # runs the server on stdio

Until the package is on PyPI, run it from GitHub instead: uvx --from git+https://github.com/BACH-AI-Tools/jieba-mcp jieba-mcp.

Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "jieba": {
      "command": "uvx",
      "args": ["jieba-mcp"]
    }
  }
}

Cursor

Add the same block to ~/.cursor/mcp.json (global) or .cursor/mcp.json (per project).

Claude Code

claude mcp add jieba -- uvx jieba-mcp

HTTP transports (optional)

jieba-mcp --transport streamable-http --port 9998   # http://127.0.0.1:9998/mcp
jieba-mcp --transport sse --port 9998               # http://127.0.0.1:9998/sse

--host defaults to 127.0.0.1. The Docker image serves SSE on 0.0.0.0:9998:

docker build -t jieba-mcp . && docker run -p 9998:9998 jieba-mcp

Examples

The outputs below are real structuredContent returned over stdio by version 1.0.0. The first call takes about a second while jieba loads its dictionary.

segment

{"text": "我来到北京清华大学"}
→ {"mode": "precise", "tokens": ["我", "来到", "北京", "清华大学"], "count": 4}

{"text": "我来到北京清华大学", "mode": "full"}
→ {"mode": "full", "tokens": ["我", "来到", "北京", "清华", "清华大学", "华大", "大学"], "count": 7}

{"text": "小明硕士毕业于中国科学院计算所", "mode": "search"}
→ {"mode": "search", "tokens": ["小明", "硕士", "毕业", "于", "中国", "科学", "学院", "科学院", "中国科学院", "计算", "计算所"], "count": 11}

Set "hmm": false to turn off jieba's HMM model, which joins unknown words.

extract_keywords

{"text": "我来到北京清华大学,清华大学是一所综合性大学", "top_k": 3}
→ {"method": "tfidf", "keywords": [
     {"word": "清华大学", "weight": 2.308741},
     {"word": "一所", "weight": 1.115948},
     {"word": "综合性", "weight": 1.044143}]}

{"text": "线程是程序执行中一个单一的顺序控制流程,进程内有一个或多个线程,线程共享进程的资源",
 "top_k": 3, "method": "textrank"}
→ {"method": "textrank", "keywords": [
     {"word": "线程", "weight": 1.0},
     {"word": "进程", "weight": 0.7957},
     {"word": "共享", "weight": 0.504354}]}

Options:

  • with_weight: false returns words only, and each weight is null.

  • allow_pos keeps only the listed tags. For example, ["ns"] keeps only place names.

  • TextRank defaults to ["ns", "n", "vn", "v"].

pos_tag

{"text": "我爱北京天安门"}
→ {"tokens": [{"word": "我", "flag": "r"}, {"word": "爱", "flag": "v"},
              {"word": "北京", "flag": "ns"}, {"word": "天安门", "flag": "ns"}], "count": 4}

Tags follow jieba's ICTCLAS-compatible set; see the jieba README.

add_user_words

segment {"text": "大语言模型正在改变检索增强生成"}
→ {"tokens": ["大", "语言", "模型", "正在", "改变", "检索", "增强", "生成"], ...}

add_user_words {"words": [{"word": "大语言模型", "tag": "nz"}, {"word": "检索增强生成"}]}
→ {"added": ["大语言模型", "检索增强生成"], "count": 2}

segment {"text": "大语言模型正在改变检索增强生成"}
→ {"tokens": ["大语言模型", "正在", "改变", "检索增强生成"], ...}

pos_tag {"text": "大语言模型正在改变检索增强生成"}
→ {"tokens": [{"word": "大语言模型", "flag": "nz"}, {"word": "正在", "flag": "t"},
              {"word": "改变", "flag": "v"}, {"word": "检索增强生成", "flag": "x"}], ...}
  • Where the words live: in the server process's memory only. They apply to all later calls and to every client of that process. They are lost when the process restarts, and nothing is written to disk.

  • Tags: give a tag if you want pos_tag to label the word; words added without one are tagged x.

  • Frequency: freq is optional. If you omit it, jieba picks one that keeps the word whole.

convert_chinese

{"text": "软件和鼠标", "config": "s2twp"}  → {"config": "s2twp", "text": "軟體和滑鼠"}
{"text": "漢字轉換", "config": "t2s"}      → {"config": "t2s", "text": "汉字转换"}

Development

git clone https://github.com/BACH-AI-Tools/jieba-mcp.git
cd jieba-mcp
pip install -e '.[test]'
pytest                       # tool tests + a real stdio session via the MCP client

License and acknowledgements

Available Tools

5 tools
add_user_wordsAdd words to the user dictionaryA
Idempotent

Add domain words (names, jargon, brands) so later calls keep them whole.

The dictionary lives in this server process's memory only: it affects every later call to segment, pos_tag and extract_keywords, is shared by all clients of this process, and is gone after a restart. Nothing is written to disk.

Inputs: words (required). Returns: added, count

convert_chineseConvert Simplified / Traditional ChineseB
Read-only

Convert between Simplified and Traditional Chinese.

Inputs: text (required), config. Returns: text, config

extract_keywordsExtract keywordsB
Read-only

Extract the most important keywords from Chinese text.

Inputs: text (required), top_k, method, allow_pos, +1 more. Returns: method, keywords

pos_tagPart-of-speech taggingA
Read-only

Segment Chinese text and tag each word with its part of speech.

Inputs: text (required), hmm. Returns: count, tokens

segmentSegment Chinese textB
Read-only

Split Chinese text into words with jieba.

Inputs: text (required), hmm, mode. Returns: mode, count, tokens

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 5 tools

    Disambiguation4/5

    Each tool maps to a distinct operation: segmentation, keyword extraction, POS tagging, dictionary mutation, and script conversion. The only slight overlap is between segment and pos_tag, since POS tagging also returns segmentation, but the descriptions make the added value clear. add_user_words is explicitly framed as a stateful modifier of the other three, which prevents confusion.

    Naming Consistency4/5

    All names are snake_case and verb-led (segment, extract_keywords, pos_tag, add_user_words, convert_chinese), forming a readable pattern. The minor deviation is `segment`, a bare verb with no object, while the others are verb_noun. That is easily understood in context and does not impair selection.

    Tool Count5/5

    Five tools cleanly cover the scope of a jieba wrapper without redundancy. Every tool earns its place: three text-analysis operations, one configuration hook, and one conversion utility. Nothing feels bolted on or missing at the structural level.

    Completeness4/5

    The core jieba surface is covered: segmentation, keyword extraction, POS tagging, and user dictionary insertion, plus a useful Simplified/Traditional converter. Minor gaps remain, such as no search-engine-mode segmentation, no way to list or remove user words, and no confidence weights on keywords, but agents can work around these.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables integration of DeepSeek's language models with MCP-compatible applications, offering features like chat completion, custom model selection, and parameter control for enhancing language-based interactions.
      11
      610 npm
      363
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that counts the number of Chinese characters (excluding punctuation, spaces, English, and numbers) in a given text, compatible with Streamable HTTP and JSON-RPC.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Provides AI models with tools to proofread and format Chinese text before delivery, covering typos, punctuation, casing, spacing, and platform-specific character limits. It runs as a zero-dependency MCP service so the model checks and fixes its own Chinese writing automatically.
      4
      1
      MIT