Skip to main content
Glama

get_sections

Retrieve the section structure of a Wikipedia article to quickly navigate content and understand its organization.

Instructions

Get the sections of a Wikipedia article.

Returns a dictionary with the article title and list of sections.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration and thin handler for the 'get_sections' MCP tool using @server.tool() decorator. Delegates core logic to wikipedia_client.get_sections.
    @server.tool()
    def get_sections(title: str) -> Dict[str, Any]:
        """
        Get the sections of a Wikipedia article.
    
        Returns a dictionary with the article title and list of sections.
        """
        logger.info(f"Tool: Getting sections for: {title}")
        sections = wikipedia_client.get_sections(title)
        return {"title": title, "sections": sections}
  • Primary handler logic for retrieving Wikipedia article sections using wikipedia-api library. Fetches page.sections and processes with _extract_sections helper.
    def get_sections(self, title: str) -> List[Dict[str, Any]]:
        """
        Get the sections of a Wikipedia article.
    
        Args:
            title: The title of the Wikipedia article.
    
        Returns:
            A list of sections.
        """
        try:
            page = self.wiki.page(title)
    
            if not page.exists():
                return []
    
            return self._extract_sections(page.sections)
        except Exception as e:
            logger.error(f"Error getting Wikipedia sections: {e}")
            return []
  • Recursive helper function to extract hierarchical section structure from Wikipedia page.sections, including title, level, text, and subsections.
    def _extract_sections(self, sections, level=0) -> List[Dict[str, Any]]:
        """
        Extract sections recursively.
    
        Args:
            sections: The sections to extract.
            level: The current section level.
    
        Returns:
            A list of sections.
        """
        result = []
        for section in sections:
            section_data = {
                "title": section.title,
                "level": level,
                "text": section.text,
                "sections": self._extract_sections(section.sections, level + 1),
            }
            result.append(section_data)
        return result
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It mentions the return format ('dictionary with the article title and list of sections'), which is helpful, but lacks details on error handling, rate limits, authentication needs, or performance characteristics. For a tool with no annotations, this is insufficient to ensure safe and effective use.

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 with two sentences that are front-loaded: the first states the purpose, and the second describes the return value. There is no wasted text, making it efficient, though it could be slightly more structured for clarity.

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

Completeness4/5

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

Given the tool's low complexity (one parameter), the presence of an output schema (which handles return values), and no annotations, the description is reasonably complete. It covers the basic purpose and return format, but gaps in behavioral transparency and usage guidelines prevent a higher score.

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?

The input schema has 0% description coverage, so the description must compensate. It does not add any meaning beyond the schema, as it does not explain the 'title' parameter (e.g., what constitutes a valid Wikipedia article title). However, with only one parameter and an output schema present, the baseline is 3, as the schema provides some structure without extra semantic context.

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

Purpose4/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: 'Get the sections of a Wikipedia article.' It specifies the verb ('Get') and resource ('sections of a Wikipedia article'), making the action explicit. However, it does not differentiate from siblings like 'get_article' or 'summarize_article_section', which might offer overlapping functionality, so it falls short of a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings such as 'get_article', 'get_summary', and 'summarize_article_section', there is no indication of context, prerequisites, or exclusions. This lack of comparative information leaves the agent without clear usage direction.

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