Skip to main content
Glama

get_links

Extract all links from a Wikipedia article by providing its title. This tool helps users quickly access and analyze referenced content within articles, supporting research and information gathering.

Instructions

Get the links contained within a Wikipedia article.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes

Implementation Reference

  • Handler function for the 'get_links' MCP tool. Registered via @server.tool() decorator. Wraps WikipediaClient.get_links() and formats the response.
    @server.tool() def get_links(title: str) -> Dict[str, Any]: """Get the links contained within a Wikipedia article.""" logger.info(f"Tool: Getting links for: {title}") links = wikipedia_client.get_links(title) return {"title": title, "links": links}
  • Core helper method in WikipediaClient that implements the logic to fetch Wikipedia page links using wikipediaapi library.
    def get_links(self, title: str) -> List[str]: """Get the links in a Wikipedia article. Args: title: The title of the Wikipedia article. Returns: A list of links. """ try: page = self.wiki.page(title) if not page.exists(): return [] return [link for link in page.links.keys()] except Exception as e: logger.error(f"Error getting Wikipedia links: {e}") return []
  • The @server.tool() decorator registers the get_links function as an MCP tool in the FastMCP server.
    @server.tool() def get_links(title: str) -> Dict[str, Any]: """Get the links contained within a Wikipedia article.""" logger.info(f"Tool: Getting links for: {title}") links = wikipedia_client.get_links(title) return {"title": title, "links": links}
  • LRU cache decorator applied to get_links method when caching is enabled, improving performance for repeated calls.
    self.get_links = functools.lru_cache(maxsize=128)(self.get_links)

Other Tools

Related 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