Skip to main content
Glama

count_chars

Count character statistics in text, including totals, letters, digits, spaces, and special characters. Analyze text composition for precise character-level operations.

Instructions

Count character statistics. Returns dict with total, without_spaces, letters, digits, spaces, special.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes

Implementation Reference

  • The handler function for the 'count_chars' tool. It takes a text string and returns a dictionary with character statistics: total length, length without spaces, counts of letters, digits, spaces, and special characters.
    @mcp.tool()
    def count_chars(
        text: Annotated[str, "Text to analyze"]
    ) -> dict:
        """Count character statistics. Returns dict with total, without_spaces, letters, digits, spaces, special."""
        return {
            "total": len(text),
            "without_spaces": len(text.replace(" ", "")),
            "letters": sum(1 for c in text if c.isalpha()),
            "digits": sum(1 for c in text if c.isdigit()),
            "spaces": sum(1 for c in text if c.isspace()),
            "special": sum(1 for c in text if not c.isalnum() and not c.isspace())
        }
Behavior3/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 discloses the return format ('Returns dict with total, without_spaces, letters, digits, spaces, special'), which is useful behavioral context. However, it lacks details on edge cases (e.g., empty strings, Unicode handling), performance implications, or error conditions. The description doesn't contradict annotations since none exist.

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 and front-loaded: a single sentence that directly states the purpose and return value. Every word earns its place with no redundancy or fluff. It efficiently communicates core functionality 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's low complexity (single input, statistical output), no annotations, and no output schema, the description is minimally adequate. It covers the basic action and return structure but lacks details on usage context, parameter nuances, or behavioral specifics. For a simple tool, this might suffice, but gaps remain in guiding effective agent use.

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

Parameters4/5

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

The description adds no parameter semantics beyond the input schema, which has 0% description coverage and only documents 'text' as a required string parameter. However, with only 1 parameter, the baseline is 4 as per the rules (0 params = baseline 4, adjusted for minimal parameter count). The description implies the parameter is text to analyze but doesn't elaborate on format or constraints.

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: 'Count character statistics' specifies the verb (count) and resource (character statistics). It distinguishes from siblings like 'find_all_char_indices' or 'find_regex_matches' by focusing on statistical counting rather than searching or manipulation. However, it doesn't explicitly differentiate from all siblings (e.g., 'extract_substrings' might also involve counting in some contexts).

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. It doesn't mention scenarios where counting characters is preferred over other text analysis tools (e.g., 'find_all_char_indices' for positional data or 'extract_between_markers' for extraction). There's no indication of prerequisites, limitations, or comparative context with sibling tools.

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