get_summary
Extract concise summaries from Wikipedia articles to quickly understand key information without reading full pages. Provide the article title to receive a structured summary with title and content.
Instructions
Get a summary of a Wikipedia article.
Returns a dictionary with the title and summary string. On error, includes an error message instead of a summary.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes |
Implementation Reference
- wikipedia_mcp/server.py:137-151 (handler)MCP tool handler and registration for 'get_summary'. Delegates to WikipediaClient.get_summary and formats response as dict with title and summary or error.@server.tool() def get_summary(title: str) -> Dict[str, Any]: """ Get a summary of a Wikipedia article. Returns a dictionary with the title and summary string. On error, includes an error message instead of a summary. """ logger.info(f"Tool: Getting summary for: {title}") summary = wikipedia_client.get_summary(title) if summary and not summary.startswith("Error"): return {"title": title, "summary": summary} else: return {"title": title, "summary": None, "error": summary}
- Core implementation of get_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)}"
- Optional LRU caching applied to get_summary method when enable_cache=True.self.get_summary = functools.lru_cache(maxsize=128)(self.get_summary)