Skip to main content
Glama
Aaryan-Kapoor

MCP Character Tools

Reverse Text

reverse_text
Read-onlyIdempotent

Reverse text character-by-character or word-by-word, with palindrome detection. Use this tool to transform text order for analysis or creative purposes.

Instructions

Reverse text character-by-character or word-by-word.

Also detects if the text is a palindrome.

Args:

  • text (string): The text to reverse

  • reverse_words_only (boolean): Reverse word order only, not characters (default: false)

Returns: Reversed text, palindrome detection.

Example: reverse_text("hello") → "olleh"; reverse_text("racecar") → "racecar" (palindrome!)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to reverse
reverse_words_onlyNoReverse word order only

Implementation Reference

  • The core handler function implementing the reverse_text tool logic: reverses text character-by-character or word-by-word, detects palindromes, and provides descriptive output.
    export function reverseText(input: ReverseTextInput): ReverseTextOutput {
      const { text, reverse_words_only } = input;
      
      let reversed: string;
      if (reverse_words_only) {
        // Reverse order of words but keep each word's characters in order
        reversed = text.split(/(\s+)/).reverse().join('');
      } else {
        // Reverse all characters
        reversed = [...text].reverse().join('');
      }
    
      const normalizedOriginal = text.toLowerCase().replace(/[^a-z0-9]/g, '');
      const normalizedReversed = [...normalizedOriginal].reverse().join('');
      const is_palindrome = normalizedOriginal === normalizedReversed && normalizedOriginal.length > 0;
    
      const description = reverse_words_only
        ? `Words reversed: "${text}" → "${reversed}"`
        : `Characters reversed: "${text}" → "${reversed}"${is_palindrome ? ' (This is a palindrome!)' : ''}`;
    
      return {
        original: text,
        reversed,
        reverse_words_only,
        is_palindrome,
        description,
      };
    }
  • TypeScript interfaces defining the input (text and reverse_words_only option) and output (reversed text, palindrome check, description) types for the reverseText handler.
    export interface ReverseTextInput {
      text: string;
      reverse_words_only: boolean;
    }
    
    export interface ReverseTextOutput {
      original: string;
      reversed: string;
      reverse_words_only: boolean;
      is_palindrome: boolean;
      description: string;
    }
  • src/index.ts:341-371 (registration)
    MCP server registration of the 'reverse_text' tool, including Zod input schema validation, description, annotations, and wrapper calling the reverseText handler.
    server.registerTool(
      "reverse_text",
      {
        title: "Reverse Text",
        description: `Reverse text character-by-character or word-by-word.
    
    Also detects if the text is a palindrome.
    
    Args:
      - text (string): The text to reverse
      - reverse_words_only (boolean): Reverse word order only, not characters (default: false)
    
    Returns: Reversed text, palindrome detection.
    
    Example: reverse_text("hello") → "olleh"; reverse_text("racecar") → "racecar" (palindrome!)`,
        inputSchema: z.object({
          text: z.string().min(1).describe("The text to reverse"),
          reverse_words_only: z.boolean().default(false).describe("Reverse word order only"),
        }).strict(),
        annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
      },
      async (params) => {
        const result = reverseText({
          text: params.text,
          reverse_words_only: params.reverse_words_only,
        });
        return {
          content: [{ type: "text" as const, text: result.description }],
        };
      }
    );
  • Zod runtime input schema for the reverse_text tool registration, validating text (non-empty string) and reverse_words_only (boolean, default false).
    inputSchema: z.object({
      text: z.string().min(1).describe("The text to reverse"),
      reverse_words_only: z.boolean().default(false).describe("Reverse word order only"),
    }).strict(),
Behavior4/5

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

Annotations already provide safety and idempotency hints (readOnlyHint: true, destructiveHint: false, idempotentHint: true). The description adds valuable behavioral context beyond this by specifying that it detects palindromes and provides example outputs, which helps the agent understand the tool's behavior and expected results. No contradiction with annotations.

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 well-structured and front-loaded with the core functionality, followed by parameter details, return information, and examples. Every sentence earns its place by adding clarity or practical guidance without redundancy, making it efficient and easy to parse.

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 tool's low complexity, rich annotations, and 100% schema coverage, the description is mostly complete. It explains the tool's purpose, parameters, and outputs with examples. However, without an output schema, it could benefit from more detail on return format (e.g., structured response vs. plain text), but the examples partially compensate.

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 documents both parameters thoroughly. The description adds minimal value beyond the schema by restating parameter purposes in the 'Args' section and providing examples, but does not introduce new semantic insights or clarify ambiguities not covered in the schema.

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 specific verbs ('reverse character-by-character or word-by-word') and distinguishes it from siblings by focusing on text reversal rather than analysis, counting, or comparison. It explicitly mentions palindrome detection, which is unique among the listed tools.

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 provides clear context for when to use this tool (for reversing text or detecting palindromes) but does not explicitly state when not to use it or name alternatives among siblings. It implies usage through examples but lacks explicit exclusions or comparisons to tools like 'analyze_sentence' or 'compare_texts'.

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