count_forecasts
Retrieve and count forecasts made by a specific user on Fatebook, a prediction tracking platform, to monitor and analyze prediction activity.
Instructions
Count forecasts for a specific user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | Yes |
Implementation Reference
- main.py:405-426 (handler)Primary handler implementation for the 'count_forecasts' MCP tool. This async function is decorated with @mcp.tool(), which both defines the schema from its signature and registers it with the FastMCP server. It makes an HTTP GET request to the Fatebook API endpoint to retrieve the forecast count for the specified userId.@mcp.tool() async def count_forecasts(ctx: Context, userId: str) -> int: """Count forecasts for a specific user""" params = {"userId": userId} try: async with httpx.AsyncClient() as client: response = await client.get("https://fatebook.io/api/v0/countForecasts", params=params) response.raise_for_status() # Parse JSON response and return the count data = response.json() return int(data.get("count", 0)) 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:375-394 (handler)Package version handler for the 'count_forecasts' tool in the src/fatebook_mcp module. Similar implementation to main.py but without Context parameter for logging.@mcp.tool() async def count_forecasts(userId: str) -> int: """Count forecasts for a specific user""" params = {"userId": userId} try: async with httpx.AsyncClient() as client: response = await client.get("https://fatebook.io/api/v0/countForecasts", params=params) response.raise_for_status() # Parse JSON response and return the count data = response.json() return int(data.get("count", 0)) except httpx.HTTPError: raise except Exception: raise
- main.py:405-426 (registration)The @mcp.tool() decorator registers this function as an MCP tool named 'count_forecasts', inferring input schema from parameters (ctx: Context, userId: str) and output as int.@mcp.tool() async def count_forecasts(ctx: Context, userId: str) -> int: """Count forecasts for a specific user""" params = {"userId": userId} try: async with httpx.AsyncClient() as client: response = await client.get("https://fatebook.io/api/v0/countForecasts", params=params) response.raise_for_status() # Parse JSON response and return the count data = response.json() return int(data.get("count", 0)) 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:375-394 (registration)@mcp.tool() decorator registers the tool, schema from (userId: str) -> int.@mcp.tool() async def count_forecasts(userId: str) -> int: """Count forecasts for a specific user""" params = {"userId": userId} try: async with httpx.AsyncClient() as client: response = await client.get("https://fatebook.io/api/v0/countForecasts", params=params) response.raise_for_status() # Parse JSON response and return the count data = response.json() return int(data.get("count", 0)) except httpx.HTTPError: raise except Exception: raise