Skip to main content
Glama

test_wikipedia_connectivity

Diagnose Wikipedia API connectivity by testing connection status, response time, and retrieving base URL with language details.

Instructions

Provide diagnostics for Wikipedia API connectivity.

Returns the base API URL, language, site information, and response time in milliseconds. If connectivity fails, status will be 'failed' with error details.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'test_wikipedia_connectivity', registered via @server.tool() decorator. It calls the underlying WikipediaClient.test_connectivity() method and formats the response time.
    @server.tool() def test_wikipedia_connectivity() -> Dict[str, Any]: """ Provide diagnostics for Wikipedia API connectivity. Returns the base API URL, language, site information, and response time in milliseconds. If connectivity fails, status will be 'failed' with error details. """ logger.info("Tool: Testing Wikipedia connectivity") diagnostics = wikipedia_client.test_connectivity() # Round response_time_ms for nicer output if present if ( diagnostics.get("status") == "success" and "response_time_ms" in diagnostics and isinstance(diagnostics["response_time_ms"], (int, float)) ): diagnostics["response_time_ms"] = round(float(diagnostics["response_time_ms"]), 3) return diagnostics
  • Supporting method in WikipediaClient class that performs the actual connectivity test by querying the Wikipedia API siteinfo endpoint, measures response time, and handles exceptions.
    def test_connectivity(self) -> Dict[str, Any]: """ Test connectivity to the Wikipedia API and return diagnostics. Returns: A dictionary with status, URL, language, site information, and response time. On failure, returns status 'failed' with error details. """ test_url = f"https://{self.base_language}.wikipedia.org/w/api.php" test_params = { "action": "query", "format": "json", "meta": "siteinfo", "siprop": "general", } try: logger.info(f"Testing connectivity to {test_url}") response = requests.get( test_url, headers=self._get_request_headers(), params=test_params, timeout=10, ) response.raise_for_status() data = response.json() site_info = data.get("query", {}).get("general", {}) return { "status": "success", "url": test_url, "language": self.base_language, "site_name": site_info.get("sitename", "Unknown"), "server": site_info.get("server", "Unknown"), # Round response time to milliseconds with high precision "response_time_ms": response.elapsed.total_seconds() * 1000, } except Exception as exc: # pragma: no cover - safeguarded logger.error("Connectivity test failed: %s", exc) return { "status": "failed", "url": test_url, "language": self.base_language, "error": str(exc), "error_type": type(exc).__name__, }

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