Skip to main content
Glama
IntelagentStudios

Intelagent MCP Template

word_count

Count words and characters in text strings. Optionally calculate unique word counts for text analysis.

Instructions

Count words and characters in a string. Optionally count unique words.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to analyse
uniqueNoCount unique words only (default: false)

Implementation Reference

  • The logic implementation of the word_count tool.
    wordCount(input: WordCountInput): WordCountResult {
      const words = input.text.trim().split(/\s+/).filter(Boolean);
      const result: WordCountResult = {
        text: input.text,
        wordCount: words.length,
        characterCount: input.text.length,
      };
      if (input.unique) {
        result.uniqueWords = new Set(words.map((w) => w.toLowerCase())).size;
      }
      return result;
    }
  • Type definitions for the input and output of the word_count tool.
    /** Input for the word_count tool. */
    export interface WordCountInput {
      text: string;
      /** Count unique words only. Defaults to false. */
      unique?: boolean;
    }
    
    /** Result from the word_count tool. */
    export interface WordCountResult {
      text: string;
      wordCount: number;
      characterCount: number;
      uniqueWords?: number;
    }
  • Tool registration and handler invocation for word_count.
    {
      name: 'word_count',
      description: 'Count words and characters in a string. Optionally count unique words.',
      inputSchema: {
        type: 'object',
        properties: {
          text: { type: 'string', description: 'The text to analyse' },
          unique: { type: 'boolean', description: 'Count unique words only (default: false)' },
        },
        required: ['text'],
      },
      handler: async (args) => {
        return service.wordCount({
          text: args.text as string,
          unique: args.unique as boolean | undefined,
        });
      },
    },
Behavior3/5

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

No annotations provided, so description carries full burden. It discloses core functionality (counting words/characters) and the unique word option, but omits details about word tokenization rules, case sensitivity, or idempotency/safety characteristics.

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?

Extremely efficient two-sentence structure. First sentence establishes primary function; second sentence covers optional behavior. No redundant or filler content—every word earns its place.

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 low complexity (2 primitive parameters, no nested objects) and absence of output schema, the description adequately covers intent but would benefit from specifying the return structure (e.g., object with word_count and char_count fields).

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 coverage is 100% with clear descriptions for both 'text' and 'unique' parameters. Description adds minimal semantic value beyond schema, only mapping 'optionally count unique words' to the boolean flag, which aligns with baseline expectations for fully documented schemas.

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?

Description clearly states the specific action (count) and resources (words, characters) with scope (unique words optional). Distinct from sibling 'reverse_string' (transformation) and 'server_info' (metadata).

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?

No explicit when-to-use or when-not-to-use guidance provided. However, the tool's purpose is self-evident from the name and description, providing implied usage context without explicit alternative recommendations.

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/IntelagentStudios/intelagent-mcp-template'

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