Skip to main content
Glama

find_all_substring_indices

Locate every occurrence of a substring within text, including overlapping matches, to identify all starting positions for precise text analysis.

Instructions

Find all starting indices where a substring appears (includes overlaps).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
substringYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'find_all_substring_indices' tool. It is decorated with @mcp.tool() for registration and implements the logic to find all starting indices of the substring in the text, including overlaps, using a loop with str.find.
    @mcp.tool()
    def find_all_substring_indices(
        text: Annotated[str, "Text to search in"],
        substring: Annotated[str, "Substring to find"]
    ) -> list[int]:
        """Find all starting indices where a substring appears (includes overlaps)."""
        if not substring:
            raise ValueError("substring cannot be empty")
        
        indices = []
        start = 0
        
        while True:
            index = text.find(substring, start)
            if index == -1:
                break
            indices.append(index)
            start = index + 1
        
        return indices
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'includes overlaps' which adds some context about the algorithm's behavior, but doesn't cover important aspects like case sensitivity, empty string handling, performance characteristics, or error conditions. This leaves significant gaps for a tool that performs string analysis.

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 perfectly concise - a single sentence that communicates the core functionality and a key behavioral detail ('includes overlaps'). Every word earns its place with zero waste or redundancy.

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's moderate complexity (string search algorithm), no annotations, and the presence of an output schema (which handles return values), the description is minimally adequate. It covers the basic purpose and a key behavioral detail, but lacks important context about edge cases, performance, and differentiation from sibling tools.

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?

The schema description coverage is 0%, so the description must compensate. While it doesn't explicitly explain the 'text' and 'substring' parameters, their meaning is strongly implied by the tool's purpose. The description adds value by specifying 'includes overlaps' which clarifies the algorithm's behavior beyond basic parameter semantics.

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 tool's purpose with a specific verb ('Find all starting indices') and resource ('where a substring appears'), and specifies it includes overlaps. However, it doesn't explicitly differentiate from sibling tools like find_nth_substring or find_regex_matches, which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like find_nth_substring, find_regex_matches, or extract_substrings. It mentions 'includes overlaps' which hints at behavior but doesn't constitute usage guidance for tool selection.

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