Skip to main content
Glama
ferdousbhai

WSB Analyst MCP Server

get_external_links

Extract external links from top WallStreetBets posts to identify shared resources for market analysis. Filter by upvote score and comment count to focus on relevant content.

Instructions

Get all external links from top WSB posts.

Args:
    min_score: Minimum score (upvotes) required
    min_comments: Minimum number of comments required
    limit: Maximum number of posts to scan

Returns:
    Dictionary with all unique external links found

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
min_scoreNo
min_commentsNo
limitNo

Implementation Reference

  • The handler function decorated with @mcp.tool(), which implements the get_external_links tool. It fetches top WSB posts using find_top_posts, retrieves detailed post data including extracted external links using fetch_batch_post_details, collects and deduplicates all unique external links from posts and comments, and returns them sorted.
    @mcp.tool()
    async def get_external_links(min_score: int = 100, min_comments: int = 10, limit: int = 10, ctx: Context = None) -> dict:
        """
        Get all external links from top WSB posts.
    
        Args:
            min_score: Minimum score (upvotes) required
            min_comments: Minimum number of comments required
            limit: Maximum number of posts to scan
    
        Returns:
            Dictionary with all unique external links found
        """
        if ctx:
            await ctx.report_progress(0, 3)
    
        # Get filtered posts
        posts_result = await find_top_posts(min_score, min_comments, limit)
        if "error" in posts_result:
            return {"error": posts_result["error"]}
    
        if len(posts_result["posts"]) == 0:
            return {"count": 0, "links": []}
    
        # Collect post IDs
        post_ids = [post["id"] for post in posts_result["posts"]]
    
        if ctx:
            await ctx.report_progress(1, 3)
    
        # Get details for all posts
        details_result = await fetch_batch_post_details(post_ids)
        if "error" in details_result:
            return {"error": details_result["error"]}
    
        # Extract all links
        all_links = []
        for post_id, post_detail in details_result["posts"].items():
            if "extracted_links" in post_detail:
                all_links.extend(post_detail["extracted_links"])
    
        if ctx:
            await ctx.report_progress(2, 3)
    
        # Remove duplicates and sort
        unique_links = sorted(list(set(all_links)))
    
        if ctx:
            await ctx.report_progress(3, 3)
    
        return {
            "count": len(unique_links),
            "links": unique_links
        }
  • Helper function that extracts potential URL links from text using regex, excluding common Reddit domains, and filters them further using is_valid_external_link.
    def extract_valid_links(text: str) -> list[str]:
        if not text:
            return []
        url_pattern = re.compile(
            r'https?://(?!(?:www\.)?reddit\.com|(?:www\.)?i\.redd\.it|(?:www\.)?v\.redd\.it|(?:www\.)?imgur\.com|'
            r'(?:www\.)?preview\.redd\.it|(?:www\.)?sh\.reddit\.com|[^.]*\.reddit\.com)'
            r'[^\s)\]}"\']+',
            re.IGNORECASE
        )
        links = url_pattern.findall(text)
        return [link for link in links if is_valid_external_link(link)]
  • Helper function that determines if a URL is a valid external link by checking against a list of excluded domains like Reddit, Imgur, etc.
    def is_valid_external_link(url: str) -> bool:
        excluded_domains = [
            "reddit.com", "redd.it", "imgur.com", "gfycat.com",
            "redgifs.com", "giphy.com", "imgflip.com",
            "youtu.be", "discord.gg",
        ]
        if any(domain in url for domain in excluded_domains):
            return False
    
        return True
  • server.py:464-464 (registration)
    The @mcp.tool() decorator registers the get_external_links function as an MCP tool.
    @mcp.tool()
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. It mentions that the tool scans posts and returns unique external links, but it lacks details on rate limits, authentication needs, error handling, or what constitutes 'top WSB posts' (e.g., time frame or sorting criteria). This leaves significant gaps in understanding the tool's behavior.

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

Conciseness5/5

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

The description is highly concise and well-structured. It starts with a clear purpose statement, followed by bullet-point-like sections for 'Args' and 'Returns,' each with brief, direct explanations. Every sentence earns its place, and there is no wasted verbiage, making it easy to scan and understand quickly.

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 moderate complexity (3 parameters, no annotations, no output schema), the description is partially complete. It covers the purpose and parameters well but lacks behavioral details and usage guidelines. Without an output schema, it should ideally explain the return format more thoroughly (e.g., structure of the dictionary), but it does state the return type, which helps somewhat.

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 beyond the input schema, which has 0% description coverage. It explains that 'min_score' refers to 'Minimum score (upvotes) required,' 'min_comments' is 'Minimum number of comments required,' and 'limit' is 'Maximum number of posts to scan.' This clarifies the purpose of each parameter, compensating well for the schema's lack of descriptions.

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: 'Get all external links from top WSB posts.' It specifies the verb ('Get'), resource ('external links'), and scope ('from top WSB posts'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'fetch_detailed_wsb_posts' or 'find_top_posts,' which might also involve post retrieval, so it misses full sibling distinction.

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 any prerequisites, exclusions, or comparisons to sibling tools such as 'fetch_batch_post_details' or 'get_top_trending_tickers.' Without this context, users might struggle to choose the right tool for their needs.

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/ferdousbhai/wsb-analyst-mcp'

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