get_page
Retrieve specific page content from MediaWiki sites like Wikipedia, Fandom, or wiki.gg by providing the page title. Useful for accessing detailed information directly.
Instructions
Get a page from mediawiki.org Args: title: The title of the page to get, which can be found in title field of the search results Returns: The page content
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes |
Input Schema (JSON Schema)
{
"properties": {
"title": {
"title": "Title",
"type": "string"
}
},
"required": [
"title"
],
"title": "get_pageArguments",
"type": "object"
}
Implementation Reference
- src/mediawiki_mcp_server/main.py:73-83 (handler)The handler function for the 'get_page' MCP tool, registered via @mcp.tool() decorator. It constructs the API endpoint path from the title and uses the make_request helper to fetch and return the page content as JSON.@mcp.tool() async def get_page(title: str): """Get a page from mediawiki.org Args: title: The title of the page to get, which can be found in title field of the search results Returns: The page content """ path = f"page/{title}" response = await make_request(path, {}) return response
- Supporting helper function that performs HTTP GET requests to the MediaWiki REST API, handles redirects and proxies, and returns JSON response. Used by the get_page tool.async def make_request(path: str, params: dict) -> httpx.Response: headers = { "User-Agent": USER_AGENT, } url = config.base_url + config.path_prefix + path proxies = get_proxy_settings() async with httpx.AsyncClient(proxies=proxies, follow_redirects=True) as client: try: response = await client.get(url, headers=headers, params=params) if response.status_code in (301, 302, 303, 307, 308): final_response = await client.get( response.headers["Location"], headers=headers ) return final_response.json() return response.json() except httpx.HTTPStatusError as e: logger.error(e) return {"error": e}
- Helper to retrieve proxy settings from environment, used by make_request.def get_proxy_settings(): """Get proxy settings from environment variables""" http_proxy = os.environ.get("HTTP_PROXY") return http_proxy
- src/mediawiki_mcp_server/main.py:17-17 (registration)Instantiates the FastMCP server instance which handles tool registration via decorators.mcp = FastMCP("mediawiki-mcp-server")