Skip to main content
Glama
Rudra-ravi

Wikipedia MCP Server

by Rudra-ravi

get_summary

Read-onlyIdempotent

Retrieve a concise summary and title of any Wikipedia article by providing its title.

Instructions

Get a summary of a Wikipedia article.

Returns a dictionary with the title and summary string. On error, includes an error message instead of a summary.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes
summaryNo
errorNo

Implementation Reference

  • The main handler function for the 'get_summary' tool. Decorated with @register_tool, it takes a title string, calls wikipedia_client.get_summary(), and returns a dictionary with title/summary/error.
    @register_tool("get_summary", model_output_schema(SummaryResponse))
    def get_summary(title: str):
        """
        Get a summary of a Wikipedia article.
    
        Returns a dictionary with the title and summary string. On error,
        includes an error message instead of a summary.
        """
        logger.info("Tool: Getting summary for: %s", title)
        summary = wikipedia_client.get_summary(title)
        if summary and not summary.startswith("Error"):
            return {"title": title, "summary": summary}
        return {"title": title, "summary": None, "error": summary}
  • The low-level Wikipedia API call that fetches the summary using the wikipedia library (page.summary). Handles errors and non-existent pages.
    def get_summary(self, title: str) -> str:
        """
        Get a summary of a Wikipedia article.
    
        Args:
            title: The title of the Wikipedia article.
    
        Returns:
            The article summary.
        """
        try:
            page = self.wiki.page(title)
    
            if not page.exists():
                return f"No Wikipedia article found for '{title}'."
    
            return page.summary
        except Exception as e:
            logger.error(f"Error getting Wikipedia summary: {e}")
            return f"Error retrieving summary for '{title}': {str(e)}"
  • The SummaryResponse Pydantic model defining the output schema for the get_summary tool: title (str), summary (Optional[str]), error (Optional[str]).
    class SummaryResponse(MCPBaseModel):
        title: str
        summary: Optional[str] = None
        error: Optional[str] = None
  • The register_tool decorator that registers the function under the name 'get_summary' (and also 'wikipedia_get_summary') with the MCP server, using the SummaryResponse output schema.
    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
  • Caching: get_summary is wrapped with lru_cache for performance when caching is enabled.
    self.get_summary = functools.lru_cache(maxsize=128)(self.get_summary)  # type: ignore[method-assign]

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.0.1
  2. Removedv1.5.8
  3. Changed1 schema field changedv1.0.0
    • removedInput schema / properties / title / title
      Removed value: -"Title"
  4. First observed

TDQS

A4.1/5.0
Behavior4/5

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

Annotations already declare read-only and idempotent behavior, allowing the description to focus on additional context. It discloses the return structure (dictionary with title and summary) and error behavior (error message instead of summary), which goes beyond the annotations.

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?

Two short sentences with no wasted words. The description is front-loaded with the primary action and immediately provides the essential return and error information.

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 simplicity, one self-explanatory parameter, an output schema, and strong annotations, the description is complete. It covers the key behavior (returns summary) and edge case (error message), so the agent has enough information to use the tool correctly.

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

Parameters3/5

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

With 1 parameter and 0% schema coverage, the description does not directly explain the 'title' parameter. However, the name 'title' is self-explanatory in the Wikipedia context, and the description implicitly references it as the article title. This is adequate but not exceptional, so a baseline score of 3 is appropriate.

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 gets a summary of a Wikipedia article, with a specific verb and resource. It distinguishes from siblings like get_article (full article) and get_sections (sections) by focusing specifically on the summary.

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 naming the summary function, but provides no explicit guidance on when to choose this over similar sibling tools like summarize_article_for_query or extract_key_facts. There is no mention of alternatives or exclusions.

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