Skip to main content
Glama

get_question

Retrieve detailed information for a specific question on Fatebook, including its structured data, to analyze and manage predictions effectively.

Instructions

Get detailed information about a specific Fatebook question

Returns a structured Question object with all available fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
apiKeyNo
questionIdYes

Implementation Reference

  • The primary handler function for the 'get_question' MCP tool. It takes questionId and optional apiKey, calls the Fatebook API, adds the ID to the response, parses it into a Question model, and returns it.
    @mcp.tool() async def get_question(ctx: Context, questionId: str, apiKey: str = "") -> Question: """Get detailed information about a specific Fatebook question Returns a structured Question object with all available fields. """ api_key = apiKey or os.getenv("FATEBOOK_API_KEY") if not api_key: await ctx.error("API key is required but not provided") raise ValueError( "API key is required (provide as parameter or set FATEBOOK_API_KEY environment variable)" ) params: ParamsType = {"apiKey": api_key, "questionId": questionId} await ctx.debug(f"Making API request for question {questionId}") try: async with httpx.AsyncClient() as client: response = await client.get("https://fatebook.io/api/v0/getQuestion", params=params) response.raise_for_status() question_data = response.json() await ctx.info(f"Successfully retrieved question {questionId}") # Add the ID to the data since the API doesn't return it question_data["id"] = questionId # Parse as Question model and return it question = Question(**question_data) return question except httpx.HTTPError as e: await ctx.error(f"HTTP error occurred: {e}") raise except Exception as e: await ctx.error(f"Unexpected error occurred: {e}") raise
  • Pydantic model 'Question' that defines the structured output schema returned by the get_question tool. Includes fields, validators, and formatting methods.
    class Question(BaseModel): """Fatebook question model with optional fields for detailed responses""" # Core fields (id is optional since getQuestion doesn't return it) id: Optional[str] = None title: str type: Literal["BINARY", "NUMERIC", "MULTIPLE_CHOICE"] = "BINARY" resolved: bool = False # Timestamps created_at: datetime = Field(alias="createdAt") resolve_by: datetime = Field(alias="resolveBy") resolved_at: Optional[datetime] = Field(None, alias="resolvedAt") # Resolution information resolution: Optional[Literal["YES", "NO", "AMBIGUOUS"]] = None # Additional content (typically in detailed view) notes: Optional[str] = None # Related data (typically in detailed view) forecasts: Optional[List[Forecast]] = Field( default=None, description="List of forecasts on this question" ) tags: Optional[List[Tag]] = Field(default=None, description="Tags associated with the question") comments: Optional[List[Comment]] = Field(default=None, description="Comments on the question") # Visibility settings (typically in detailed view) shared_publicly: Optional[bool] = Field(None, alias="sharedPublicly") unlisted: Optional[bool] = None hide_forecasts_until: Optional[datetime] = Field(None, alias="hideForecastsUntil") share_with_lists: Optional[List[str]] = Field(None, alias="shareWithLists") share_with_email: Optional[List[str]] = Field(None, alias="shareWithEmail") # Additional fields from getQuestion endpoint your_latest_prediction: Optional[str] = Field(None, alias="yourLatestPrediction") question_scores: Optional[List] = Field(None, alias="questionScores") class Config: populate_by_name = True by_alias = True # Use aliases when serializing # Computed properties @property def forecast_count(self) -> int: """Number of forecasts on this question""" return len(self.forecasts) if self.forecasts else 0 @property def status_text(self) -> str: """Human-readable status string""" if self.resolved: return f"✅ RESOLVED ({self.resolution})" return "⏳ OPEN" def format_short(self) -> str: """Format for list display""" tags_text = ", ".join([tag.name for tag in self.tags]) if self.tags else "" tags_display = f" | Tags: {tags_text}" if tags_text else "" forecast_text = ( f" | {self.forecast_count} forecast{'s' if self.forecast_count != 1 else ''}" ) id_text = f" | ID: {self.id}" if self.id else "" return f"**{self.title}**\n{self.status_text}{id_text}{forecast_text}{tags_display}" def format_detailed(self) -> str: """Format for detailed single question display""" lines = [ f"**{self.title}**", ] if self.id: lines.append(f"ID: {self.id}") lines.extend( [ f"Type: {self.type}", f"Created: {self.created_at.isoformat()}", f"Resolve By: {self.resolve_by.isoformat()}", ] ) status = "✅ Resolved" if self.resolved else "⏳ Open" if self.resolved and self.resolved_at: status += f" as {self.resolution} on {self.resolved_at.isoformat()}" lines.append(f"Status: {status}") if self.notes: lines.append(f"Notes: {self.notes}") if self.forecasts: lines.append(f"Forecasts ({len(self.forecasts)}):") for forecast in self.forecasts: lines.append(f" • {forecast.user.name}: {forecast.forecast:.0%}") if self.tags: tag_names = [tag.name for tag in self.tags] lines.append(f"Tags: {', '.join(tag_names)}") if self.comments: lines.append(f"Comments ({len(self.comments)}):") for comment in self.comments: lines.append(f" • {comment.user.name}: {comment.comment}") visibility = [] if self.shared_publicly: visibility.append("Public") if self.unlisted: visibility.append("Unlisted") if visibility: lines.append(f"Visibility: {', '.join(visibility)}") return "\n".join(lines)
  • MCP resource handler providing alternative access to question data via URI 'question://{question_id}', similar logic to the tool handler but without ctx.
    @mcp.resource("question://{question_id}") async def get_question_resource(question_id: str) -> Question: """Get detailed information about a specific Fatebook question as a resource Provides read-only access to question data for loading into LLM context. """ api_key = os.getenv("FATEBOOK_API_KEY") if not api_key: raise ValueError("API key is required (set FATEBOOK_API_KEY environment variable)") params: ParamsType = {"apiKey": api_key, "questionId": question_id} async with httpx.AsyncClient() as client: response = await client.get("https://fatebook.io/api/v0/getQuestion", params=params) response.raise_for_status() question_data = response.json() # Add the ID to the data since the API doesn't return it question_data["id"] = question_id question = Question(**question_data) return question

Other Tools

Related Tools

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