Skip to main content
Glama

split_at_indices

Split text at specified character positions. Automatically sorts and removes duplicate indices to ensure precise segmentation for position-based text operations.

Instructions

Split text at exact index positions. Indices auto-sorted and deduplicated.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
indicesYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'split_at_indices' tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Takes text and list of indices, sorts/deduplicates/validates indices, and splits the text into parts at those positions, returning list of strings.
    @mcp.tool()
    def split_at_indices(
        text: Annotated[str, "Text to split"],
        indices: Annotated[list[int], "Split positions (auto-sorted & deduplicated)"]
    ) -> list[str]:
        """Split text at exact index positions. Indices auto-sorted and deduplicated."""
        if not indices:
            return [text]
        
        # Sort and remove duplicates
        sorted_indices = sorted(set(indices))
        
        # Validate
        for idx in sorted_indices:
            if idx < 0 or idx > len(text):
                raise ValueError(f"Index {idx} out of bounds [0, {len(text)}]")
        
        result = []
        start = 0
        
        for idx in sorted_indices:
            result.append(text[start:idx])
            start = idx
        
        result.append(text[start:])
        
        return result
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that indices are 'auto-sorted and deduplicated', which is a useful behavioral trait beyond basic splitting. However, it doesn't cover other aspects like error handling (e.g., out-of-bounds indices), return format, or whether the operation is read-only or modifies data, leaving gaps for a tool with mutation implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with two short sentences that directly state the tool's function and a key behavioral trait. Every word earns its place, and it's front-loaded with the core purpose, making it efficient and easy to parse without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema, the description doesn't need to explain return values. However, with no annotations, 0% schema coverage, and two parameters, the description is minimal. It covers the basic action and one behavioral aspect but lacks details on parameter usage, error cases, or interaction with siblings, making it adequate but incomplete for full context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It implies parameters 'text' and 'indices' but doesn't add meaning beyond the schema's titles. No details on index semantics (e.g., zero-based, inclusive/exclusive) or text handling are provided. The baseline is 3 since schema coverage is low, but the description doesn't adequately fill the gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('split') and resource ('text'), specifying the action occurs 'at exact index positions'. It distinguishes from siblings like 'extract_substrings' or 'delete_range' by focusing on splitting rather than extraction or deletion. However, it doesn't explicitly contrast with all siblings, such as 'insert_at_index' which also involves indices.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives is provided. The description mentions indices are 'auto-sorted and deduplicated', which hints at usage but doesn't specify scenarios like splitting text for processing segments versus using 'extract_between_markers' for marker-based extraction. It lacks clear when/when-not instructions or named alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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