get_posts_by_date
Retrieve QAnon posts within a specific date range for sociological analysis by providing start and end dates.
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 |
|---|---|---|---|
| start_date | Yes | ||
| end_date | No | ||
| limit | No |
Implementation Reference
- src/qanon_mcp/__init__.py:363-399 (handler)The primary handler for the 'get_posts_by_date' tool. Decorated with @mcp.tool() for registration. Validates dates, calls helper to fetch posts, limits results, formats output using format_post, and returns a formatted string.@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)Core helper function that filters the global 'posts' list by timestamp within the given date range, converting dates to timestamps for comparison.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-154 (helper)Utility function used by the handler to format individual posts into a readable string, including metadata, text, images, and referenced posts.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()
- src/qanon_mcp/__init__.py:365-372 (schema)Input schema defined in the tool's docstring, describing parameters start_date (str, required), end_date (str, optional), limit (int, optional=10). Output is 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) """
- src/qanon_mcp/__init__.py:363-363 (registration)The @mcp.tool() decorator registers this function as an MCP tool named 'get_posts_by_date'.@mcp.tool()