Token导航 LogoToken导航TokenDH.com
Char Index MCP logo
开发工具stdio官方级别未说明来源级核验

Char Index MCP

MCP Server

一款提供字符级索引操作的MCP服务器,用于精确的字符串处理和测试代码生成。

工具数

12

提示词数

0

GitHub Stars

2

资源数

0
PythonClaude批量处理ClaudeCursor

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

agent-hanju

提供方

agent-hanju

最后核验

2026/5/17 20:20

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uvx char-index-mcp --help

详细介绍

char索引mcp(已存档)

此存储库已存档。 该项目已转移到 字符索引技能,现在作为Claude Code Skill插件提供,并继续支持MCP服务器。 技能和MCP服务器的未来更新(char-index-mcp)将从新存储库中发布。

______________________________________________________________________

模型上下文协议(MCP)服务器提供 基于字符级索引的字符串操作非常适合在需要精确字符定位的情况下生成测试代码。

](https://smithery.ai/server/char-index-mcp) ![License: MIT](https://opensource.org/licenses/MIT) ![PyPI](https://pypi.org/project/char-index-mcp/) ![Python](https://pypi.org/project/char-index-mcp/)

🎯 为什么存在

LLM逐个生成文本令牌,并努力进行精确的字符计数。当生成具有特定长度要求的测试代码或验证字符串位置时,您需要精确的基于索引的工具。这个MCP服务器解决了这个问题。

✨ 功能(12个工具)

🔍 字符和子字符串查找(4个工具)

  • find_nth_char -查找字符的第n次出现
  • find_all_char_indices -查找角色的所有索引
  • find_nth_substring -查找子字符串的第n次出现
  • find_all_substring_indices -查找子字符串的所有出现

✂️ 拆分(1个工具)

  • split_at_indices -在多个位置拆分字符串

✏️ 字符串修改(3个工具)

  • insert_at_index -在特定位置插入文本
  • delete_range -删除范围内的字符
  • replace_range -用新文本替换范围

🛠️ 实用程序(3个工具)

  • find_regex_matches -查找与位置匹配的正则表达式模式
  • extract_between_markers -提取两个标记之间的文本
  • count_chars -字符统计(总数、字母、数字等)

📦 批处理(1个工具)

  • extract_substrings -提取一个或多个子字符串(统一工具)

🚀 安装

选项1:使用uvx(推荐)

无需安装!只需配置并运行:

# Test it works
uvx char-index-mcp --help

选项2:来自PyPI

pip install char-index-mcp

选项3:来源

git clone https://github.com/agent-hanju/char-index-mcp.git
cd char-index-mcp
pip install -e .

🔧 配置

克劳德桌面

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

视窗: %APPDATA%\Claude\claude_desktop_config.json

使用uvx(推荐)

{
  "mcpServers": {
    "char-index": {
      "command": "uvx",
      "args": ["char-index-mcp"]
    }
  }
}

使用pip安装

{
  "mcpServers": {
    "char-index": {
      "command": "char-index-mcp"
    }
  }
}

克劳德代码

# Using uvx (recommended)
claude mcp add char-index '{"command":"uvx","args":["char-index-mcp"]}'

# Using pip install
claude mcp add char-index '{"command":"char-index-mcp"}'

光标

添加 ~/.cursor/mcp.json:

使用uvx(推荐)

{
  "mcpServers": {
    "char-index": {
      "command": "uvx",
      "args": ["char-index-mcp"]
    }
  }
}

使用pip安装

{
  "mcpServers": {
    "char-index": {
      "command": "char-index-mcp"
    }
  }
}

📖 用法示例

查找角色

# Find 3rd occurrence of 'l'
find_nth_char("hello world", "l", 3)  # Returns: 9

# Find all occurrences of 'l'
find_all_char_indices("hello world", "l")  # Returns: [2, 3, 9]

使用子环

# Find 2nd "hello"
find_nth_substring("hello hello world", "hello", 2)  # Returns: 6

# Find all occurrences
find_all_substring_indices("hello hello world", "hello")  # Returns: [0, 6]

字符串操作

# Insert comma after "hello"
insert_at_index("hello world", 5, ",")  # Returns: "hello, world"

# Delete " world"
delete_range("hello world", 5, 11)  # Returns: "hello"

# Replace "world" with "Python"
replace_range("hello world", 6, 11, "Python")  # Returns: "hello Python"

拆分和提取

# Split at multiple positions
split_at_indices("hello world", [2, 5, 8])  # Returns: ["he", "llo", " wo", "rld"]

# Extract single character
extract_substrings("hello", [{"start": 1, "end": 2}])
# Returns: [{"start": 1, "end": 2, "substring": "e", "length": 1}]

# Batch extraction
extract_substrings("hello world", [
    {"start": 0, "end": 5},
    {"start": 6, "end": 11}
])
# Returns: [
#   {"start": 0, "end": 5, "substring": "hello", "length": 5},
#   {"start": 6, "end": 11, "substring": "world", "length": 5}
# ]

模式匹配

# Find all numbers with their positions
find_regex_matches("test123abc456", r"\d+")
# Returns: [
#   {"start": 4, "end": 7, "match": "123"},
#   {"start": 10, "end": 13, "match": "456"}
# ]

提取文本

# Extract content between markers
extract_between_markers("start[content]end", "[", "]", 1)
# Returns: {
#   "content": "content",
#   "content_start": 6,
#   "content_end": 13,
#   "full_start": 5,
#   "full_end": 14
# }

🧪 发展

# Clone the repository
git clone https://github.com/agent-hanju/char-index-mcp.git
cd char-index-mcp

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=char_index_mcp --cov-report=term-missing

🎯 用例

  1. 测试代码生成:生成具有精确字符数的字符串
  2. 数据处理:在精确位置分割/提取数据
  3. 文本格式:在特定索引处插入/删除/替换
  4. 模式分析:查找并提取与位置匹配的模式
  5. LLM响应解析:按位置提取XML标记之间的内容

📝 示例:测试代码生成

# Ask Claude: "Generate a test string that's exactly 100 characters long"
# Claude can use count_chars() to verify the exact length

# Ask: "Find where the 5th comma is in this CSV line"
# Claude can use find_nth_char(csv_line, ",", 5)

# Ask: "Split this string at characters 10, 25, and 50"
# Claude can use split_at_indices(text, [10, 25, 50])

# Ask: "Extract the text between the 2nd  and  tags"
# Claude can use extract_between_markers(text, "", "", 2)

🤝 贡献

欢迎投稿!拜托:

  1. 分叉存储库
  2. 创建要素分支
  3. 添加新功能的测试
  4. 提交拉取请求

📄 许可证

MIT许可证-有关详细信息,请参阅许可证文件

🔗 相关项目

📮 联系

有关问题、疑问或建议,请在GitHub上打开问题。

______________________________________________________________________

备注:这是第一个专门为基于索引的字符串操作设计的MCP服务器。所有其他文本MCP服务器都专注于计数、大小写转换或编码,而不是精确的字符定位。

目录标签

目录标签

PythonClaude批量处理字符操作本地部署测试代码生成字符串处理文本分析

支持客户端

ClaudeCursor

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

12

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononeremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP