number_fact
Retrieve interesting facts about numbers or dates using the NumbersAPI to enhance learning and satisfy curiosity.
Instructions
Get an interesting fact about a number or date using NumbersAPI.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- server.py:28-40 (handler)The number_fact tool handler function, registered via @mcp.tool(). It fetches and returns an interesting fact about the provided number or date query from the NumbersAPI.@mcp.tool() def number_fact(query: str) -> str: """Get an interesting fact about a number or date using NumbersAPI.""" try: # You can pass things like "42", "math/42", or "date/6/14" url = f"http://numbersapi.com/{query}" response = requests.get(url) if response.status_code == 200: return response.text else: return f"⚠️ API error: {response.status_code}" except Exception as e: return f"❌ Something went wrong: {e}"
- server.py:28-28 (registration)Registration of the number_fact tool using the @mcp.tool() decorator.@mcp.tool()