get_random_word
Generate a random word with definition to expand vocabulary. Choose difficulty level (easy, medium, hard) for customized learning.
Instructions
Get a random word with its definition for word of the day
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| difficulty | No | Difficulty level of the random word | medium |
Implementation Reference
- src/index.ts:237-263 (handler)The core handler function for the 'get_random_word' tool. It validates input args using the schema, selects a random word from difficulty-specific lists, and delegates to getWordDefinition for the response.private async getRandomWord(args: unknown) { const { difficulty = 'medium' } = GetRandomWordArgsSchema.parse(args); // List of curated words by difficulty level const wordLists = { easy: [ 'happy', 'house', 'water', 'light', 'music', 'friend', 'smile', 'peace', 'dream', 'heart', 'love', 'hope', 'time', 'life', 'world', 'nature' ], medium: [ 'serendipity', 'eloquent', 'resilient', 'magnificent', 'innovative', 'perspective', 'authentic', 'curiosity', 'adventure', 'harmony', 'wisdom', 'courage', 'gratitude', 'compassion', 'creativity', 'balance' ], hard: [ 'ephemeral', 'ubiquitous', 'perspicacious', 'surreptitious', 'magnanimous', 'obfuscate', 'ameliorate', 'propensity', 'vicissitude', 'perspicuity', 'sesquipedalian', 'grandiloquent', 'pusillanimous', 'truculent', 'recalcitrant' ] }; const words = wordLists[difficulty]; const randomWord = words[Math.floor(Math.random() * words.length)]; // Get the definition for the random word return await this.getWordDefinition({ word: randomWord, language: 'en' }); }
- src/index.ts:44-46 (schema)Zod schema for validating input arguments to the get_random_word tool, defining the optional 'difficulty' parameter.const GetRandomWordArgsSchema = z.object({ difficulty: z.enum(['easy', 'medium', 'hard']).default('medium').optional(), });
- src/index.ts:91-106 (registration)Registration of the 'get_random_word' tool in the ListToolsRequestHandler, including metadata like name, description, and input schema.{ name: 'get_random_word', description: 'Get a random word with its definition for word of the day', inputSchema: { type: 'object', properties: { difficulty: { type: 'string', enum: ['easy', 'medium', 'hard'], description: 'Difficulty level of the random word', default: 'medium', }, }, required: [], }, },
- src/index.ts:119-120 (registration)Dispatch case in the CallToolRequestHandler switch statement that routes calls to the getRandomWord handler.case 'get_random_word': return await this.getRandomWord(args);