Skip to main content
Glama
Aaryan-Kapoor

MCP Character Tools

Batch Count

batch_count
Read-onlyIdempotent

Count occurrences of a specific letter across multiple words simultaneously. Analyze word lists to identify letter frequency with case-sensitive options and get sorted results.

Instructions

Count a letter across multiple words at once.

Efficiently process a list of words.

Args:

  • words (string[]): Array of words to analyze

  • letter (string): The letter to count

  • case_sensitive (boolean): Match case exactly (default: false)

Returns: Results for each word, totals, sorted by count.

Example: batch_count(["strawberry", "raspberry", "blueberry"], "r") → individual and total counts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
wordsYesWords to analyze
letterYesThe letter to count
case_sensitiveNoMatch case exactly

Implementation Reference

  • Core implementation of batchCount function: processes array of words, counts specified letter in each using countLetter helper, computes totals, stats, and sorted results.
    export function batchCount(input: BatchCountInput): BatchCountOutput {
      const { words, letter, case_sensitive } = input;
      
      const results: BatchWordResult[] = words.map(word => {
        const result = countLetter({ text: word, letter, case_sensitive });
        return {
          word,
          count: result.count,
          positions: result.positions,
        };
      });
    
      const total_count = results.reduce((sum, r) => sum + r.count, 0);
      const words_with_letter = results.filter(r => r.count > 0).length;
      const words_without_letter = results.filter(r => r.count === 0).length;
      
      const sorted_by_count = [...results].sort((a, b) => b.count - a.count);
      
      const summary = `Analyzed ${words.length} word${words.length === 1 ? '' : 's'}: found ${total_count} total '${letter}'${total_count === 1 ? '' : 's'}. ${words_with_letter} word${words_with_letter === 1 ? '' : 's'} contain the letter, ${words_without_letter} do not.`;
    
      return {
        letter,
        case_sensitive,
        results,
        total_count,
        words_with_letter,
        words_without_letter,
        summary,
        sorted_by_count,
      };
    }
  • TypeScript interfaces defining input (BatchCountInput), per-word result (BatchWordResult), and output (BatchCountOutput) schemas for batch_count tool.
    export interface BatchCountInput {
      words: string[];
      letter: string;
      case_sensitive: boolean;
    }
    
    export interface BatchWordResult {
      word: string;
      count: number;
      positions: number[];
    }
    
    export interface BatchCountOutput {
      letter: string;
      case_sensitive: boolean;
      results: BatchWordResult[];
      total_count: number;
      words_with_letter: number;
      words_without_letter: number;
      summary: string;
      sorted_by_count: BatchWordResult[];
    }
  • src/index.ts:447-483 (registration)
    MCP server registration of 'batch_count' tool: defines Zod inputSchema, description, and async handler wrapper that calls batchCount and formats response.
    server.registerTool(
      "batch_count",
      {
        title: "Batch Count",
        description: `Count a letter across multiple words at once.
    
    Efficiently process a list of words.
    
    Args:
      - words (string[]): Array of words to analyze
      - letter (string): The letter to count
      - case_sensitive (boolean): Match case exactly (default: false)
    
    Returns: Results for each word, totals, sorted by count.
    
    Example: batch_count(["strawberry", "raspberry", "blueberry"], "r") → individual and total counts`,
        inputSchema: z.object({
          words: z.array(z.string().min(1)).min(1).describe("Words to analyze"),
          letter: z.string().length(1).describe("The letter to count"),
          case_sensitive: z.boolean().default(false).describe("Match case exactly"),
        }).strict(),
        annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
      },
      async (params) => {
        const result = batchCount({
          words: params.words,
          letter: params.letter,
          case_sensitive: params.case_sensitive,
        });
        const breakdown = result.results
          .map(r => `"${r.word}": ${r.count} at [${r.positions.join(', ')}]`)
          .join('\n');
        return {
          content: [{ type: "text" as const, text: `${result.summary}\n\n${breakdown}` }],
        };
      }
    );
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false, covering safety and idempotency. The description adds valuable context beyond annotations: it specifies the return format ('Results for each word, totals, sorted by count') and provides an example output structure, which helps the agent understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with purpose, efficiency note, parameter details, return description, and an example. It's appropriately sized but could be slightly more concise by integrating the Args section more seamlessly. Most sentences earn their place, though the parameter repetition is somewhat redundant given the schema.

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?

For a simple read-only tool with good annotations and no output schema, the description is mostly complete. It covers purpose, parameters, returns, and provides an example. The main gap is the lack of explicit sibling differentiation, but overall it gives sufficient context for an agent to use the tool effectively.

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%, so the schema already fully documents all parameters. The description repeats parameter information in the Args section but doesn't add meaningful semantics beyond what's in the schema (e.g., it doesn't explain edge cases or provide additional usage context for parameters). Baseline 3 is appropriate when schema does the heavy lifting.

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 tool's purpose with a specific verb ('Count') and resource ('a letter across multiple words at once'), distinguishing it from siblings like 'count_letter' (singular) and 'count_letters' (plural). The first sentence precisely defines the batch processing nature of this tool.

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

Usage Guidelines4/5

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

The description implies usage context through 'Efficiently process a list of words' and the example, suggesting this is for batch operations rather than single words. However, it doesn't explicitly state when to use this vs. alternatives like 'count_letter' or 'count_letters', nor does it provide exclusion criteria.

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/Aaryan-Kapoor/mcp-character-tools'

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