get_article
Retrieve complete Wikipedia article content by title to access detailed information for research or reference purposes.
Instructions
Get the full content of a Wikipedia article.
Returns a dictionary containing article details or an error message if retrieval fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes |
Implementation Reference
- wikipedia_mcp/server.py:121-133 (handler)MCP tool handler for get_article, registered via @server.tool() decorator. Delegates to WikipediaClient.get_article and ensures dict return.@server.tool() def get_article(title: str) -> Dict[str, Any]: """ Get the full content of a Wikipedia article. Returns a dictionary containing article details or an error message if retrieval fails. """ logger.info(f"Tool: Getting article: {title}") article = wikipedia_client.get_article(title) # Ensure we always return a dictionary return article or {"title": title, "exists": False, "error": "Unknown error retrieving article"}
- Core implementation of get_article in WikipediaClient, fetches page using wikipediaapi, extracts summary, text, sections, categories, links.def get_article(self, title: str) -> Dict[str, Any]: """ Get the full content of a Wikipedia article. Args: title: The title of the Wikipedia article. Returns: A dictionary containing the article information. """ try: page = self.wiki.page(title) if not page.exists(): return {"title": title, "exists": False, "error": "Page does not exist"} # Get sections sections = self._extract_sections(page.sections) # Get categories categories = [cat for cat in page.categories.keys()] # Get links links = [link for link in page.links.keys()] return { "title": page.title, "pageid": page.pageid, "summary": page.summary, "text": page.text, "url": page.fullurl, "sections": sections, "categories": categories, "links": links[:100], # Limit to 100 links to avoid too much data "exists": True, } except Exception as e: logger.error(f"Error getting Wikipedia article: {e}") return {"title": title, "exists": False, "error": str(e)}
- wikipedia_mcp/server.py:121-121 (registration)The @server.tool() decorator registers the get_article function as an MCP tool.@server.tool()