Skip to main content
Glama

spell_word

Break text into individual characters with optional position indices to verify character-by-character content 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 implementing the logic for the 'spell_word' tool: destructures input, spreads text into characters, creates indexed list using helper, conditionally formats spelled_out string, and 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 and include_indices flag) and output schema (including characters array, indexed characters, and formatted spelled_out string) 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)
    Registration of the 'spell_word' tool on the MCP server, defining metadata, Zod input schema matching the handler types, annotations, and async wrapper that invokes spellWord and formats the textual 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}` }], }; } );
  • Supporting utility function called by spellWord to create an array of objects with index and character for each position in the text.
    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