Skip to main content
Glama

search_legal_acts

Search Polish legal acts using filters like date, type, keywords, or title to find specific documents from official sources.

Instructions

Advanced search for Polish legal acts with multiple filters. Use this for finding specific documents by criteria like date, type, keywords, or title. Note: When using multiple keywords, ALL keywords must be present in the act (AND logic).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNoPublication year (e.g., 2020, 2023)
keywordsNoList of keywords to search in act content. ALL keywords must be present in the act (AND logic)
date_fromNoStart date for effectiveness period (YYYY-MM-DD)
date_toNoEnd date for effectiveness period (YYYY-MM-DD)
titleNoText fragment to search in act titles
act_typeNoDocument type (e.g., 'Rozporządzenie', 'Ustawa')
pub_date_fromNoStart date for publication period (YYYY-MM-DD)
pub_date_toNoEnd date for publication period (YYYY-MM-DD)
in_forceNoOnly return currently active acts. Type 'true' for active, 'false' for inactive
limitNoMaximum number of results (default: all matching)
offsetNoSkip first N results for pagination

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • app.py:214-218 (registration)
    FastMCP decorator that registers the 'search_legal_acts' tool, defining its name, description, tags, and input schema via subsequent function parameters.
    @app.tool(
        name="search_legal_acts",
        description="Advanced search for Polish legal acts with multiple filters. Use this for finding specific documents by criteria like date, type, keywords, or title. Note: When using multiple keywords, ALL keywords must be present in the act (AND logic).",
        tags={"search", "acts", "filtering", "legal-research"}
    )
  • app.py:219-325 (handler)
    The main handler function that executes the tool logic: constructs search parameters, queries the Sejm API endpoint https://api.sejm.gov.pl/eli/acts/search, processes the response, and returns the list of matching legal acts.
    def get_acts_list(
        year: Annotated[Union[int, str, None], "Publication year (e.g., 2020, 2023)"] = None,
        keywords: Annotated[list[str] | None, "List of keywords to search in act content. ALL keywords must be present in the act (AND logic)"] = None,
        date_from: Annotated[str | None, "Start date for effectiveness period (YYYY-MM-DD)"] = None,
        date_to: Annotated[str | None, "End date for effectiveness period (YYYY-MM-DD)"] = None,
        title: Annotated[str | None, "Text fragment to search in act titles"] = None,
        act_type: Annotated[str | None, "Document type (e.g., 'Rozporządzenie', 'Ustawa')"] = None,
        pub_date_from: Annotated[str | None, "Start date for publication period (YYYY-MM-DD)"] = None,
        pub_date_to: Annotated[str | None, "End date for publication period (YYYY-MM-DD)"] = None,
        in_force: Annotated[Union[bool, str], "Only return currently active acts. Type 'true' for active, 'false' for inactive"] = None,
        limit: Annotated[Union[int, str, None], "Maximum number of results (default: all matching)"] = None,
        offset: Annotated[Union[int, str, None], "Skip first N results for pagination"] = None
    ) -> list:
        """Fetches a list of legal acts from the Sejm API based on specified filters.
    
        This function provides comprehensive search capabilities for Polish legal acts,
        allowing filtering by multiple criteria including publication year, keywords,
        effective dates, document types, and current legal status.
    
        IMPORTANT: When providing multiple keywords, ALL keywords must be present in the act
        (AND logic). If no results are found, try using fewer or different keywords.
        IMPORTANT: If you want to find acts related to multiple categories/topics, search for them one keyword at a time.
    
        Args:
            year: Publication year (e.g., 2020, 2023).
            keywords: List of keywords to search in act content. ALL keywords must be present in the act (AND logic).
            date_from: Start date for effectiveness period (YYYY-MM-DD).
            date_to: End date for effectiveness period (YYYY-MM-DD).
            title: Text fragment to search in act titles.
            act_type: Document type (e.g., 'Rozporządzenie', 'Ustawa').
            pub_date_from: Start date for publication period (YYYY-MM-DD).
            pub_date_to: End date for publication period (YYYY-MM-DD).
            in_force: Only return currently active acts ('true' for active, 'false' for inactive).
            limit: Maximum number of results to return.
            offset: Skip first N results for pagination.
    
        Returns:
            list: A list of legal acts matching the criteria, or empty list if no matches or error.
    
        Examples:
            User asks: "Please fetch all acts from the year 2020":
                Parameters: year = 2020
            User asks: "Please fetch all regulations from 2020":
                Parameters: year = 2020, act_type = 'Rozporządzenie'
            User asks: "Please fetch all acts with keywords 'sąd' and 'prawnik'":
                IMPORTANT: This will find acts containing BOTH 'sąd' AND 'prawnik'
                Parameters: keywords = ['sąd', 'prawnik']
                If you want to find acts containing 'sąd' OR 'prawnik', you need to search for them one keyword at a time.
                User asks: "Please fetch all acts with keywords 'sąd' or 'prawnik'":
                1st run:
                Parameters: keywords = ['sąd']
                2nd run:
                Parameters: keywords = ['prawnik']
            User asks: "Please fetch all currently active acts from 2020":
                Parameters: year = 2020, in_force = True
            User asks: "Please fetch acts containing 'zmieniające' in title from 2020":
                Parameters: year = 2020, title = 'zmieniające'
            User asks: "Please fetch first 10 acts from 2020":
                Parameters: year = 2020, limit = 10
        """
        logger.debug(f"get_acts_list called with filters: year={year}, keywords={keywords}, date_from={date_from}, date_to={date_to}, title={title}, act_type={act_type}, pub_date_from={pub_date_from}, pub_date_to={pub_date_to}, in_force={in_force}, limit={limit}, offset={offset}")
        try:
            # Build API request parameters from function arguments
            params = {
                "publisher": "DU",  # Default to Dziennik Ustaw (primary legal gazette)
            }
            if year:
                params["year"] = int(year) if isinstance(year, str) else year
            if keywords:
                params["keyword"] = ",".join(keywords)
            if date_from:
                params["dateEffectFrom"] = date_from
            if date_to:
                params["dateEffectTo"] = date_to
            if title:
                params["title"] = title
            if act_type:
                params["type"] = act_type
            if pub_date_from:
                params["dateFrom"] = pub_date_from
            if pub_date_to:
                params["dateTo"] = pub_date_to
            if in_force is not None:
                params["inForce"] = bool(in_force)
            if limit:
                params["limit"] = int(limit) if isinstance(limit, str) else limit
            if offset:
                params["offset"] = int(offset) if isinstance(offset, str) else offset
    
            url = "https://api.sejm.gov.pl/eli/acts/search"
    
            # Make API request with constructed parameters
            response = requests.get(url, params=params, headers={"Accept": "application/json"})
            response.raise_for_status()
    
            data = response.json().get("items", [])
    
            if not data:
                logger.info("get_acts_list returned no results")
                return []
    
            logger.info(f"get_acts_list returned {len(data)} acts")
            return data
        except Exception as e:
            logger.error(f"Error: {e}")
            return []
  • Input schema defined by Annotated type hints on function parameters, specifying optional filters for the search including year, keywords (AND logic), dates, title, type, publication dates, force status, limit, and offset.
    def get_acts_list(
        year: Annotated[Union[int, str, None], "Publication year (e.g., 2020, 2023)"] = None,
        keywords: Annotated[list[str] | None, "List of keywords to search in act content. ALL keywords must be present in the act (AND logic)"] = None,
        date_from: Annotated[str | None, "Start date for effectiveness period (YYYY-MM-DD)"] = None,
        date_to: Annotated[str | None, "End date for effectiveness period (YYYY-MM-DD)"] = None,
        title: Annotated[str | None, "Text fragment to search in act titles"] = None,
        act_type: Annotated[str | None, "Document type (e.g., 'Rozporządzenie', 'Ustawa')"] = None,
        pub_date_from: Annotated[str | None, "Start date for publication period (YYYY-MM-DD)"] = None,
        pub_date_to: Annotated[str | None, "End date for publication period (YYYY-MM-DD)"] = None,
        in_force: Annotated[Union[bool, str], "Only return currently active acts. Type 'true' for active, 'false' for inactive"] = None,
        limit: Annotated[Union[int, str, None], "Maximum number of results (default: all matching)"] = None,
        offset: Annotated[Union[int, str, None], "Skip first N results for pagination"] = None
    ) -> list:
