Skip to main content
Glama
webreactiva-devs

MCP Character Counter

count-characters-in-text

Count total characters, letters, numbers, and symbols in any text. Analyze text length and structure for precise character-based insights.

Instructions

Count characters in a text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text whose characters you want to count

Implementation Reference

  • The handler function that executes the tool logic: counts total characters, without spaces, letters, numbers, and symbols in the input text, logs details, and returns a formatted analysis.
      async ({ text }) => {
        server.server.sendLoggingMessage({
          level: "info",
          data: text,
        });
    
        // Total character count
        const totalCount = text.length;
    
        // Character count without spaces
        const noSpacesCount = text.replace(/\s/g, "").length;
    
        // Letter count (a-z, A-Z)
        const lettersCount = (text.match(/[a-zA-Z]/g) || []).length;
    
        // Number count
        const numbersCount = (text.match(/[0-9]/g) || []).length;
    
        // Symbol count (everything that is not a letter, number, or space)
        const symbolsCount = (text.match(/[^a-zA-Z0-9\s]/g) || []).length;
    
        server.server.sendLoggingMessage({
          level: "info",
          data: {
            totalCount,
            noSpacesCount,
            lettersCount,
            numbersCount,
            symbolsCount,
          },
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Character analysis:
    - Total characters: ${totalCount}
    - Characters without spaces: ${noSpacesCount}
    - Letters: ${lettersCount}
    - Numbers: ${numbersCount}
    - Symbols: ${symbolsCount}`,
            },
          ],
        };
      }
  • Input schema for the tool using Zod: requires a 'text' string parameter.
    {
      text: z.string().describe("The text whose characters you want to count"),
    },
  • Registration of the 'count-characters-in-text' tool using server.tool, including name, description, input schema, and handler function.
    server.tool(
      "count-characters-in-text",
      "Count characters in a text",
      {
        text: z.string().describe("The text whose characters you want to count"),
      },
      async ({ text }) => {
        server.server.sendLoggingMessage({
          level: "info",
          data: text,
        });
    
        // Total character count
        const totalCount = text.length;
    
        // Character count without spaces
        const noSpacesCount = text.replace(/\s/g, "").length;
    
        // Letter count (a-z, A-Z)
        const lettersCount = (text.match(/[a-zA-Z]/g) || []).length;
    
        // Number count
        const numbersCount = (text.match(/[0-9]/g) || []).length;
    
        // Symbol count (everything that is not a letter, number, or space)
        const symbolsCount = (text.match(/[^a-zA-Z0-9\s]/g) || []).length;
    
        server.server.sendLoggingMessage({
          level: "info",
          data: {
            totalCount,
            noSpacesCount,
            lettersCount,
            numbersCount,
            symbolsCount,
          },
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Character analysis:
    - Total characters: ${totalCount}
    - Characters without spaces: ${noSpacesCount}
    - Letters: ${lettersCount}
    - Numbers: ${numbersCount}
    - Symbols: ${symbolsCount}`,
            },
          ],
        };
      }
    );
Behavior1/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 of behavioral disclosure. The description only states the basic function without mentioning any behavioral traits such as performance characteristics, error handling, or output format. This is inadequate for a tool with no annotation support.

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—a single, clear sentence that directly states the tool's purpose without any unnecessary words. It is front-loaded and efficiently communicates the core function, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It fails to address behavioral aspects, output format, or any contextual nuances. While the tool is simple, the description does not provide enough information for an agent to fully understand how to use it effectively beyond the basic function.

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 100%, with the schema fully documenting the single 'text' parameter. The description adds no additional meaning beyond what the schema provides, such as examples or edge cases. The baseline score of 3 reflects adequate coverage by the schema alone.

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 'Count characters in a text' clearly states the verb ('count') and resource ('characters in a text'), making the purpose immediately understandable. It's not a tautology since it elaborates beyond the tool name. However, with no sibling tools mentioned, there's no opportunity to differentiate from alternatives, preventing 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, prerequisites, or contextual constraints. It simply states what the tool does without any usage context, leaving the agent to infer applicability based solely on the tool name and description.

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

Related 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/webreactiva-devs/mcp-character-counter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server