get_summary
Retrieve concise summaries of Wikipedia articles by specifying the article title. Ideal for quick insights or extracting key information from Wikipedia content efficiently.
Instructions
Get a summary of a Wikipedia article.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes |
Implementation Reference
- wikipedia_mcp/server.py:88-93 (handler)Handler function for the 'get_summary' tool, registered with @server.tool(). It takes a title, fetches the summary from WikipediaClient, and returns a structured dictionary.@server.tool() def get_summary(title: str) -> Dict[str, Any]: """Get a summary of a Wikipedia article.""" logger.info(f"Tool: Getting summary for: {title}") summary = wikipedia_client.get_summary(title) return {"title": title, "summary": summary}
- Core helper method in WikipediaClient that retrieves the summary using wikipediaapi.Wikipedia.page(title).summary, with error handling.def get_summary(self, title: str) -> str: """Get a summary of a Wikipedia article. Args: title: The title of the Wikipedia article. Returns: The article summary. """ try: page = self.wiki.page(title) if not page.exists(): return f"No Wikipedia article found for '{title}'." return page.summary except Exception as e: logger.error(f"Error getting Wikipedia summary: {e}") return f"Error retrieving summary for '{title}': {str(e)}"
- Caching configuration in WikipediaClient.__init__ that applies functools.lru_cache to get_summary and other methods when enable_cache is True.if self.enable_cache: self.search = functools.lru_cache(maxsize=128)(self.search) self.get_article = functools.lru_cache(maxsize=128)(self.get_article) self.get_summary = functools.lru_cache(maxsize=128)(self.get_summary) self.get_sections = functools.lru_cache(maxsize=128)(self.get_sections) self.get_links = functools.lru_cache(maxsize=128)(self.get_links) self.get_related_topics = functools.lru_cache(maxsize=128)(self.get_related_topics) self.summarize_for_query = functools.lru_cache(maxsize=128)(self.summarize_for_query) self.summarize_section = functools.lru_cache(maxsize=128)(self.summarize_section) self.extract_facts = functools.lru_cache(maxsize=128)(self.extract_facts) self.get_coordinates = functools.lru_cache(maxsize=128)(self.get_coordinates)
- wikipedia_mcp/server.py:88-93 (registration)Registration of the 'get_summary' tool using the @server.tool() decorator in the FastMCP server setup.@server.tool() def get_summary(title: str) -> Dict[str, Any]: """Get a summary of a Wikipedia article.""" logger.info(f"Tool: Getting summary for: {title}") summary = wikipedia_client.get_summary(title) return {"title": title, "summary": summary}