Skip to main content
Glama
Traves-Theberge

Word of the Day MCP Server

get_word_definition

Retrieve definitions, pronunciations, and meanings for any word using a dictionary API to enhance vocabulary understanding.

Instructions

Get the definition, pronunciation, and meanings of a word using the Dictionary API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
wordYesThe word to get the definition for
languageNoLanguage code (default: en)en

Implementation Reference

  • The handler function that validates input using GetDefinitionArgsSchema, fetches word data from Dictionary API, handles errors, formats response with pronunciation, origin, meanings, definitions, examples, synonyms, antonyms, and audio links.
    private async getWordDefinition(args: unknown) { const { word, language = 'en' } = GetDefinitionArgsSchema.parse(args); try { const response = await fetch(`https://api.dictionaryapi.dev/api/v2/entries/${language}/${encodeURIComponent(word)}`); if (!response.ok) { if (response.status === 404) { return { content: [ { type: 'text', text: `No definition found for "${word}". Please check the spelling or try a different word.`, }, ], }; } throw new Error(`Dictionary API error: ${response.status} ${response.statusText}`); } const data: WordEntry[] = await response.json(); if (!data || data.length === 0) { return { content: [ { type: 'text', text: `No definition found for "${word}".`, }, ], }; } const entry = data[0]; let result = `**${entry.word}**\n\n`; // Add phonetic information if (entry.phonetic) { result += `**Pronunciation:** ${entry.phonetic}\n\n`; } else if (entry.phonetics && entry.phonetics.length > 0) { const phoneticTexts = entry.phonetics .filter(p => p.text) .map(p => p.text) .join(', '); if (phoneticTexts) { result += `**Pronunciation:** ${phoneticTexts}\n\n`; } } // Add origin if available if (entry.origin) { result += `**Origin:** ${entry.origin}\n\n`; } // Add meanings result += `**Meanings:**\n\n`; entry.meanings.forEach((meaning, index) => { result += `${index + 1}. **${meaning.partOfSpeech}**\n`; meaning.definitions.forEach((def, defIndex) => { result += ` ${defIndex + 1}. ${def.definition}\n`; if (def.example) { result += ` *Example: "${def.example}"*\n`; } if (def.synonyms && def.synonyms.length > 0) { result += ` *Synonyms: ${def.synonyms.join(', ')}*\n`; } if (def.antonyms && def.antonyms.length > 0) { result += ` *Antonyms: ${def.antonyms.join(', ')}*\n`; } }); result += '\n'; }); // Add audio pronunciation links if available const audioLinks = entry.phonetics .filter(p => p.audio) .map(p => p.audio) .filter(Boolean); if (audioLinks.length > 0) { result += `**Audio Pronunciation:**\n`; audioLinks.forEach((audio, index) => { result += `${index + 1}. ${audio}\n`; }); } return { content: [ { type: 'text', text: result, }, ], }; } catch (error) { throw new Error(`Failed to fetch definition for "${word}": ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • Zod schema defining input parameters for get_word_definition: required 'word' string, optional 'language' string defaulting to 'en'.
    const GetDefinitionArgsSchema = z.object({ word: z.string().min(1, 'Word cannot be empty'), language: z.string().default('en').optional(), });
  • src/index.ts:72-90 (registration)
    Tool registration in ListTools handler, specifying name, description, and JSON schema matching the Zod schema.
    { name: 'get_word_definition', description: 'Get the definition, pronunciation, and meanings of a word using the Dictionary API', inputSchema: { type: 'object', properties: { word: { type: 'string', description: 'The word to get the definition for', }, language: { type: 'string', description: 'Language code (default: en)', default: 'en', }, }, required: ['word'], }, },
  • TypeScript interface defining the structure of the Dictionary API response entry used in the handler.
    interface WordEntry { word: string; phonetic?: string; phonetics: PhoneticInfo[]; origin?: string; meanings: Meaning[]; }
  • Interface for meaning objects containing partOfSpeech and definitions array.
    interface Meaning { partOfSpeech: string; definitions: Definition[]; }
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/Traves-Theberge/Word_of_the_day'

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