Skip to main content

MCP Jieba Server

这是一个基于 rjieba (Rust implementation of Jieba) 的 Model Context Protocol (MCP) 服务器,提供高性能的中文分词服务。

功能特性

  • 高性能分词: 使用 Rust 编写的底层引擎。
  • 多模式支持: 支持精确模式 (exact) 和搜索引擎模式 (search)。
  • 词性标注: 支持 ICTCLAS 兼容的词性标注。
  • 关键词提取: 基于 BM25 算法的关键词提取。
  • 批量处理: 支持单字符串或字符串数组输入,返回 JSON 格式结果。
  • 双模部署:
    • STDIO: 适用于本地开发和 Claude Context/Cherry Studio/VS Code 集成。
    • Streamable-HTTP: 适用于远程部署(如 ModelScope)。

安装

使用 pip / uv / pipx

# 使用 pip
pip install .

# 使用 uv
uv pip install .

使用方法

1. 本地运行 (STDIO)

直接运行模块即可启动 STDIO 服务器:

python -m mcp_jieba.server

或者在 Claude Context/Cherry Studio/VS Code 的 MCP 配置中添加:

{
  "mcpServers": {
    "jieba": {
      "command": "python",
      "args": ["-m", "mcp_jieba.server"]
    }
  }
}

2. 远程部署 (Streamable-HTTP)

使用命令行参数启动 HTTP 服务器:

python -m mcp_jieba.server --transport http --host 0.0.0.0 --port 8000

SSE 端点地址: http://localhost:8000/sse

ModelScope 部署

在 ModelScope 创建 Space 时,选择 Python 环境,并使用以下启动命令:

python -m mcp_jieba.server --transport http --host 0.0.0.0 --port 8000

当前 pyproject.toml 已经包含所有依赖。

开发与测试

目前项目的单元测试尚不完善。建议使用 MCP Inspector 进行交互式测试和调试。

bunx @modelcontextprotocol/inspector python -m mcp_jieba.server

工具说明

tokenize

对文本进行分词。

项目 描述
参数
  • text (required): 待分词的文本,可以是单个字符串或字符串数组。
  • mode (optional): 分词模式,可选 "exact" (默认) 或 "search"。
返回 JSON 对象,键为输入数组的索引(字符串格式),值为分词结果数组。

示例:

  • 输入: text=["我爱北京天安门"], mode="exact"
  • 输出: {"0": ["我", "爱", "北京", "天安门"]}

tag

对文本进行词性标注,标注类型符合ICTCLAS标准。

项目 描述
参数
  • text (required): 待标注的文本,可以是单个字符串或字符串数组。
返回 JSON 对象,键为输入数组的索引,值为单词-词性对的列表。

示例:

  • 输入: text=["我爱北京天安门"]
  • 输出: {"0": [{"word": "我", "flag": "r"}, {"word": "爱", "flag": "v"}, ...]}

extract_keywords

使用向量化的针对关键词BM25-ADPT算法提取关键词。

项目 描述
参数
  • text (required): 待提取的文本,可以是单个字符串或字符串数组。
  • top_k (optional): 每个文档提取的关键词数量 (默认 3)。
返回 JSON 对象,键为输入数组的索引,值为关键词列表。

示例:

  • 输入: text=["我爱北京天安门"], top_k=2
  • 输出: {"0": ["天安门", "北京"]}

鸣谢

Metadata

Release files for mcp-jieba 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-jieba 0.1.1
File Size Uploaded Provenance
mcp_jieba-0.1.1.tar.gz 33.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-jieba 0.1.1
File Interpreter ABI Platform
mcp_jieba-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 72.7 kB

Release files / mcp_jieba-0.1.1.tar.gz

Download URL mcp_jieba-0.1.1.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7e1825fc433fc54b10fd74ff93fdda495b5f18fd9a645b92e0c64955afc3e153
BLAKE2b-256 checksum
How to use checksums
0e4c896a9d113da2762c3462f7d3662bac383f8e65b2bb1fb3c1fc8c8cafbecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Release files / mcp_jieba-0.1.1-py3-none-any.whl

Download URL mcp_jieba-0.1.1-py3-none-any.whl
Size 38.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01d167a6d443fca72d8990ae103c973e2b602a12c462147264a5896bcc0ac46d
BLAKE2b-256 checksum
How to use checksums
870366bd923698e7bdde8a0f7723bf74da40c335d1db878ba34ee55d20bc6413
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.11

Security for mcp-jieba 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page