A Model Context Protocol (MCP) server providing character-level index-based string manipulation. Perfect for test code generation where precise character positioning matters. LLMs generate text token-by-token and struggle with exact character counting. When generating test code with specific length requirements or validating string positions, you need precise index-based tools. This MCP server sol
Add this skill
npx mdskills install agent-hanju/char-index-mcpComprehensive character-level string manipulation toolkit with 12 well-documented tools solving a real LLM limitation
1# char-index-mcp23A Model Context Protocol (MCP) server providing **character-level index-based string manipulation**. Perfect for test code generation where precise character positioning matters.45[](https://smithery.ai/server/char-index-mcp)6[](https://opensource.org/licenses/MIT)7[](https://pypi.org/project/char-index-mcp/)8[](https://pypi.org/project/char-index-mcp/)910> This project was created with Claude AI.1112## ๐ฏ Why This Exists1314LLMs generate text token-by-token and struggle with exact character counting. When generating test code with specific length requirements or validating string positions, you need precise index-based tools. This MCP server solves that problem.1516## โจ Features (12 Tools)1718### ๐ Character & Substring Finding (4 tools)19- `find_nth_char` - Find nth occurrence of a character20- `find_all_char_indices` - Find all indices of a character21- `find_nth_substring` - Find nth occurrence of a substring22- `find_all_substring_indices` - Find all occurrences of a substring2324### โ๏ธ Splitting (1 tool)25- `split_at_indices` - Split string at multiple positions2627### โ๏ธ String Modification (3 tools)28- `insert_at_index` - Insert text at specific position29- `delete_range` - Delete characters in range30- `replace_range` - Replace range with new text3132### ๐ ๏ธ Utilities (3 tools)33- `find_regex_matches` - Find regex pattern matches with positions34- `extract_between_markers` - Extract text between two markers35- `count_chars` - Character statistics (total, letters, digits, etc.)3637### ๐ฆ Batch Processing (1 tool)38- `extract_substrings` - Extract one or more substrings (unified tool)3940## ๐ Installation4142### Option 1: Using uvx (Recommended)4344No installation required! Just configure and run:4546```bash47# Test it works48uvx char-index-mcp --help49```5051### Option 2: From PyPI5253```bash54pip install char-index-mcp55```5657### Option 3: From Source5859```bash60git clone https://github.com/agent-hanju/char-index-mcp.git61cd char-index-mcp62pip install -e .63```6465## ๐ง Configuration6667### Claude Desktop6869**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`7071**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`7273#### Using uvx (Recommended)7475```json76{77 "mcpServers": {78 "char-index": {79 "command": "uvx",80 "args": ["char-index-mcp"]81 }82 }83}84```8586#### Using pip install8788```json89{90 "mcpServers": {91 "char-index": {92 "command": "char-index-mcp"93 }94 }95}96```9798### Claude Code99100```bash101# Using uvx (recommended)102claude mcp add char-index '{"command":"uvx","args":["char-index-mcp"]}'103104# Using pip install105claude mcp add char-index '{"command":"char-index-mcp"}'106```107108### Cursor109110Add to `~/.cursor/mcp.json`:111112#### Using uvx (Recommended)113114```json115{116 "mcpServers": {117 "char-index": {118 "command": "uvx",119 "args": ["char-index-mcp"]120 }121 }122}123```124125#### Using pip install126127```json128{129 "mcpServers": {130 "char-index": {131 "command": "char-index-mcp"132 }133 }134}135```136137## ๐ Usage Examples138139### Finding Characters140```python141# Find 3rd occurrence of 'l'142find_nth_char("hello world", "l", 3) # Returns: 9143144# Find all occurrences of 'l'145find_all_char_indices("hello world", "l") # Returns: [2, 3, 9]146```147148### Working with Substrings149```python150# Find 2nd "hello"151find_nth_substring("hello hello world", "hello", 2) # Returns: 6152153# Find all occurrences154find_all_substring_indices("hello hello world", "hello") # Returns: [0, 6]155```156157### String Manipulation158```python159# Insert comma after "hello"160insert_at_index("hello world", 5, ",") # Returns: "hello, world"161162# Delete " world"163delete_range("hello world", 5, 11) # Returns: "hello"164165# Replace "world" with "Python"166replace_range("hello world", 6, 11, "Python") # Returns: "hello Python"167```168169### Splitting & Extracting170```python171# Split at multiple positions172split_at_indices("hello world", [2, 5, 8]) # Returns: ["he", "llo", " wo", "rld"]173174# Extract single character175extract_substrings("hello", [{"start": 1, "end": 2}])176# Returns: [{"start": 1, "end": 2, "substring": "e", "length": 1}]177178# Batch extraction179extract_substrings("hello world", [180 {"start": 0, "end": 5},181 {"start": 6, "end": 11}182])183# Returns: [184# {"start": 0, "end": 5, "substring": "hello", "length": 5},185# {"start": 6, "end": 11, "substring": "world", "length": 5}186# ]187```188189### Pattern Matching190```python191# Find all numbers with their positions192find_regex_matches("test123abc456", r"\d+")193# Returns: [194# {"start": 4, "end": 7, "match": "123"},195# {"start": 10, "end": 13, "match": "456"}196# ]197```198199### Extracting Text200```python201# Extract content between markers202extract_between_markers("start[content]end", "[", "]", 1)203# Returns: {204# "content": "content",205# "content_start": 6,206# "content_end": 13,207# "full_start": 5,208# "full_end": 14209# }210```211212## ๐งช Development213214```bash215# Clone the repository216git clone https://github.com/agent-hanju/char-index-mcp.git217cd char-index-mcp218219# Install in development mode220pip install -e ".[dev]"221222# Run tests223pytest224225# Run with coverage226pytest --cov=char_index_mcp --cov-report=term-missing227```228229## ๐ฏ Use Cases2302311. **Test Code Generation**: Generate strings with exact character counts2322. **Data Processing**: Split/extract data at precise positions2333. **Text Formatting**: Insert/delete/replace at specific indices2344. **Pattern Analysis**: Find and extract pattern matches with positions2355. **LLM Response Parsing**: Extract content between XML tags by position236237## ๐ Example: Test Code Generation238239```python240# Ask Claude: "Generate a test string that's exactly 100 characters long"241# Claude can use count_chars() to verify the exact length242243# Ask: "Find where the 5th comma is in this CSV line"244# Claude can use find_nth_char(csv_line, ",", 5)245246# Ask: "Split this string at characters 10, 25, and 50"247# Claude can use split_at_indices(text, [10, 25, 50])248249# Ask: "Extract the text between the 2nd <thinking> and </thinking> tags"250# Claude can use extract_between_markers(text, "<thinking>", "</thinking>", 2)251```252253## ๐ค Contributing254255Contributions are welcome! Please:2562571. Fork the repository2582. Create a feature branch2593. Add tests for new functionality2604. Submit a pull request261262## ๐ License263264MIT License - see LICENSE file for details265266## ๐ Related Projects267268- [mcp-character-counter](https://github.com/webreactiva-devs/mcp-character-counter) - Character counting & analysis269- [mcp-wordcounter](https://github.com/qpd-v/mcp-wordcounter) - Word & character counting for files270- [text-master-mcp](https://github.com/very99/text-master-mcp) - Comprehensive text processing toolkit271272## ๐ฎ Contact273274For issues, questions, or suggestions, please open an issue on GitHub.275276---277278**Note**: This is the first MCP server specifically designed for index-based string manipulation. All other text MCP servers focus on counting, case conversion, or encoding - not precise character positioning.279
Full transparency โ inspect the skill content before installing.