search_legal_acts
Search Polish legal acts using filters like date, type, keywords, or title to find specific documents from Dziennik Ustaw and Monitor Polski.
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
| Name | Required | Description | Default |
|---|---|---|---|
| act_type | No | Document type (e.g., 'Rozporządzenie', 'Ustawa') | |
| date_from | No | Start date for effectiveness period (YYYY-MM-DD) | |
| date_to | No | End date for effectiveness period (YYYY-MM-DD) | |
| in_force | No | Only return currently active acts. Type 'true' for active, 'false' for inactive | |
| keywords | No | List of keywords to search in act content. ALL keywords must be present (AND logic) | |
| limit | No | Maximum number of results (default: all matching) | |
| offset | No | Skip first N results for pagination | |
| pub_date_from | No | Start date for publication period (YYYY-MM-DD) | |
| pub_date_to | No | End date for publication period (YYYY-MM-DD) | |
| title | No | Text fragment to search in act titles | |
| year | No | Publication year (e.g., 2020, 2023) |
Implementation Reference
- app.py:214-218 (registration)Registers the search_legal_acts tool using FastMCP's @app.tool decorator, specifying name, description, and tags.@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-231 (schema)Defines the input schema and parameters for the search_legal_acts tool using Python's Annotated types with descriptions.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:
- app.py:279-325 (handler)Implements the core execution logic of the search_legal_acts tool: builds query parameters from inputs, makes HTTP GET request to Sejm API search endpoint, processes response, and returns list of matching legal acts.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 []