get_timeline_summary
Generate a summarized timeline of QAnon posts within a specified date range to support research and analysis of their content and patterns.
Instructions
Get a timeline summary of posts/drops, optionally within a date range.
Args:
start_date: Optional start date in YYYY-MM-DD format
end_date: Optional end date in YYYY-MM-DD format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_date | No | ||
| start_date | No |
Implementation Reference
- src/qanon_mcp/__init__.py:548-622 (handler)The handler function for the 'get_timeline_summary' tool. It generates a timeline summary of QAnon posts grouped by month, showing sample posts from each month. Optionally filters posts by a date range using the helper function get_posts_by_date_range. The @mcp.tool() decorator registers this function as an MCP tool.@mcp.tool() def get_timeline_summary(start_date: str = None, end_date: str = None) -> str: """ Get a timeline summary of posts/drops, optionally within a date range. Args: start_date: Optional start date in YYYY-MM-DD format end_date: Optional end date in YYYY-MM-DD format """ # Use all posts if no dates provided timeline_posts = posts # Filter by date range if provided if start_date and end_date: try: datetime.strptime(start_date, "%Y-%m-%d") datetime.strptime(end_date, "%Y-%m-%d") timeline_posts = get_posts_by_date_range(start_date, end_date) except ValueError: return "Invalid date format. Please use YYYY-MM-DD format." # Sort posts by time timeline_posts = sorted( timeline_posts, key=lambda x: x.get("post_metadata", {}).get("time", 0) ) if not timeline_posts: return "No posts found for the specified date range." # Group posts by month months = {} for post in timeline_posts: timestamp = post.get("post_metadata", {}).get("time", 0) if timestamp: month_key = datetime.fromtimestamp(timestamp).strftime("%Y-%m") if month_key not in months: months[month_key] = [] months[month_key].append(post) # Build the timeline timeline = "QAnon Posts Timeline:\n\n" for month_key in sorted(months.keys()): month_name = datetime.strptime(month_key, "%Y-%m").strftime("%B %Y") month_posts = months[month_key] timeline += f"## {month_name} ({len(month_posts)} posts)\n\n" # Get the first and last 2 posts of the month as examples sample_posts = [] if len(month_posts) <= 4: sample_posts = month_posts else: sample_posts = month_posts[:2] + month_posts[-2:] for post in sample_posts: post_id = post.get("post_metadata", {}).get("id", "Unknown") timestamp = post.get("post_metadata", {}).get("time", 0) day = datetime.fromtimestamp(timestamp).strftime("%d %b") text = post.get("text", "") if text: text = text.replace("\\n", " ") # Truncate text if too long if len(text) > 100: text = text[:97] + "..." timeline += f"- {day}: Post #{post_id} - {text}\n" if len(month_posts) > 4: timeline += f" ... and {len(month_posts) - 4} more posts this month\n" timeline += "\n" return timeline
- src/qanon_mcp/__init__.py:68-84 (helper)Helper function used by get_timeline_summary to filter the posts list by a given date range (inclusive). Converts dates to timestamps and matches post times.def get_posts_by_date_range(start_date: str, end_date: str) -> List[Dict]: """Get posts within a date range (YYYY-MM-DD format).""" try: start_timestamp = int(datetime.strptime(start_date, "%Y-%m-%d").timestamp()) end_timestamp = ( int(datetime.strptime(end_date, "%Y-%m-%d").timestamp()) + 86400 ) # Add a day in seconds results = [] for post in posts: post_time = post.get("post_metadata", {}).get("time", 0) if start_timestamp <= post_time <= end_timestamp: results.append(post) return results except ValueError: return []