Skip to main content
Glama

wikipedia_get_related_topics

Read-onlyIdempotent

Find related topics from a Wikipedia article using its links and categories. Specify a title and optional limit to get relevant results.

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
titleYes
related_topicsYes

Implementation Reference

  • The handler function for the 'get_related_topics' tool. It delegates to wikipedia_client.get_related_topics and returns the title with related topics.
    @register_tool("get_related_topics", model_output_schema(RelatedTopicsResponse))
    def get_related_topics(title: str, limit: int = 10):
        """
        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("Tool: Getting related topics for: %s", title)
        related = wikipedia_client.get_related_topics(title, limit=limit)
        return {"title": title, "related_topics": related}
  • Pydantic schema 'RelatedTopicsResponse' defining the output type for the get_related_topics tool (title + list of related topics dicts).
    class RelatedTopicsResponse(MCPBaseModel):
        title: str
        related_topics: list[dict[str, Any]]
  • The register_tool decorator that registers the tool under both the base name ('get_related_topics') and the prefixed name ('wikipedia_get_related_topics').
    def register_tool(name: str, output_schema: dict[str, Any]):
        def decorator(func):
            server.tool(
                func,
                name=name,
                annotations=_READ_ONLY_TOOL_ANNOTATIONS,
                output_schema=output_schema,
            )
            server.tool(
                func,
                name=f"wikipedia_{name}",
                annotations=_READ_ONLY_TOOL_ANNOTATIONS,
                output_schema=output_schema,
            )
            return func
  • Core helper function that retrieves related topics by fetching page links and categories from the Wikipedia API, with support for a limit parameter.
    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
  • LRU cache wrapping applied to get_related_topics method for performance optimization.
    self.get_related_topics = functools.lru_cache(maxsize=128)(  # type: ignore[method-assign]
        self.get_related_topics
    )
Behavior3/5

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

Annotations already declare readOnly and idempotent hints. Description adds that it returns a list up to a limit, but no additional behavioral context beyond annotations.

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?

Two sentences, front-loaded with purpose, no fluff. Could be slightly more structured but highly efficient.

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?

Output schema exists, so return values are documented elsewhere. However, missing guidance on how relatedness is determined and lack of differentiation from similarly named sibling.

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

Parameters2/5

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

Schema description coverage is 0% (no parameter descriptions). Description only mentions 'limit' vaguely; does not clarify 'title' format or the structure of the returned list. Regression for a 0% coverage case.

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?

Clearly states it retrieves related topics based on links and categories, distinguishing from 'get_links' and 'get_summary'. However, there is a sibling tool with the same name 'get_related_topics', which could confuse agents.

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?

No guidance on when to use this tool versus siblings like 'search_wikipedia' or 'get_links'. Does not specify prerequisites or when not to use.

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