get_publisher_year_acts
Retrieve all legal acts published by a specific publisher in a given year to browse complete annual collections of Polish legislation.
Instructions
Get all legal acts published by a specific publisher in a given year. Useful for browsing complete annual collections.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| publisher | Yes | Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski) | |
| year | Yes | Publication year (e.g., 2020, 2023) |
Implementation Reference
- app.py:421-464 (handler)The handler function `get_year_acts` implements the core logic for retrieving all legal acts published by a specific publisher in a given year from the Sejm API. It constructs the API URL, makes the GET request, and returns the response data or a default empty structure on error.def get_year_acts( publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"], year: Annotated[Union[int, str], "Publication year (e.g., 2020, 2023)"] ) -> dict: """Fetches a list of all legal acts for a specific publisher and year. Retrieves the complete collection of legal acts published in a specific year by a given publisher. This is useful for annual reviews, statistical analysis, and browsing complete yearly publications. Args: publisher: Publisher code (e.g., 'DU' for Dziennik Ustaw, 'MP' for Monitor Polski). year: Publication year as integer or string (e.g., 2020, 2023). Returns: dict: Object containing totalCount, items array with act details, and searchQuery info. Returns dict with zero counts and empty items array if year not found or error. Examples: User asks: "Show me all acts from DU in 2020": Parameters: publisher = 'DU', year = 2020 Returns: {'totalCount': 2463, 'items': [{'ELI': 'DU/2020/1', 'title': '...'}], 'count': 2463} User asks: "What acts were published in Monitor Polski in 2023?": Parameters: publisher = 'MP', year = 2023 User asks: "List all legal acts from Dziennik Ustaw for 2019": Parameters: publisher = 'DU', year = 2019 User asks: "How many acts were there in DU for 2022?": Parameters: publisher = 'DU', year = 2022 User asks: "Browse acts from MP published in 2024": Parameters: publisher = 'MP', year = 2024 """ logger.debug(f"get_year_acts called with publisher: {publisher}, year: {year}") try: url = f"https://api.sejm.gov.pl/eli/acts/{publisher}/{year}" response = requests.get(url, headers={"Accept": "application/json"}) response.raise_for_status() data = response.json() logger.info(f"get_year_acts retrieved {data.get('totalCount', 0)} acts for {publisher}/{year}") return data except Exception as e: logger.error(f"Error: {e}") return {"totalCount": 0, "items": [], "count": 0}
- app.py:416-420 (registration)The `@app.tool` decorator registers the `get_year_acts` function as the MCP tool named 'get_publisher_year_acts', providing its description and tags.@app.tool( name="get_publisher_year_acts", description="Get all legal acts published by a specific publisher in a given year. Useful for browsing complete annual collections.", tags={"search", "acts", "yearly", "browsing"} )
- app.py:422-424 (schema)The function parameters with Annotated types define the input schema for the tool, including descriptions used for validation and documentation.publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"], year: Annotated[Union[int, str], "Publication year (e.g., 2020, 2023)"] ) -> dict: