Skip to main content
Glama
Rudra-ravi

Wikipedia MCP Server

by Rudra-ravi

test_wikipedia_connectivity

Read-onlyIdempotent

Check whether the Wikipedia API is reachable and responsive. Returns the base URL, language, site info, and response time, or reports failure with error 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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYes
urlYes
languageYes
site_nameNo
serverNo
response_time_msNo
errorNo
error_typeNo

Implementation Reference

  • The handler function for the 'test_wikipedia_connectivity' tool. It calls wikipedia_client.test_connectivity() and rounds the response_time_ms if present.
    @register_tool("test_wikipedia_connectivity", model_output_schema(ConnectivityResponse))
    def test_wikipedia_connectivity():
        """
        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()
    
        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
  • The output schema/model for the connectivity test tool response.
    class ConnectivityResponse(MCPBaseModel):
        status: str
        url: str
        language: str
        site_name: Optional[str] = None
        server: Optional[str] = None
        response_time_ms: Optional[float] = None
        error: Optional[str] = None
        error_type: Optional[str] = None
  • The registration decorator that registers the tool under both the canonical name and the 'wikipedia_' alias.
    def register_tool(name: str, output_schema: dict[str, Any]):
        def decorator(func):
            server.tool(
                func,
                name=name,
                annotations=_READ_ONLY_TOOL_ANNOTATIONS,
                output_schema=output_schema,
            )
            server.tool(
                func,
                name=f"wikipedia_{name}",
                annotations=_READ_ONLY_TOOL_ANNOTATIONS,
                output_schema=output_schema,
            )
            return func
    
        return decorator
  • The helper method on WikipediaClient that actually performs the HTTP request to the Wikipedia API and returns connectivity diagnostics.
    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}")
            data, error = self._request_json(
                url=test_url,
                params=test_params,
                timeout=10,
                retries=1,
            )
            if error:
                return {
                    "status": "failed",
                    "url": test_url,
                    "language": self.base_language,
                    "error": error.get("message", "Connectivity test failed"),
                    "error_type": error.get("error_type", "RequestError"),
                }
    
            site_info = (data or {}).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"),
                "response_time_ms": None,
            }
    
        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__,
            }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.0.1
  2. Removedv1.5.8
  3. Addedv1.0.0

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, and the description adds valuable behavior details: return fields (base API URL, language, site info, response time) and failure handling (status='failed' with error details). This complements the annotations without contradicting them.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences and front-loaded with the primary purpose. The first sentence states what the tool does, and the second sentence details the output and failure behavior. Every word contributes meaning; there is no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with no parameters and an output-schema present, the description is fully sufficient. It explains the return values and failure status, covering all necessary contextual information for an agent to invoke the tool appropriately.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters and the schema coverage is 100%, so the description has no parameters to explain. The baseline for zero-parameter tools is 4, and the description appropriately refrains from inventing unnecessary parameter details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Provide diagnostics for Wikipedia API connectivity.' It uses a specific verb ('provide diagnostics') and a well-defined resource ('Wikipedia API connectivity'), making it distinct from sibling tools that retrieve content or perform searches.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies its usage as a connectivity diagnostic tool but does not explicitly state when to use it versus alternatives. Since no sibling tool performs diagnostics, the usage context is inferred rather than directly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.