Behavior4/5

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

With no annotations provided, the description carries full burden and adds valuable behavioral context: it discloses the AND logic for keyword matching ('ALL keywords must be present'), which is critical for understanding search behavior. However, it doesn't mention pagination behavior (implied by offset/limit parameters), rate limits, or authentication requirements.

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 perfectly front-loaded with the core purpose in the first clause, followed by usage guidance and a critical behavioral note. Every sentence earns its place - the first establishes purpose, the second provides usage context, and the third clarifies important search logic.

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 complexity (11 parameters, search functionality) and the presence of an output schema (which handles return values), the description is reasonably complete. It covers purpose, basic usage, and critical behavioral logic. The main gap is lack of guidance on when to use versus sibling tools, but this is partially mitigated by the output schema handling return format.

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?

Schema description coverage is 100%, so the schema already documents all 11 parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'date, type, keywords, or title' as examples and reinforcing the AND logic for keywords, but doesn't provide additional semantic context beyond what's in the parameter descriptions.

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 ('Advanced search for Polish legal acts') and resource type ('Polish legal acts'), distinguishing it from siblings like 'get_act_comprehensive_details' or 'get_act_content' which retrieve specific documents rather than search across multiple. The phrase 'with multiple filters' further clarifies its functionality.

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 provides implied usage context ('Use this for finding specific documents by criteria like date, type, keywords, or title'), but doesn't explicitly state when to use this tool versus alternatives like 'get_legal_types' or 'get_act_relationships'. No exclusions or clear sibling comparisons are provided.

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