number_fact
Retrieve interesting facts about numbers or dates using the NumbersAPI. Enter a number or date to get a factual response.
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:29-40 (handler)This is the handler function for the 'number_fact' tool. It fetches an interesting fact about a number or date from numbersapi.com using an HTTP request. The @mcp.tool() decorator registers it with the MCP server.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}"