@ff-xiaofan/fastmcp-text-segment
v1.1.0
Published
A FastMCP server with text segmentation tool - split text by natural paragraphs
Maintainers
Readme
FastMCP Text Segment Server
A FastMCP server for intelligent text segmentation by natural paragraphs.
功能特性
- ✅ 智能文本分段(自然段落识别)
- ✅ 多种输出格式(Array、Numbered、Markdown)
- ✅ 自动清理空段落和空白字符
- ✅ 支持双换行和单换行分段
- ✅ 基于 MCP 协议
快速开始
安装
npm install -g @ff-xiaofan/fastmcp-text-segment使用
fastmcp-segment或使用 npx(无需安装):
npx @ff-xiaofan/fastmcp-text-segmentMCP 工具
segment_text
根据自然段落对文本进行分段处理。
参数:
text(必需): 需要分段的文本内容format(可选): 输出格式"array"(默认): JSON数组格式"numbered": 编号列表格式"markdown": Markdown格式
示例:
{
"text": "第一段内容\\n\\n第二段内容\\n\\n第三段内容",
"format": "array"
}greeting
简单的问候工具。
参数:
name(必需): 要问候的人的名字language(可选): 'zh' 或 'en',默认 'en'
Claude Desktop 配置
编辑配置文件:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
添加配置:
{
"mcpServers": {
"text-segment": {
"command": "npx",
"args": ["-y", "@ff-xiaofan/fastmcp-text-segment"]
}
}
}分段规则
- 优先按双换行符(`
或\r
\r
`)分段
2. 如果没有双换行,则按单换行符分段
3. 自动过滤空段落
4. 自动去除段落首尾空白
输出格式示例
Array 格式
[
"第一段内容",
"第二段内容",
"第三段内容"
]Numbered 格式
1. 第一段内容
2. 第二段内容
3. 第三段内容Markdown 格式
### 段落 1
第一段内容
### 段落 2
第二段内容
### 段落 3
第三段内容技术栈
- MCP SDK 1.x
- TypeScript 5.x
- Node.js 18+
- Zod(参数验证)
开发
# 克隆项目
git clone https://github.com/ff-xiaofan/fastmcp-text-segment.git
cd fastmcp-text-segment
# 安装依赖
npm install
# 开发模式
npm run dev
# 运行测试
npm test
# 构建
npm run buildLicense
MIT
