Skip to main content
Glama
jkingsman

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

get_post_by_id_tool

Retrieve a specific QAnon post by its ID for sociological research and analysis.

Instructions

Retrieve a specific post by its ID.

Args:
    post_id: The ID of the post to retrieve

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYes

Implementation Reference

  • The handler function for get_post_by_id_tool, decorated with @mcp.tool() for registration. Retrieves the post by ID using helper, formats it, adds adjacent post context, and returns formatted string.
    @mcp.tool()
    def get_post_by_id_tool(post_id: int) -> str:
        """
        Retrieve a specific post by its ID.
    
        Args:
            post_id: The ID of the post to retrieve
        """
        # Use the existing helper function to get the post
        post = get_post_by_id(post_id)
    
        if not post:
            return f"Post with ID {post_id} not found."
    
        # Use the existing format_post function to format the output
        formatted_post = format_post(post)
    
        # Get adjacent posts for context
        post_list = sorted(posts, key=lambda x: x.get("post_metadata", {}).get("id", 0))
        post_ids = [p.get("post_metadata", {}).get("id", 0) for p in post_list]
    
        try:
            index = post_ids.index(post_id)
            context = "\nAdjacent Posts:\n"
    
            # Get previous post if it exists
            if index > 0:
                prev_id = post_ids[index - 1]
                prev_date = datetime.fromtimestamp(
                    post_list[index - 1].get("post_metadata", {}).get("time", 0)
                ).strftime("%Y-%m-%d")
                context += f"Previous post: #{prev_id} from {prev_date}\n"
    
            # Get next post if it exists
            if index < len(post_ids) - 1:
                next_id = post_ids[index + 1]
                next_date = datetime.fromtimestamp(
                    post_list[index + 1].get("post_metadata", {}).get("time", 0)
                ).strftime("%Y-%m-%d")
                context += f"Next post: #{next_id} from {next_date}\n"
        except ValueError:
            context = ""
    
        result = f"Post #{post_id}:\n\n{formatted_post}\n{context}"
    
        return result
  • Docstring defining the tool's purpose and input parameter schema (post_id: int).
    """
    Retrieve a specific post by its ID.
    
    Args:
        post_id: The ID of the post to retrieve
    """
  • Helper function to find and return the post dictionary by ID from the loaded dataset.
    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
  • Helper function to format the post data 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()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Retrieve' implies a read-only operation, it doesn't specify whether this requires authentication, has rate limits, returns structured data, or handles errors. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by a brief parameter explanation. It avoids redundancy and wastes no words, though the 'Args:' section could be integrated more seamlessly into the flow.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and parameter meaning but lacks behavioral details (e.g., error handling, return format) and usage guidelines relative to siblings, leaving room for improvement.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context for the single parameter 'post_id' by explaining it's 'The ID of the post to retrieve', which clarifies its purpose beyond the schema's basic type (integer). With 0% schema description coverage and only one parameter, this adequately compensates, though it doesn't detail format constraints (e.g., numeric range).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Retrieve') and resource ('a specific post by its ID'), making it immediately understandable. However, it doesn't explicitly differentiate from siblings like 'get_posts_by_author_id' or 'search_posts', which also retrieve posts but with different filtering criteria.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_posts_by_author_id' for author-based retrieval or 'search_posts' for keyword searches, leaving the agent to infer usage context solely from tool names.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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