Skip to main content
Glama

get_act_table_of_contents

Extract the hierarchical table of contents for Polish legal acts, showing chapters, articles, and sections to understand document structure.

Instructions

Get the hierarchical structure and table of contents of a legal act. Shows chapters, articles, sections, and their organization.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
publisherYesPublisher code (DU for Dziennik Ustaw, MP for Monitor Polski)
yearYesPublication year
numYesAct number/position within the year

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • app.py:581-630 (handler)
    The @app.tool decorator registers the 'get_act_table_of_contents' tool, and the immediately following 'get_act_structure' function serves as the handler. It fetches the hierarchical structure (table of contents) of a legal act from the Sejm API using the provided publisher, year, and number parameters.
    @app.tool(
        name="get_act_table_of_contents",
        description="Get the hierarchical structure and table of contents of a legal act. Shows chapters, articles, sections, and their organization.",
        tags={"analysis", "structure", "navigation", "toc"}
    )
    def get_act_structure(
        publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"],
        year: Annotated[int, "Publication year"],
        num: Annotated[Union[int, str], "Act number/position within the year"]
    ) -> list:
        """Fetches the structure/table of contents of a specific legal act.
    
        Retrieves the hierarchical organization of a legal act, including parts, chapters,
        articles, sections, and other structural elements. This helps understand the
        document's organization and navigate to specific sections.
    
        Args:
            publisher: Publication code (e.g., 'DU' for Dziennik Ustaw, 'MP' for Monitor Polski).
            year: Year of publication as integer.
            num: Act number/position within the year as integer or string.
    
        Returns:
            list: List of structure elements with hierarchical organization, each containing
                  id, title, type, and children arrays. Returns empty list if structure not found.
    
        Examples:
            User asks: "Show me the structure of DU/2020/1":
                Parameters: publisher = 'DU', year = 2020, num = 1
                Returns: [{'id': 'part_1', 'title': 'Treść rozporządzenia', 'type': 'part', 'children': [...]}]
            User asks: "What is the table of contents for act MP/2023/50?":
                Parameters: publisher = 'MP', year = 2023, num = 50
            User asks: "Display the structure of DU/2019/100":
                Parameters: publisher = 'DU', year = 2019, num = 100
            User asks: "How is act DU/2022/75 organized?":
                Parameters: publisher = 'DU', year = 2022, num = 75
            User asks: "Give me the outline of legal act DU/2021/30":
                Parameters: publisher = 'DU', year = 2021, num = 30
        """
        logger.debug(f"get_act_structure called with: publisher={publisher}, year={year}, num={num}")
        try:
            url = f"https://api.sejm.gov.pl/eli/acts/{publisher}/{year}/{num}/struct"
            response = requests.get(url, headers={"Accept": "application/json"})
            response.raise_for_status()
    
            data = response.json()
            logger.info(f"get_act_structure retrieved structure for act: {publisher}/{year}/{num}")
            return data
        except Exception as e:
            logger.error(f"Error: {e}")
            return []
  • app.py:581-585 (registration)
    Tool registration via FastMCP @app.tool decorator, specifying the tool name, description, and tags.
    @app.tool(
        name="get_act_table_of_contents",
        description="Get the hierarchical structure and table of contents of a legal act. Shows chapters, articles, sections, and their organization.",
        tags={"analysis", "structure", "navigation", "toc"}
    )
  • Input schema defined by function parameters with Annotated types for publisher (str), year (int), num (int or str), and output as list.
    def get_act_structure(
        publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"],
        year: Annotated[int, "Publication year"],
        num: Annotated[Union[int, str], "Act number/position within the year"]
    ) -> list:
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the output structure but lacks details on permissions, rate limits, error handling, or whether it's a read-only operation. For a tool with no annotations, this leaves significant gaps in understanding its behavior beyond basic functionality.

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 a single, well-structured sentence that efficiently conveys the tool's purpose and output. It is front-loaded with the main action and resource, with no redundant or unnecessary information, making it highly concise and effective.

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 moderate complexity (3 parameters, read-only likely), 100% schema coverage, and the presence of an output schema (which handles return values), the description is reasonably complete. It clearly states what the tool does and the output structure, though it lacks behavioral context and usage guidelines, which slightly reduces completeness.

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 100% description coverage, clearly documenting all three required parameters (publisher, year, num). The description adds no parameter-specific information beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without compensating with extra 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 specific action ('Get') and resource ('hierarchical structure and table of contents of a legal act'), distinguishing it from siblings like get_act_content (which likely retrieves full text) or get_act_comprehensive_details (which may provide metadata). It specifies the output includes 'chapters, articles, sections, and their organization,' making the purpose explicit and differentiated.

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 such as get_act_content or get_act_comprehensive_details. It mentions the output structure but does not specify use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name alone.

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/numikel/law-scrapper-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server