animal_fact
Retrieve interesting facts about animals by specifying a species name. This tool provides educational information for learning about wildlife characteristics and behaviors.
Instructions
Get a fun fact about a given animal.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| animal | No | dog |
Implementation Reference
- server.py:69-78 (handler)The main handler function for the 'animal_fact' tool. It takes an optional animal name (default 'dog'), fetches a fun fact from 'https://some-random-api.com/facts/{animal}', and returns the fact or an error message.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}"
- server.py:68-68 (registration)The @mcp.tool() decorator registers the 'animal_fact' function as an MCP tool.@mcp.tool()
- server.py:69-70 (schema)Tool schema defined via function signature (input: animal str default 'dog', output: str) and docstring.def animal_fact(animal: str = "dog") -> str: """Get a fun fact about a given animal."""