Skip to main content
Glama

create_question

Create prediction questions on Fatebook to track forecasts with deadlines, probabilities, and sharing options for collaborative forecasting.

Instructions

Create a new Fatebook question

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes
resolveByYes
forecastYes
apiKeyNo
tagsNo
sharePubliclyNo
shareWithListsNo
shareWithEmailNo
hideForecastsUntilNo

Implementation Reference

  • Implementation of the create_question tool handler. Posts to Fatebook API to create a question, parses the response URL to extract question ID, and returns QuestionReference.
    @mcp.tool()
    async def create_question(
        title: str,
        resolveBy: str,
        forecast: float,
        apiKey: str = "",
        tags: list[str] = [],
        sharePublicly: bool = False,
        shareWithLists: list[str] = [],
        shareWithEmail: list[str] = [],
        hideForecastsUntil: str = "",
    ) -> QuestionReference:
        """Create a new 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")
    
        params: ParamsType = {
            "apiKey": api_key,
            "title": title,
            "resolveBy": resolveBy,
            "forecast": forecast,
        }
    
        # Add optional parameters
        if tags:
            params["tags"] = ",".join(tags)
        if sharePublicly:
            params["sharePublicly"] = sharePublicly
        if shareWithLists:
            params["shareWithLists"] = ",".join(shareWithLists)
        if shareWithEmail:
            params["shareWithEmail"] = ",".join(shareWithEmail)
        if hideForecastsUntil:
            params["hideForecastsUntil"] = hideForecastsUntil
    
        try:
            async with httpx.AsyncClient() as client:
                response = await client.post("https://fatebook.io/api/v0/createQuestion", params=params)
                response.raise_for_status()
    
                # Parse the URL from the response to extract title and ID
                url = response.text.strip()
                if url.startswith("https://fatebook.io/q/"):
                    # Extract the slug part after /q/
                    slug = url.replace("https://fatebook.io/q/", "")
    
                    # Split on the last occurrence of -- to separate title and ID
                    if "--" in slug:
                        url_title, question_id = slug.rsplit("--", 1)
                        return QuestionReference(id=question_id, title=title)
                    else:
                        raise ValueError(f"Could not parse question ID from URL: {url}")
                else:
                    raise ValueError(f"Unexpected response format: {url}")
    
        except httpx.HTTPError:
            raise
        except Exception:
            raise
  • Pydantic model defining the output schema (QuestionReference) returned by create_question tool.
    class QuestionReference(BaseModel):
        """Minimal question reference with id and title"""
    
        id: str
        title: str
  • MCP tool registration decorator for create_question.
    @mcp.tool()
    async def create_question(

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