get_posts_by_date
Retrieve QAnon posts within a specified date range using start and end dates in YYYY-MM-DD format. Optionally, limit the number of results returned for targeted analysis.
Instructions
Get posts/drops within a specific date range.
Args:
start_date: Start date in YYYY-MM-DD format
end_date: End date in YYYY-MM-DD format (defaults to start_date if not provided)
limit: Maximum number of results to return (default: 10)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_date | No | ||
| limit | No | ||
| start_date | Yes |
Implementation Reference
- src/qanon_mcp/__init__.py:363-399 (handler)Primary handler for the get_posts_by_date MCP tool. Validates input dates, retrieves posts using date range helper, limits and formats results for output.@mcp.tool() def get_posts_by_date(start_date: str, end_date: str = None, limit: int = 10) -> str: """ Get posts/drops within a specific date range. Args: start_date: Start date in YYYY-MM-DD format end_date: End date in YYYY-MM-DD format (defaults to start_date if not provided) limit: Maximum number of results to return (default: 10) """ if not end_date: end_date = start_date try: # Validate date format datetime.strptime(start_date, "%Y-%m-%d") datetime.strptime(end_date, "%Y-%m-%d") except ValueError: return "Invalid date format. Please use YYYY-MM-DD format." results = get_posts_by_date_range(start_date, end_date) if not results: return f"No posts found between {start_date} and {end_date}." total_found = len(results) results = results[:limit] output = f"Found {total_found} posts between {start_date} and {end_date}. Showing top {len(results)} results:\n\n" for i, post in enumerate(results, 1): output += f"Result {i}:\n{format_post(post)}\n\n" + "-" * 40 + "\n\n" if total_found > limit: output += f"... and {total_found - limit} more posts." return output
- src/qanon_mcp/__init__.py:68-84 (helper)Helper function that implements the core date range filtering logic by converting dates to timestamps and matching 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 []
- src/qanon_mcp/__init__.py:96-153 (helper)Helper function used by the handler to format individual post data into a readable string representation.def format_post(post: Dict) -> str: """Format a post for display.""" metadata = post.get("post_metadata", {}) post_id = metadata.get("id", "Unknown") author = metadata.get("author", "Unknown") author_id = metadata.get("author_id", "Unknown") tripcode = metadata.get("tripcode", "Unknown") source = metadata.get("source", {}) board = source.get("board", "Unknown") site = source.get("site", "Unknown") timestamp = metadata.get("time", 0) date_str = ( datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S") if timestamp else "Unknown" ) text = post.get("text", "") if text: # Replace '\n' string literals with actual newlines text = text.replace("\\n", "\n") # Format images images_section = "" images = post.get("images", []) if images: images_section = "\nImages:\n" for img in images: images_section += f"- File: {img.get('file', 'Unknown')}, Name: {img.get('name', 'Unknown')}\n" # Format referenced posts refs_section = "" refs = post.get("referenced_posts", []) if refs: refs_section = "\nReferenced Posts:\n" for ref in refs: ref_text = ref.get("text", "No text") if ref_text: ref_text = ref_text.replace("\\n", "\n") ref_author_id = ref.get("author_id", "Unknown") refs_section += f"- Reference: {ref.get('reference', 'Unknown')}\n" refs_section += f" Author ID: {ref_author_id}\n" refs_section += f" Text: {ref_text}\n" # Assemble the formatted post formatted = f""" Post ID: {post_id} Author: {author} (ID: {author_id}, tripcode: {tripcode}) Source: {board} on {site} Date: {date_str} Text: {text} {images_section} {refs_section} """ return formatted.strip()