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())
        }

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