lookup_word_lemma
Find the base form of Norwegian words using the National Library of Norway's digital collections. Input a word to receive its lemma information in JSON format.
Instructions
Look up the lemma (base form) of a Norwegian word.
Args: word: The word to look up
Returns: JSON string containing lemma information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| word | Yes |
Implementation Reference
- src/dhlab_mcp/server.py:222-239 (handler)The handler function for the lookup_word_lemma tool. It takes a word as input, uses dhlab.WordLemma to retrieve lemma information, and returns it as JSON or an error message.@mcp.tool() def lookup_word_lemma(word: str) -> str: """Look up the lemma (base form) of a Norwegian word. Args: word: The word to look up Returns: JSON string containing lemma information """ try: word_lemma = dhlab.WordLemma(word) if hasattr(word_lemma, 'lemmas') and word_lemma.lemmas is not None: return word_lemma.lemmas.to_json(orient='records', force_ascii=False) return f"No lemma found for word: {word}" except Exception as e: return f"Error looking up word lemma: {str(e)}"