Skip to main content
Glama

spell_word

Break text into individual characters with optional position numbers to verify content character-by-character and overcome tokenization limitations.

Instructions

Break text into individual characters with optional indices.

Perfect for verifying character-by-character content.

Args:

  • text (string): The text to spell out

  • include_indices (boolean): Include position numbers (default: true)

Returns: Array of characters, indexed list, spelled out string.

Example: spell_word("cat") → ['c', 'a', 't'] with indices [0:'c', 1:'a', 2:'t']

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text to spell out
include_indicesNoInclude position numbers

Implementation Reference

  • Core handler function that executes the spell_word tool: destructures input, spreads text to characters, calls helper for indexed list, conditionally formats spelled_out string, returns structured output.
    export function spellWord(input: SpellWordInput): SpellWordOutput { const { text, include_indices } = input; const characters = [...text]; const indexed_characters = createIndexedList(text); const spelled_out = include_indices ? indexed_characters.map(ic => `${ic.index}:'${ic.char}'`).join(', ') : characters.map(c => `'${c}'`).join(', '); return { text, length: characters.length, characters, indexed_characters, spelled_out, }; }
  • TypeScript interfaces defining the input schema (text, include_indices) and output schema (text, length, characters, indexed_characters, spelled_out) for the spellWord handler.
    export interface SpellWordInput { text: string; include_indices: boolean; } export interface SpellWordOutput { text: string; length: number; characters: string[]; indexed_characters: Array<{ index: number; char: string }>; spelled_out: string; }
  • src/index.ts:211-241 (registration)
    MCP tool registration for 'spell_word': defines title, description, Zod input schema (validating text and include_indices), annotations, and async wrapper handler that invokes spellWord and formats text response.
    server.registerTool( "spell_word", { title: "Spell Word", description: `Break text into individual characters with optional indices. Perfect for verifying character-by-character content. Args: - text (string): The text to spell out - include_indices (boolean): Include position numbers (default: true) Returns: Array of characters, indexed list, spelled out string. Example: spell_word("cat") → ['c', 'a', 't'] with indices [0:'c', 1:'a', 2:'t']`, inputSchema: z.object({ text: z.string().min(1).describe("The text to spell out"), include_indices: z.boolean().default(true).describe("Include position numbers"), }).strict(), annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }, }, async (params) => { const result = spellWord({ text: params.text, include_indices: params.include_indices, }); return { content: [{ type: "text" as const, text: `"${result.text}" (${result.length} chars): ${result.spelled_out}` }], }; } );
  • Utility helper function called by spellWord to generate array of objects with character indices and characters.
    export function createIndexedList(text: string): Array<{ index: number; char: string }> { return [...text].map((char, index) => ({ index, char })); }

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