Skip to main content
Glama

search_wikipedia

Find Wikipedia articles by entering search terms to retrieve relevant information and metadata for research or reference purposes.

Instructions

Search Wikipedia for articles matching a query.

Parameters: query: The search term to look up on Wikipedia. limit: Maximum number of results to return (1-500).

Returns a dictionary with the search query, results, status, and additional metadata. If the query is empty or invalid, the status will be 'error' and an explanatory message is included.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The search_wikipedia tool handler, registered via @server.tool() decorator. Validates query and limit parameters, performs search using WikipediaClient, and returns formatted results with status.
    @server.tool()
    def search_wikipedia(query: str, limit: int = 10) -> Dict[str, Any]:
        """
        Search Wikipedia for articles matching a query.
    
        Parameters:
            query: The search term to look up on Wikipedia.
            limit: Maximum number of results to return (1-500).
    
        Returns a dictionary with the search query, results, status, and
        additional metadata. If the query is empty or invalid, the status
        will be 'error' and an explanatory message is included.
        """
        logger.info("Tool: Searching Wikipedia for '%s' (limit=%d)", query, limit)
    
        # Validate query
        if not query or not query.strip():
            logger.warning("Search tool called with empty query")
            return {
                "query": query,
                "results": [],
                "status": "error",
                "message": "Empty search query provided",
            }
    
        # Sanitize and validate limit
        validated_limit = limit
        if limit <= 0:
            validated_limit = 10
            logger.warning("Invalid limit %d; using default %d", limit, validated_limit)
        elif limit > 500:
            validated_limit = 500
            logger.warning("Limit %d capped to %d", limit, validated_limit)
    
        results = wikipedia_client.search(query, limit=validated_limit)
        status = "success" if results else "no_results"
        response: Dict[str, Any] = {
            "query": query,
            "results": results,
            "status": status,
            "count": len(results),
            "language": wikipedia_client.base_language,
        }
    
        if not results:
            response["message"] = (
                "No search results found. This could indicate connectivity issues, "
                "API errors, or simply no matching articles."
            )
    
        return response
Behavior4/5

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

With no annotations provided, the description carries the full burden and adds valuable behavioral context beyond basic functionality. It discloses that the tool returns a dictionary with specific fields (search query, results, status, metadata), handles errors for empty/invalid queries with an 'error' status and explanatory message, and includes a limit parameter range (1-500). However, it does not mention rate limits, authentication needs, or pagination details.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose. The parameter and return value sections are structured clearly, but the return details could be more concise. Every sentence adds value, such as error handling and metadata, though it slightly extends beyond minimal necessity.

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?

Given the tool's moderate complexity, no annotations, and an output schema (implied by 'Returns a dictionary'), the description is complete enough. It covers purpose, parameters with semantics, return structure, and error behavior, providing all necessary context for an AI agent to use the tool effectively without needing to rely on structured fields alone.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must compensate, and it does so effectively. It adds meaning beyond the schema by explaining that 'query' is a search term to look up on Wikipedia and 'limit' is the maximum number of results (1-500), including the default value of 10 implied by the schema. This fully documents both parameters with clear semantics.

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 with a specific verb ('Search') and resource ('Wikipedia for articles'), and distinguishes it from siblings like get_article (which retrieves a specific article) or summarize_article_for_query (which summarizes rather than searches). It explicitly mentions 'matching a query,' which sets it apart from other search-related tools.

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 usage by stating it searches for articles, but does not explicitly guide when to use this tool versus alternatives like get_article (for known titles) or summarize_article_for_query (for summarized results). It mentions error handling for invalid queries, which provides some context, but lacks explicit when/when-not instructions or named alternatives.

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

Install Server

Other Tools

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