create_question
Generate and manage predictive questions on Fatebook by defining titles, resolution dates, forecasts, tags, and sharing settings for collaborative forecasting and decision-making.
Instructions
Create a new Fatebook question
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | ||
| forecast | Yes | ||
| hideForecastsUntil | No | ||
| resolveBy | Yes | ||
| sharePublicly | No | ||
| shareWithEmail | No | ||
| shareWithLists | No | ||
| tags | No | ||
| title | Yes |
Implementation Reference
- src/fatebook_mcp/__main__.py:184-251 (handler)The handler function for the create_question tool, which handles the core logic: API key retrieval, input validation, constructing API parameters, making the HTTP POST request to create the question, parsing the response to extract the question ID, and returning a QuestionReference object. Registered via @mcp.tool() decorator.@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
- src/fatebook_mcp/models.py:204-209 (schema)Pydantic BaseModel defining the output type schema for the create_question tool, used for structured response validation and serialization.class QuestionReference(BaseModel): """Minimal question reference with id and title""" id: str title: str
- src/fatebook_mcp/__main__.py:184-184 (registration)The @mcp.tool() decorator registers the create_question function as an MCP tool, automatically generating input schema from function signature and docstring.@mcp.tool()