analyze_post
Analyze a specific post to extract detailed insights, references, and contextual information for sociological research on QAnon content.
Instructions
Get detailed analysis of a specific post/drop including references and context.
Args:
post_id: The ID of the post to analyze
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| post_id | Yes |
Implementation Reference
- src/qanon_mcp/__init__.py:437-545 (handler)The primary handler for the 'analyze_post' MCP tool. Decorated with @mcp.tool(), it performs detailed analysis of a QAnon post by ID, including metadata extraction, content formatting, image and reference analysis, and contextual information about adjacent posts in the dataset.@mcp.tool() def analyze_post(post_id: int) -> str: """ Get detailed analysis of a specific post/drop including references and context. Args: post_id: The ID of the post to analyze """ post = get_post_by_id(post_id) if not post: return f"Post with ID {post_id} not found." metadata = post.get("post_metadata", {}) author = metadata.get("author", "Unknown") author_id = metadata.get("author_id", "Unknown") timestamp = metadata.get("time", 0) date_str = ( datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S") if timestamp else "Unknown" ) source = metadata.get("source", {}) board = source.get("board", "Unknown") site = source.get("site", "Unknown") link = source.get("link", "Unknown") text = post.get("text", "") if text: text = text.replace("\\n", "\n") # Images analysis images = post.get("images", []) images_analysis = "" if images: images_analysis = f"\n\nImages ({len(images)}):\n" for i, img in enumerate(images, 1): images_analysis += f"{i}. File: {img.get('file', 'Unknown')}, Name: {img.get('name', 'Unknown')}\n" # Referenced posts analysis refs = post.get("referenced_posts", []) refs_analysis = "" if refs: refs_analysis = f"\n\nReferenced Posts ({len(refs)}):\n" for i, ref in enumerate(refs, 1): 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_analysis += f"{i}. Reference: {ref.get('reference', 'Unknown')}\n" refs_analysis += f" Author ID: {ref_author_id}\n" refs_analysis += f" Text: {ref_text}\n\n" # Find other posts by the same author same_author_posts = get_posts_by_author_id(author_id, limit=5) # Build the analysis analysis = f""" Detailed Analysis of Post/Drop {post_id}: Basic Information: ----------------- Author: {author} (ID: {author_id}) Date: {date_str} Source: {board} on {site} Original Link: {link} Post Content: ------------ {text} {images_analysis} {refs_analysis} Context: ------- This post is part of {len(posts)} total posts in the dataset. """ # Add information about posts around this one post_position = None for i, p in enumerate( sorted(posts, key=lambda x: x.get("post_metadata", {}).get("id", 0)) ): if p.get("post_metadata", {}).get("id") == post_id: post_position = i break if post_position is not None: analysis += f"\nThis is post #{post_position + 1} in chronological order.\n" # Previous post if post_position > 0: prev_post = posts[post_position - 1] prev_id = prev_post.get("post_metadata", {}).get("id", "Unknown") prev_date = datetime.fromtimestamp( prev_post.get("post_metadata", {}).get("time", 0) ).strftime("%Y-%m-%d") analysis += f"\nPrevious post: #{prev_id} from {prev_date}\n" # Next post if post_position < len(posts) - 1: next_post = posts[post_position + 1] next_id = next_post.get("post_metadata", {}).get("id", "Unknown") next_date = datetime.fromtimestamp( next_post.get("post_metadata", {}).get("time", 0) ).strftime("%Y-%m-%d") analysis += f"Next post: #{next_id} from {next_date}\n" return analysis
- src/qanon_mcp/__init__.py:49-54 (helper)Helper function used by analyze_post to retrieve a specific post from the global 'posts' list by its ID.def get_post_by_id(post_id: int) -> Optional[Dict]: """Get a post by its ID.""" for post in posts: if post.get("post_metadata", {}).get("id") == post_id: return post return None