Skip to main content
Glama
jkingsman

https://github.com/jkingsman/qanon-mcp-server

search_posts

Search for QAnon posts containing specific keywords or phrases to support sociological research and analysis.

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
NameRequiredDescriptionDefault
queryYes
limitNo

Implementation Reference

  • The handler function for the 'search_posts' tool. It is registered via the @mcp.tool() decorator, which also serves as the schema via type hints and docstring. Searches posts using the helper function and formats output.
    @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
  • Helper function that performs the actual keyword search on the loaded posts data, returning matching posts.
    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
  • Supporting function used by search_posts to format individual post results for display.
    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()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jkingsman/qanon-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server