char-index-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@char-index-mcp find the 2nd occurrence of 'e' in 'hello there everyone'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
char-index-mcp (Archived)
This repository is archived. This project has moved to char-index-skill, now available as a Claude Code Skill plugin with continued MCP server support.
Future updates to both the Skill and the MCP server (
char-index-mcp) will be published from the new repository.
A Model Context Protocol (MCP) server providing character-level index-based string manipulation. Perfect for test code generation where precise character positioning matters.
๐ฏ 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.
Related MCP server: MCP Character Tools
โจ 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:
# Test it works
uvx char-index-mcp --helpOption 2: From PyPI
pip install char-index-mcpOption 3: From Source
git clone https://github.com/agent-hanju/char-index-mcp.git
cd char-index-mcp
pip install -e .๐ง Configuration
Claude Desktop
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Using uvx (Recommended)
{
"mcpServers": {
"char-index": {
"command": "uvx",
"args": ["char-index-mcp"]
}
}
}Using pip install
{
"mcpServers": {
"char-index": {
"command": "char-index-mcp"
}
}
}Claude Code
# 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
Add to ~/.cursor/mcp.json:
Using uvx (Recommended)
{
"mcpServers": {
"char-index": {
"command": "uvx",
"args": ["char-index-mcp"]
}
}
}Using pip install
{
"mcpServers": {
"char-index": {
"command": "char-index-mcp"
}
}
}๐ Usage Examples
Finding Characters
# 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]Working with Substrings
# 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]String Manipulation
# 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"Splitting & Extracting
# 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}
# ]Pattern Matching
# 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"}
# ]Extracting Text
# 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
# }๐งช Development
# 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๐ฏ 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
# 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 <thinking> and </thinking> tags"
# Claude can use extract_between_markers(text, "<thinking>", "</thinking>", 2)๐ค 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.
Available Tools
12 toolscount_charsB
Count character statistics. Returns dict with total, without_spaces, letters, digits, spaces, special.
Inputs: text (required).
delete_rangeC
Delete characters in range [start, end).
Inputs: text (required), start (required), end (required). Returns: result
extract_between_markersC
Extract content between markers with positions. Returns dict with content and position info.
Inputs: text (required), start_marker (required), end_marker (required), occurrence.
extract_substringsB
Extract substrings by index ranges. Supports negative indices and omitting end. Returns list of {start, end, substring, length} dicts.
Inputs: text (required), ranges (required). Returns: result
find_all_char_indicesA
Find all indices where a character appears. Returns empty list if not found.
Inputs: text (required), char (required). Returns: result
find_all_substring_indicesB
Find all starting indices where a substring appears (includes overlaps).
Inputs: text (required), substring (required). Returns: result
find_nth_charA
Find index of nth occurrence of a character. Returns -1 if not found.
Inputs: text (required), char (required), n. Returns: result
find_nth_substringA
Find starting index of nth occurrence of a substring. Returns -1 if not found.
Inputs: text (required), substring (required), n. Returns: result
find_regex_matchesB
Find all regex matches with positions. Returns list of {start, end, match} dicts.
Inputs: text (required), pattern (required). Returns: result
insert_at_indexC
Insert text at index position without replacing. Supports negative indices.
Inputs: text (required), index (required), insertion (required). Returns: result
replace_rangeB
Replace characters in range [start, end) with new text.
Inputs: text (required), start (required), end (required), replacement (required). Returns: result
split_at_indicesB
Split text at exact index positions. Indices auto-sorted and deduplicated.
Inputs: text (required), indices (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 12 tools
Each tool has a clearly distinct purpose with no overlap: character counting, deletion, extraction, finding indices, regex matching, insertion, replacement, and splitting. The descriptions precisely differentiate operations like find_all_char_indices vs find_nth_char, and extract_between_markers vs extract_substrings.
All tools follow a consistent snake_case verb_noun pattern (e.g., count_chars, delete_range, extract_between_markers). The naming is predictable and readable throughout, with verbs like count, delete, extract, find, insert, replace, and split consistently applied.
12 tools are well-scoped for a character/index manipulation server, covering essential operations without bloat. Each tool earns its place by addressing specific needs like character statistics, range operations, substring extraction, and pattern matching.
The toolset provides complete coverage for text manipulation tasks: counting, insertion, deletion, replacement, extraction, finding indices (both character and substring), regex matching, and splitting. There are no obvious gaps; agents can perform a full lifecycle of operations on text data.
Maintenance
Related MCP Connectors
Exact text tools for AI agents: unified diff, patch apply, regex testing, grapheme counting.
Exact character/word counting, reversal, palindrome checks, indexing, sorting; Unicode-safe.
300+ deterministic data utilities for AI agents: validate, normalize, parse, match, redact.
Token counting, RAG chunking, truncation, HTML to Markdown and JSON repair
Related MCP Servers
- AlicenseAqualityNot gradedmaintenanceEnables agents to quickly find and edit code in a codebase with surgical precision. Find symbols, edit them everywhere with tools for reading code blocks, searching/replacing text, and making precise line-based modifications.311 npm-
- AlicenseAqualityDmaintenanceProvides 14+ character-level text analysis tools that give LLMs the ability to accurately count letters, analyze individual characters, and work with text at the character levelโovercoming tokenization limitations.143MIT
- AlicenseBqualityBmaintenanceEnables LLMs to efficiently read, write, and refactor code using precise AST-based operations, reducing token usage and context window waste.25238 npm3MIT
- AlicenseNot gradedqualityDmaintenanceEnables precise code extraction from 30+ languages using tree-sitter parsing, allowing AI assistants to retrieve functions, classes, and code snippets with accurate line numbers.19 PyPI8MIT