Skip to main content
Glama

get_related_topics

Find related Wikipedia topics by analyzing article links and categories to discover connected subjects and expand research scope.

Instructions

Get topics related to a Wikipedia article based on links and categories.

Returns a list of related topics up to the specified limit.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'get_related_topics'. Registers the tool via @server.tool() decorator and implements minimal logic by delegating to WikipediaClient.get_related_topics().
    @server.tool()
    def get_related_topics(title: str, limit: int = 10) -> Dict[str, Any]:
        """
        Get topics related to a Wikipedia article based on links and categories.
    
        Returns a list of related topics up to the specified limit.
        """
        logger.info(f"Tool: Getting related topics for: {title}")
        related = wikipedia_client.get_related_topics(title, limit=limit)
        return {"title": title, "related_topics": related}
  • Core implementation of get_related_topics in WikipediaClient. Fetches the page, extracts links and categories, retrieves summaries for top links up to the limit, and falls back to categories.
    def get_related_topics(self, title: str, limit: int = 10) -> List[Dict[str, Any]]:
        """
        Get topics related to a Wikipedia article based on links and categories.
    
        Args:
            title: The title of the Wikipedia article.
            limit: Maximum number of related topics to return.
    
        Returns:
            A list of related topics.
        """
        try:
            page = self.wiki.page(title)
    
            if not page.exists():
                return []
    
            # Get links from the page
            links = list(page.links.keys())
    
            # Get categories
            categories = list(page.categories.keys())
    
            related = []
    
            # Add links first
            for link in links[:limit]:
                link_page = self.wiki.page(link)
                if link_page.exists():
                    related.append(
                        {
                            "title": link,
                            "summary": (
                                link_page.summary[:200] + "..."
                                if len(link_page.summary) > 200
                                else link_page.summary
                            ),
                            "url": link_page.fullurl,
                            "type": "link",
                        }
                    )
                if len(related) >= limit:
                    break
    
            # Add categories if we still have room
            remaining = limit - len(related)
            if remaining > 0:
                for category in categories[:remaining]:
                    # Remove "Category:" prefix if present
                    clean_category = category.replace("Category:", "")
                    related.append({"title": clean_category, "type": "category"})
    
            return related
        except Exception as e:
            logger.error(f"Error getting related topics: {e}")
            return []
  • The @server.tool() decorator registers 'get_related_topics' as an MCP tool on the FastMCP server.
    @server.tool()
    def get_related_topics(title: str, limit: int = 10) -> Dict[str, Any]:
        """
        Get topics related to a Wikipedia article based on links and categories.
    
        Returns a list of related topics up to the specified limit.
        """
        logger.info(f"Tool: Getting related topics for: {title}")
        related = wikipedia_client.get_related_topics(title, limit=limit)
        return {"title": title, "related_topics": related}
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 topics are 'based on links and categories' and returns 'a list up to the specified limit,' but lacks details on permissions, rate limits, error handling, or what 'related' entails (e.g., relevance scoring). This is a significant gap for a tool with no annotation coverage.

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 front-loaded, with two sentences that directly state the purpose and output. Every sentence earns its place by providing essential information without redundancy or unnecessary elaboration.

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 (2 parameters, no annotations, but with an output schema), the description is minimally adequate. The output schema likely covers return values, so the description need not explain them. However, it lacks details on behavioral aspects and parameter constraints, leaving gaps in completeness for effective tool use.

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

Parameters3/5

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

Schema description coverage is 0%, so the schema provides no parameter details. The description adds some semantics by implying 'title' is a Wikipedia article title and 'limit' controls the number of topics returned, but it does not specify format constraints (e.g., case sensitivity for 'title') or range for 'limit' beyond the default. It partially compensates for the low coverage but not fully.

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 topics related to a Wikipedia article based on links and categories.' It specifies the verb ('Get'), resource ('topics'), and scope ('related to a Wikipedia article'), but does not explicitly differentiate it from sibling tools like 'get_links' or 'search_wikipedia', which might have overlapping functionality.

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 does not mention sibling tools like 'get_links' (which might retrieve links without categorization) or 'search_wikipedia' (which might find articles by keyword), leaving the agent to infer usage context without explicit direction.

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/Rudra-ravi/wikipedia-mcp'

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