char-index-mcp
A Model Context Protocol (MCP) server providing character-level index-based string manipulation. Perfect for test code generation where precise character positioning matters.
This project was created with Claude AI.
๐ฏ Why This Exists
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 solves that problem.
โจ Features (12 Tools)
๐ Character & Substring Finding (4 tools)
find_nth_char- Find nth occurrence of a characterfind_all_char_indices- Find all indices of a characterfind_nth_substring- Find nth occurrence of a substringfind_all_substring_indices- Find all occurrences of a substring
โ๏ธ Splitting (1 tool)
split_at_indices- Split string at multiple positions
โ๏ธ String Modification (3 tools)
insert_at_index- Insert text at specific positiondelete_range- Delete characters in rangereplace_range- Replace range with new text
๐ ๏ธ Utilities (3 tools)
find_regex_matches- Find regex pattern matches with positionsextract_between_markers- Extract text between two markerscount_chars- Character statistics (total, letters, digits, etc.)
๐ฆ Batch Processing (1 tool)
extract_substrings- Extract one or more substrings (unified tool)
๐ Installation
Option 1: Using uvx (Recommended)
No installation required! Just configure and run:
Option 2: From PyPI
Option 3: From Source
๐ง Configuration
Claude Desktop
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Using uvx (Recommended)
Using pip install
Claude Code
Cursor
Add to ~/.cursor/mcp.json:
Using uvx (Recommended)
Using pip install
๐ Usage Examples
Finding Characters
Working with Substrings
String Manipulation
Splitting & Extracting
Pattern Matching
Extracting Text
๐งช Development
๐ฏ Use Cases
Test Code Generation: Generate strings with exact character counts
Data Processing: Split/extract data at precise positions
Text Formatting: Insert/delete/replace at specific indices
Pattern Analysis: Find and extract pattern matches with positions
LLM Response Parsing: Extract content between XML tags by position
๐ Example: Test Code Generation
๐ค Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Add tests for new functionality
Submit a pull request
๐ License
MIT License - see LICENSE file for details
๐ Related Projects
mcp-character-counter - Character counting & analysis
mcp-wordcounter - Word & character counting for files
text-master-mcp - Comprehensive text processing toolkit
๐ฎ Contact
For issues, questions, or suggestions, please open an issue on GitHub.
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.
This server cannot be installed