animal_fact
Discover interesting facts about animals by entering the name of any animal species to learn about their behavior, characteristics, or habitat.
Instructions
Get a fun fact about a given animal.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| animal | No | dog |
Implementation Reference
- server.py:68-79 (handler)The handler function for the 'animal_fact' tool. It is registered via the @mcp.tool() decorator and fetches a random fact about the specified animal from the 'some-random-api.com' API. Includes input parameter 'animal' with default 'dog', returns a string fact or error message.@mcp.tool() def animal_fact(animal: str = "dog") -> str: """Get a fun fact about a given animal.""" try: url = f"https://some-random-api.com/facts/{animal.lower()}" r = requests.get(url) if r.status_code == 200: return r.json().get("fact", "No fact found.") return f"⚠️ API error: {r.status_code}" except Exception as e: return f"❌ Something went wrong: {e}"