Skip to main content

A Model Context Protocol server for character-level index-based string manipulation

Project description

char-index-skill

Character-level index-based string manipulation as a Claude Code Skill (plugin).

LLMs generate text token-by-token and struggle with exact character counting. This skill provides precise index-based tools for test code generation, string parsing, and position-critical tasks.

License: MIT

Evolved from char-index-mcp. The MCP server is still supported — see MCP Server section.

Installation

As a Claude Code Plugin (Recommended)

# Install the plugin
claude plugin install char-index-skill

Or clone and use directly:

git clone https://github.com/agent-hanju/char-index-skill.git

The skill is in skills/char-index-skill/ and will be automatically available in Claude Code.

Usage

Claude will automatically invoke the skill when you need character-level string operations. You can also call it explicitly with /char-index-skill.

All operations are available via:

python ${CLAUDE_SKILL_DIR}/scripts/char_ops.py <command> [options]

See SKILL.md for the full command reference.

Features (11 Operations)

Finding (4)

  • find-nth-char - Find nth occurrence of a character
  • find-all-chars - Find all indices of a character
  • find-nth-substring - Find nth occurrence of a substring
  • find-all-substrings - Find all occurrences of a substring

Splitting & Extraction (4)

  • split-at - Split string at multiple positions
  • extract - Extract substring by range
  • extract-between - Extract text between two markers
  • extract-batch - Extract multiple substrings by index ranges

Modification (3)

  • insert - Insert text at specific position
  • delete - Delete characters in range
  • replace - Replace range with new text

Utilities (1)

  • count - Character statistics (total, letters, digits, etc.)

Quick Examples

# Find 3rd 'l'
python ${CLAUDE_SKILL_DIR}/scripts/char_ops.py find-nth-char \
  --text "hello world" --char "l" --n 3
# {"index": 9}

# Split at positions
python ${CLAUDE_SKILL_DIR}/scripts/char_ops.py split-at \
  --text "hello world" --indices "2,5,8"
# {"parts": ["he", "llo", " wo", "rld"]}

# Extract between markers
python ${CLAUDE_SKILL_DIR}/scripts/char_ops.py extract-between \
  --text "<tag>content</tag>" --start-marker "<tag>" --end-marker "</tag>"
# {"content": "content", ...}

# Count characters
python ${CLAUDE_SKILL_DIR}/scripts/char_ops.py count --text "Hello World!"
# {"total": 12, "letters": 10, "digits": 0, "spaces": 1, "special": 1}

See examples.md for more practical examples.

Key Points

  • 0-indexed: All positions start from 0
  • 1-based occurrence: find-nth-* uses --n 1 for first occurrence
  • Negative indices: -1 = last char, -5 = 5th from end
  • Range format: [start, end) - start inclusive, end exclusive
  • Unicode safe: Each Unicode character = 1 position
  • JSON output: All operations return JSON for easy parsing

Use Cases

  1. Test Code Generation - Generate strings with exact character counts
  2. Data Processing - Split/extract data at precise positions
  3. Text Formatting - Insert/delete/replace at specific indices
  4. LLM Response Parsing - Extract content between XML tags by position

Project Structure

char-index-skill/
├── .claude-plugin/plugin.json     # Plugin manifest
├── skills/
│   └── char-index-skill/
│       ├── SKILL.md               # Skill definition
│       ├── examples.md            # Usage examples
│       └── scripts/char_ops.py    # Implementation (11 operations)
├── char_index_mcp/                # MCP server (legacy)
│   ├── server.py
│   ├── char_ops.py                # Synced copy
│   └── tests/
├── pyproject.toml                 # MCP package config
├── README.md
└── LICENSE

Development

git clone https://github.com/agent-hanju/char-index-skill.git
cd char-index-skill

python -m venv .venv
.venv/Scripts/activate  # or source .venv/bin/activate

pip install -e .
pytest char_index_mcp/tests/ -v
ruff check .
mypy char_index_mcp/

MCP Server (Legacy)

The char-index-mcp package provides the same 11 operations as an MCP server for integration with Claude Desktop, Cursor, and other MCP clients. This is maintained for backward compatibility but the Claude Code Skill is the recommended approach.

# Install
pip install char-index-mcp

# Or run directly
uvx char-index-mcp

Configuration for Claude Desktop (claude_desktop_config.json):

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

PyPI Python

License

MIT License - see LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

char_index_mcp-0.3.0.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

char_index_mcp-0.3.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file char_index_mcp-0.3.0.tar.gz.

File metadata

  • Download URL: char_index_mcp-0.3.0.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for char_index_mcp-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8f96411704c6e3629ff29e4444c043395c26dde923be9c7cdb33c9c63ab07075
MD5 7f6f11e819cfe9e32aeed55f60f791fd
BLAKE2b-256 497c4f0269ff52241c5fa5cc4c378ac37605d501c7088647c81a6f9609273fea

See more details on using hashes here.

File details

Details for the file char_index_mcp-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: char_index_mcp-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for char_index_mcp-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f4281dbb092f6e30b437da5693abf0945a6323666fa38d6f340f74ad54af774
MD5 1b8ed68b2e0d4e6363611cf7ea140e3b
BLAKE2b-256 786cd6e12f4d3bf5a26aa6114ea4e6a63055f30484ede5f21a96c5658453f6a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page