Skip to main content
Glama

insert_at_index

Insert text at a specific character position in a string without replacing existing content. Supports positive and negative indices for precise string manipulation.

Instructions

Insert text at index position without replacing. Supports negative indices.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
indexYes
insertionYes

Implementation Reference

  • The handler function for the 'insert_at_index' tool. It inserts the specified text at the given index position in the original text, supporting negative indices (from the end). The function signature includes input schema via Annotated types.
    @mcp.tool() def insert_at_index( text: Annotated[str, "Original text"], index: Annotated[int, "Position to insert at (negative = from end)"], insertion: Annotated[str, "Text to insert"] ) -> str: """Insert text at index position without replacing. Supports negative indices.""" if index < 0: index = max(0, len(text) + index + 1) return text[:index] + insertion + text[index:]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/agent-hanju/char-index-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server