Skip to main content
Glama

add_forecast

Add a probability forecast to a prediction question on Fatebook to track and update your predictions over time.

Instructions

Add a forecast to a Fatebook question

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionIdYes
forecastYes
apiKeyNo
optionIdNo

Implementation Reference

  • The core handler function for the 'add_forecast' MCP tool. It validates inputs, constructs the API payload, and makes a POST request to the Fatebook API to add the forecast. Registered via @mcp.tool() decorator.
    @mcp.tool()
    async def add_forecast(
        questionId: str, forecast: float, apiKey: str = "", optionId: str = ""
    ) -> bool:
        """Add a forecast to a Fatebook question"""
    
        api_key = apiKey or os.getenv("FATEBOOK_API_KEY")
        if not api_key:
            raise ValueError(
                "API key is required (provide as parameter or set FATEBOOK_API_KEY environment variable)"
            )
    
        # Validate forecast parameter
        if not 0 <= forecast <= 1:
            raise ValueError("forecast must be between 0 and 1")
    
        data = {"questionId": questionId, "forecast": forecast, "apiKey": api_key}
    
        # Add optional parameter for multi-choice questions
        if optionId:
            data["optionId"] = optionId
    
        try:
            async with httpx.AsyncClient() as client:
                response = await client.post("https://fatebook.io/api/v0/addForecast", json=data)
                response.raise_for_status()
                return True
    
        except httpx.HTTPError:
            raise
        except Exception:
            raise

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/an1lam/fatebook-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server