Skip to main content
Glama

find_all_char_indices

Locate every occurrence of a specific character within a text string. Returns a list of positions for precise character-level indexing and text manipulation.

Instructions

Find all indices where a character appears. Returns empty list if not found.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes
charYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool() implements the find_all_char_indices tool. It takes text and a single character, validates the character length, and returns a list of all indices where the character appears using enumerate and list comprehension.
    @mcp.tool()
    def find_all_char_indices(
        text: Annotated[str, "Text to search in"],
        char: Annotated[str, "Single character to find"]
    ) -> list[int]:
        """Find all indices where a character appears. Returns empty list if not found."""
        if len(char) != 1:
            raise ValueError("char must be a single character")
        
        return [i for i, c in enumerate(text) if c == char]
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions the return behavior ('Returns empty list if not found'), which is helpful, but lacks details on performance (e.g., case sensitivity, handling of multiple characters, or error conditions). For a tool with no annotations, this leaves significant behavioral gaps.

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 two short sentences that are front-loaded with the core purpose and include essential behavioral info. Every sentence earns its place by stating the action and the return behavior, with zero waste or redundancy.

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

Completeness4/5

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

Given the tool's low complexity (2 parameters, no nested objects) and the presence of an output schema (which handles return values), the description is mostly complete. It covers the purpose and basic behavior, but could improve by addressing parameter semantics or usage guidelines to be fully comprehensive.

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. It doesn't add any meaning beyond the schema's parameter names ('text' and 'char'), such as explaining what 'char' represents (e.g., a single character) or constraints. With 0% coverage and no param info in the description, it meets the baseline but doesn't enhance understanding.

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

Purpose5/5

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

The description clearly states the verb ('Find all indices') and resource ('where a character appears'), specifying the exact operation. It distinguishes from siblings like 'find_all_substring_indices' (for substrings) and 'find_nth_char' (for single occurrence), making the purpose specific and differentiated.

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

Usage Guidelines3/5

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

The description implies usage by stating it 'Returns empty list if not found,' suggesting it's for checking character presence. However, it doesn't explicitly say when to use this tool versus alternatives like 'find_all_substring_indices' for substrings or 'count_chars' for counting, leaving the context somewhat implied rather than clearly defined.

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