A FastMCP server with text segmentation tool - split text by natural paragraphs
npm install @ff-xiaofan/fastmcp-text-segmentbash
npm install -g @ff-xiaofan/fastmcp-text-segment
`
$3
`bash
fastmcp-segment
`
或使用 npx(无需安装):
`bash
npx @ff-xiaofan/fastmcp-text-segment
`
MCP 工具
$3
根据自然段落对文本进行分段处理。
参数:
- text (必需): 需要分段的文本内容
- format (可选): 输出格式
- "array" (默认): JSON数组格式
- "numbered": 编号列表格式
- "markdown": Markdown格式
示例:
`json
{
"text": "第一段内容\\n\\n第二段内容\\n\\n第三段内容",
"format": "array"
}
`
$3
简单的问候工具。
参数:
- 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
添加配置:
`json
{
"mcpServers": {
"text-segment": {
"command": "npx",
"args": ["-y", "@ff-xiaofan/fastmcp-text-segment"]
}
}
}
`
分段规则
1. 优先按双换行符(
或 \r
)分段
2. 如果没有双换行,则按单换行符分段
3. 自动过滤空段落
4. 自动去除段落首尾空白
输出格式示例
$3
`json
[
"第一段内容",
"第二段内容",
"第三段内容"
]
`
$3
`
1. 第一段内容
2. 第二段内容
3. 第三段内容
`
$3
`markdown
$3
第一段内容
$3
第二段内容
$3
第三段内容
`
技术栈
- MCP SDK 1.x
- TypeScript 5.x
- Node.js 18+
- Zod(参数验证)
开发
`bash
克隆项目
git clone https://github.com/ff-xiaofan/fastmcp-text-segment.git
cd fastmcp-text-segment
安装依赖
npm install
开发模式
npm run dev
运行测试
npm test
构建
npm run build
``