字符处理工具

MCP字符工具是一个提供14+种字符和文本分析功能的工具集,专门为大型语言模型(LLM)设计,帮助它们处理字符级别的任务。

  • by Aaryan-Kapoor
  • TypeScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 Aaryan-Kapoor/mcp-character-tools

使用说明

MCP字符工具

LLM处理单个字符或计算单词中r的数量所需的最后一件事。这是一个MCP服务器,提供14多种全面(且美观)的字符和文本分析工具,帮助LLM处理单个字符——这是他们由于标记化而难以解决的问题。

看出差异

无MCP(错误) 有MCP(正确)
声称“大蒜”中有2个r 正确识别“大蒜”中的1 r
Yes, your agent will be able to tell how many r's are in Strawberry/Garlic :)

为什么存在

首先,为什么不呢?其次,大型语言模型将文本标记为子词,而不是单个字符。例如,“草莓”可能会变成像这样的代币 ["straw", "berry"],因此该模型从未真正“看到”单个字母。此MCP服务器通过一套工具为LLM提供“角色级视觉”。

安装

通过npx(推荐)

npx mcp-character-tools

通过npm(全局安装)

npm install -g mcp-character-tools
mcp-character-tools

来源

git clone https://github.com/Aaryan-Kapoor/mcp-character-tools
cd mcp-character-tools
npm install
npm run build
npm start

使用Claude Desktop

添加到您的Claude Desktop配置(claude_desktop_config.json):

{
  "mcpServers": {
    "char-tools": {
      "command": "npx",
      "args": ["mcp-character-tools"]
    }
  }
}

所有工具参考

看 sample_outputs.md 查看所有14+工具的输入和输出的完整示例。

工具 说明
count_letter 数一个特定的字母
count_letters 一次数多个字母
count_substring 统计子字符串出现次数
letter_frequency 获取频率分布
spell_word 分成角色
char_at 在索引处获取字符
nth_character 获取第n个字符(从1开始)
word_length 获取精确长度
reverse_text 反转文本,检测回文
compare_texts 比较两个文本
analyze_sentence 逐字分解
batch_count 跨多个单词计数
get_tricky_words 列出常见的误算单词
check_tricky_word 检查单词是否棘手

发展

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Development mode with auto-rebuild
npm run dev

测试

该项目包括对所有工具的全面测试:

npm test

测试文件:

  • tests/counting.test.ts -计数工具测试
  • tests/spelling.test.ts -拼写工具测试
  • tests/analysis.test.ts -分析工具测试
  • tests/tricky-words.test.ts -棘手的单词资源测试
  • tests/visualization.test.ts -可视化实用程序测试

许可证

麻省理工学院