add_comment
Enable AI assistants to attach comments to specific questions on Fatebook, enhancing context and collaboration for prediction tracking. Requires question ID and comment input.
Instructions
Add a comment to a Fatebook question
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| apiKey | No | ||
| comment | Yes | ||
| questionId | Yes |
Implementation Reference
- main.py:307-332 (handler)Core handler implementation for the 'add_comment' MCP tool. Posts comment data to Fatebook API endpoint and handles API key, errors, and response validation.@mcp.tool() async def add_comment(ctx: Context, questionId: str, comment: str, apiKey: str = "") -> bool: """Add a comment to a Fatebook question""" 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)" ) data = {"questionId": questionId, "comment": comment, "apiKey": api_key} try: async with httpx.AsyncClient() as client: response = await client.post("https://fatebook.io/api/v0/addComment", json=data) response.raise_for_status() return True 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
- src/fatebook_mcp/__main__.py:287-308 (handler)Alternative or package-mode handler for the 'add_comment' MCP tool, similar API call logic without explicit Context parameter.@mcp.tool() async def add_comment(questionId: str, comment: str, apiKey: str = "") -> bool: """Add a comment 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)" ) data = {"questionId": questionId, "comment": comment, "apiKey": api_key} try: async with httpx.AsyncClient() as client: response = await client.post("https://fatebook.io/api/v0/addComment", json=data) response.raise_for_status() return True except httpx.HTTPError: raise except Exception: raise
- src/fatebook_mcp/models.py:54-71 (schema)Pydantic model for Comment objects, used in detailed question responses which include comments added via add_comment tool.class Comment(BaseModel): """Comment on a question""" id: Optional[Union[str, int]] = None comment: str user: User created_at: Optional[datetime] = Field(None, alias="createdAt") @field_validator("id") @classmethod def convert_id_to_string(cls, v): """Convert integer IDs to strings""" return str(v) if v is not None else v class Config: populate_by_name = True by_alias = True # Use aliases when serializing
- main.py:307-332 (registration)FastMCP decorator that registers the add_comment function as an MCP tool with automatic schema inference from signature and docstring.@mcp.tool() async def add_comment(ctx: Context, questionId: str, comment: str, apiKey: str = "") -> bool: """Add a comment to a Fatebook question""" 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)" ) data = {"questionId": questionId, "comment": comment, "apiKey": api_key} try: async with httpx.AsyncClient() as client: response = await client.post("https://fatebook.io/api/v0/addComment", json=data) response.raise_for_status() return True 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