jieba-mcp

jieba-mcp

Enables Chinese text segmentation using the jieba library with support for precise, full, and search engine modes. Provides natural language access to professional Chinese word segmentation capabilities through MCP protocol.

Category
Visit Server

README

jieba-mcp

基于 jieba 中文分词的 MCP (Model Context Protocol) 服务器,使用 FastMCP 框架构建。

项目简介

这是一个 MCP 服务器,提供中文文本分词功能。通过 FastMCP 框架将 jieba 分词能力封装为标准的 MCP 工具,可以被支持 MCP 协议的客户端(如 Claude Desktop)调用。

功能特性

  • 支持三种分词模式:
    • 精确模式(默认):试图将句子最精确地切开,适合文本分析
    • 全模式:把句子中所有的可以成词的词语都扫描出来
    • 搜索引擎模式:在精确模式的基础上,对长词再次切分,提高召回率
  • 自动过滤空白字符
  • 基于 SSE (Server-Sent Events) 传输协议
  • Docker 容器化部署支持

安装和使用

1. 直接运行

# 安装依赖
pip install -r requirements.txt

# 启动服务器
python main.py

2. Docker 部署

# 构建镜像
docker build -t jieba-mcp .

# 运行容器
docker run -p 9998:9998 jieba-mcp

API 文档

jieba_segment 工具

对中文文本进行分词处理。

参数:

  • text (str): 待分词的中文文本
  • mode (str, 可选): 分词模式,默认为 "precise"
    • "precise": 精确模式
    • "full": 全模式
    • "search": 搜索引擎模式

返回值:

  • List[str]: 分词后的词语列表(已去除空白字符)

示例:

# 精确模式
jieba_segment("我来到北京清华大学")
# 返回: ["我", "来到", "北京", "清华大学"]

# 全模式
jieba_segment("我来到北京清华大学", mode="full")
# 返回: ["我", "来到", "北京", "清华", "清华大学", "华大", "大学"]

# 搜索引擎模式
jieba_segment("小明硕士毕业于中国科学院计算所", mode="search")
# 返回: ["小明", "硕士", "毕业", "于", "中国", "科学", "学院", "科学院", "中国科学院", "计算", "计算所"]

项目结构

jieba-mcp/
├── main.py              # 主程序文件
├── requirements.txt     # Python 依赖包
├── Dockerfile          # Docker 构建文件
└── README.md           # 项目说明文档

技术栈

  • Python 3.11+: 主要编程语言
  • jieba: 中文分词库
  • FastMCP: MCP 服务器框架
  • Docker: 容器化部署

配置

服务器默认配置:

  • 主机: 0.0.0.0
  • 端口: 9998
  • 传输协议: SSE (Server-Sent Events)

如需修改配置,请编辑 main.py 文件中的相关参数。

开发

本地开发环境搭建

  1. 克隆项目:
git clone <repository-url>
cd jieba-mcp
  1. 创建虚拟环境:
python -m venv venv
source venv/bin/activate  # Linux/Mac
# 或
venv\Scripts\activate     # Windows
  1. 安装依赖:
pip install -r requirements.txt
  1. 启动开发服务器:
python main.py

MCP 客户端集成

要在支持 MCP 的客户端(如 Claude Desktop)中使用此服务器:

  1. 启动 jieba-mcp 服务器
  2. 在客户端配置中添加 MCP 服务器连接
  3. 指定服务器地址为 http://localhost:9998

贡献

欢迎提交 Issue 和 Pull Request 来改进这个项目。

许可证

本项目采用 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