search_posts
Find QAnon posts containing specific keywords or phrases for research or analysis. Specify query and limit results to streamline your investigation. Powered by the qanon-mcp-server.
Instructions
Search for posts/drops containing a specific keyword or phrase.
Args:
query: The keyword or phrase to search for
limit: Maximum number of results to return (default: 10)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| query | Yes |
Implementation Reference
- src/qanon_mcp/__init__.py:332-361 (handler)The primary handler function for the 'search_posts' tool, registered via @mcp.tool() decorator. It searches posts by keyword using a helper function and formats results.@mcp.tool() def search_posts(query: str, limit: int = 10) -> str: """ Search for posts/drops containing a specific keyword or phrase. Args: query: The keyword or phrase to search for limit: Maximum number of results to return (default: 10) """ if not query: return "Please provide a search query." results = search_posts_by_keyword(query) if not results: return f"No posts found containing '{query}'." total_found = len(results) results = results[:limit] output = f"Found {total_found} posts containing '{query}'. 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:57-66 (helper)Helper function that performs the keyword search on post texts, called by the main search_posts handler.def search_posts_by_keyword(keyword: str) -> List[Dict]: """Search posts containing a keyword.""" keyword = keyword.lower() results = [] for post in posts: text = post.get("text", "").lower() if keyword in text: results.append(post) return results
- src/qanon_mcp/__init__.py:96-154 (helper)Utility function used by search_posts to format individual post results for output.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()